com.sap.cds.feature.dashboard.index.DashboardIndexContentProviderFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cds-feature-dev-dashboard Show documentation
Show all versions of cds-feature-dev-dashboard Show documentation
Development Dashboard for CDS Services Java
package com.sap.cds.feature.dashboard.index;
import java.io.PrintWriter;
import com.sap.cds.adapter.IndexContentProvider;
import com.sap.cds.adapter.IndexContentProviderFactory;
import com.sap.cds.services.runtime.CdsRuntime;
import com.sap.cds.services.runtime.CdsRuntimeAware;
/**
* Explicitly adds links to UI resources provided by this application to the index page
*/
public class DashboardIndexContentProviderFactory implements IndexContentProviderFactory, CdsRuntimeAware {
private CdsRuntime runtime;
@Override
public void setCdsRuntime(CdsRuntime runtime) {
this.runtime = runtime;
}
@Override
public IndexContentProvider create() {
return new UiIndexContentProvider();
}
@Override
public boolean isEnabled() {
return runtime.getEnvironment().getCdsProperties().getIndexPage().isEnabled();
}
private static class UiIndexContentProvider implements IndexContentProvider {
private static final String ENDPOINT_START = "" +
" \n";
private static final String ENDPOINT = "" +
" - \n" +
" %s\n" +
"
\n";
private static final String ENDPOINT_END = "" +
"
\n";
@Override
public int order() {
return -100;
}
@Override
public String getSectionTitle() {
return "CAP Developer Dashboard";
}
@Override
public void writeContent(PrintWriter writer, String contextPath) {
writer.print(ENDPOINT_START);
writer.printf(ENDPOINT, contextPath + "dashboard", "Dashboard UI");
writer.print(ENDPOINT_END);
}
}
}