You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2020/01/07 10:16:33 UTC
[sling-org-apache-sling-installer-console] branch master updated:
SLING-5746 provide TOC
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-installer-console.git
The following commit(s) were added to refs/heads/master by this push:
new 36b9a9b SLING-5746 provide TOC
36b9a9b is described below
commit 36b9a9bccb32cf24bf49f7cbda8b8da4c5cab496
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Jan 7 11:16:26 2020 +0100
SLING-5746 provide TOC
---
.../console/OsgiInstallerWebConsolePlugin.java | 75 ++++++++++++++++++----
src/main/resources/res/ui/list.css | 28 ++++++++
2 files changed, 92 insertions(+), 11 deletions(-)
diff --git a/src/main/java/org/apache/sling/installer/core/impl/console/OsgiInstallerWebConsolePlugin.java b/src/main/java/org/apache/sling/installer/core/impl/console/OsgiInstallerWebConsolePlugin.java
index 8c5c244..40c1218 100644
--- a/src/main/java/org/apache/sling/installer/core/impl/console/OsgiInstallerWebConsolePlugin.java
+++ b/src/main/java/org/apache/sling/installer/core/impl/console/OsgiInstallerWebConsolePlugin.java
@@ -20,6 +20,8 @@ package org.apache.sling.installer.core.impl.console;
import java.io.IOException;
import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collection;
@@ -48,15 +50,20 @@ import org.osgi.service.component.annotations.ReferencePolicyOption;
property = {
Constants.SERVICE_VENDOR + "=The Apache Software Foundation",
Constants.SERVICE_DESCRIPTION + "=Apache Sling OSGi Installer Web Console Plugin",
- "felix.webconsole.label=osgi-installer",
+ "felix.webconsole.label=" + OsgiInstallerWebConsolePlugin.LABEL,
"felix.webconsole.title=OSGi Installer",
"felix.webconsole.category=OSGi",
"felix.webconsole.configprinter.modes=zip",
- "felix.webconsole.configprinter.modes=txt"
+ "felix.webconsole.configprinter.modes=txt",
+ "felix.webconsole.css=" + OsgiInstallerWebConsolePlugin.RES_LOC + "/list.css"
})
@SuppressWarnings("serial")
public class OsgiInstallerWebConsolePlugin extends GenericServlet {
+ public static final String LABEL = "osgi-installer";
+ protected static final String RES_LOC = LABEL + "/res/ui";
+
+
@Reference(policyOption=ReferencePolicyOption.GREEDY)
private InfoProvider installer;
@@ -130,23 +137,34 @@ public class OsgiInstallerWebConsolePlugin extends GenericServlet {
@Override
public void service(final ServletRequest req, final ServletResponse res)
throws IOException {
- final PrintWriter pw = res.getWriter();
+ StringWriter bufferedWriter = new StringWriter();
+ final PrintWriter pw = new PrintWriter(bufferedWriter);
+ PrintWriter headerPrintWriter = res.getWriter();
final InstallationState state = this.installer.getInstallationState();
- pw.print("<p class='statline ui-state-highlight'>Apache Sling OSGi Installer");
+ headerPrintWriter.print("<p class='statline ui-state-highlight'>Apache Sling OSGi Installer");
if ( state.getActiveResources().size() == 0 && state.getInstalledResources().size() == 0 && state.getUntransformedResources().size() == 0 ) {
- pw.print(" - no resources registered.");
+ headerPrintWriter.print(" - no resources registered.");
}
- pw.print("</p>");
-
+
+
+
+ headerPrintWriter.print("</p>");
+ headerPrintWriter.println("<ul class=list>");
+ headerPrintWriter.println("<li>Active Resources");
+ headerPrintWriter.println("<ul>");
+
+
String rt = null;
- for(final ResourceGroup group : state.getActiveResources()) {
+ for (final ResourceGroup group : state.getActiveResources()) {
final Resource toActivate = group.getResources().get(0);
if ( !toActivate.getType().equals(rt) ) {
if ( rt != null ) {
pw.println("</tbody></table>");
}
- pw.println("<div class='ui-widget-header ui-corner-top buttonGroup' style='height: 15px;'>");
+ String anchor = "active-" + getType(toActivate);
+ headerPrintWriter.println("<li><a href='#" + anchor + "'>" + getType(toActivate) + "</a></li>");
+ pw.println("<div id='" + anchor + "' class='ui-widget-header ui-corner-top buttonGroup' style='height: 15px;'>");
pw.printf("<span style='float: left; margin-left: 1em;'>Active Resources - %s</span>", getType(toActivate));
pw.println("</div>");
pw.println("<table class='nicetable'><tbody>");
@@ -162,9 +180,15 @@ public class OsgiInstallerWebConsolePlugin extends GenericServlet {
}
if ( rt != null ) {
pw.println("</tbody></table>");
+ } else {
+ headerPrintWriter.println("<li>none</li>");
}
rt = null;
+ headerPrintWriter.println("</ul></li>");
+ headerPrintWriter.println("<li>Processed Resources");
+ headerPrintWriter.println("<ul>");
+
for(final ResourceGroup group : state.getInstalledResources()) {
final Collection<Resource> resources = group.getResources();
if (resources.size() > 0) {
@@ -174,7 +198,10 @@ public class OsgiInstallerWebConsolePlugin extends GenericServlet {
if ( rt != null ) {
pw.println("</tbody></table>");
}
- pw.println("<div class='ui-widget-header ui-corner-top buttonGroup' style='height: 15px;'>");
+ String anchor = "processed-" + getType(first);
+ headerPrintWriter.println("<li><a href='#" + anchor + "'>" + getType(first) + "</a></li>");
+
+ pw.println("<div id='" + anchor + "' class='ui-widget-header ui-corner-top buttonGroup' style='height: 15px;'>");
pw.printf("<span style='float: left; margin-left: 1em;'>Processed Resources - %s</span>", getType(first));
pw.println("</div>");
pw.println("<table class='nicetable'><tbody>");
@@ -220,15 +247,24 @@ public class OsgiInstallerWebConsolePlugin extends GenericServlet {
}
if ( rt != null ) {
pw.println("</tbody></table>");
+ } else {
+ headerPrintWriter.println("<li>none</li>");
}
+ headerPrintWriter.println("</ul></li>");
+ headerPrintWriter.println("<li>Untransformed Resources");
+ headerPrintWriter.println("<ul>");
+
rt = null;
for(final RegisteredResource registeredResource : state.getUntransformedResources()) {
if ( !registeredResource.getType().equals(rt) ) {
if ( rt != null ) {
pw.println("</tbody></table>");
}
- pw.println("<div class='ui-widget-header ui-corner-top buttonGroup' style='height: 15px;'>");
+ String anchor = "untransformed-" + getType(registeredResource);
+ headerPrintWriter.println("<li><a href='#" + anchor + "'>" + getType(registeredResource) + "</a></li>");
+
+ pw.println("<div id='" + anchor + "' class='ui-widget-header ui-corner-top buttonGroup' style='height: 15px;'>");
pw.printf("<span style='float: left; margin-left: 1em;'>Untransformed Resources - %s</span>", getType(registeredResource));
pw.println("</div>");
pw.println("<table class='nicetable'><tbody>");
@@ -242,7 +278,13 @@ public class OsgiInstallerWebConsolePlugin extends GenericServlet {
}
if ( rt != null ) {
pw.println("</tbody></table>");
+ } else {
+ headerPrintWriter.println("<li>none</li>");
}
+
+ headerPrintWriter.println("</ul></li>");
+ headerPrintWriter.println("</ul>");
+ headerPrintWriter.print(bufferedWriter.toString());
}
/**
@@ -325,4 +367,15 @@ public class OsgiInstallerWebConsolePlugin extends GenericServlet {
registeredResource.getURL());
}
}
+
+ /**
+ * Method to retrieve static resources from this bundle.
+ */
+ @SuppressWarnings("unused")
+ private URL getResource(final String path) {
+ if (path.startsWith("/" + RES_LOC)) {
+ return this.getClass().getResource(path.substring(LABEL.length()+1));
+ }
+ return null;
+ }
}
diff --git a/src/main/resources/res/ui/list.css b/src/main/resources/res/ui/list.css
new file mode 100644
index 0000000..5983791
--- /dev/null
+++ b/src/main/resources/res/ui/list.css
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+.list ul, ul.list {
+ /* set to 0 if your not using a list-style-type */
+ padding-left: 40px;
+ list-style-position: inside;
+}
+
+.list li {
+ list-style-type: disc;
+ display: list-item;
+}
\ No newline at end of file