--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
<projects>
</projects>
<buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
+Bundle-ActivationPolicy: lazy
<tags>shellMaximized</tags>
<tags>auth.cn=org.argeo.office.coworker,ou=roles,ou=node</tags>
<children xsi:type="basic:PartSashContainer" xmi:id="__LhVQMlHEeic2PiQZ6_KRg" elementId="org.argeo.suite.e4.partsashcontainer.1" selectedElement="_8xaqAP3vEeia6ei0NV0Yrw" horizontal="true">
- <children xsi:type="basic:Part" xmi:id="_xi1k0DDzEeiUfOa4rxEKwQ" elementId="org.argeo.suite.e4.part.documents" containerData="2000" contributionURI="bundleclass://org.argeo.connect.e4/org.argeo.documents.e4.parts.MyFilesView" label="%documents" iconURI="platform:/plugin/org.argeo.theme.argeo2/icons/types/documents.png"/>
+ <children xsi:type="basic:PartStack" xmi:id="_jfxwIPM8Eeqinoi2-PNjfw" elementId="org.argeo.suite.studio.partstack.0">
+ <children xsi:type="basic:Part" xmi:id="_xi1k0DDzEeiUfOa4rxEKwQ" elementId="org.argeo.suite.e4.part.siteMap" containerData="2000" contributionURI="bundleclass://org.argeo.suite.studio/org.argeo.suite.studio.parts.SiteMapPart" label="Site Map" iconURI="platform:/plugin/org.argeo.theme.argeo2/icons/types/documents.png"/>
+ </children>
<children xsi:type="basic:PartStack" xmi:id="_8xaqAP3vEeia6ei0NV0Yrw" elementId="org.argeo.suite.e4.partstack.entityEditorArea" containerData="8000">
<tags>entityEditorArea</tags>
<children xsi:type="basic:Part" xmi:id="_EQBUIP3xEeia6ei0NV0Yrw" elementId="org.argeo.suite.e4.part.defaultDashboard" contributionURI="bundleclass://org.argeo.connect.e4/org.argeo.documents.e4.parts.DocumentsDashboard" label="" iconURI="platform:/plugin/org.argeo.theme.argeo2/icons/types/dashboard.png" tooltip="%dashboard">
--- /dev/null
+package org.argeo.suite.studio.parts;
+
+import org.eclipse.rap.rwt.application.ApplicationConfiguration;
+import org.osgi.framework.ServiceReference;
+
+/** Site map element representing an RWT application. */
+class RwtAppElem extends SiteElem {
+ private final static String CONTEXT_NAME = "contextName";
+
+ private final ServiceReference<ApplicationConfiguration> serviceReference;
+
+ public RwtAppElem(ServiceReference<ApplicationConfiguration> serviceReference) {
+ super(serviceReference.getProperties().get(CONTEXT_NAME).toString());
+ this.serviceReference = serviceReference;
+ }
+
+ public ServiceReference<ApplicationConfiguration> getServiceReference() {
+ return serviceReference;
+ }
+
+}
--- /dev/null
+package org.argeo.suite.studio.parts;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import javax.servlet.Servlet;
+
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.context.ServletContextHelper;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+/** Site map element which is a plain servlet. */
+class ServletElem extends SiteElem {
+ private final ServiceReference<Servlet> serviceReference;
+
+ public ServletElem(ServiceReference<Servlet> serviceReference) {
+ super(extractPath(serviceReference));
+ this.serviceReference = serviceReference;
+ }
+
+
+
+ public ServiceReference<Servlet> getServiceReference() {
+ return serviceReference;
+ }
+
+
+
+ private static String extractPath(ServiceReference<Servlet> serviceReference) {
+ Object servletPattern = serviceReference.getProperties()
+ .get(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN);
+ Object servletContextSelect = serviceReference.getProperties()
+ .get(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT);
+ String servletContextPath = "";
+ if (servletContextSelect != null) {
+ try {
+ Collection<ServiceReference<ServletContextHelper>> scSr = serviceReference.getBundle()
+ .getBundleContext()
+ .getServiceReferences(ServletContextHelper.class, servletContextSelect.toString());
+ if (scSr.size() > 0) {
+ servletContextPath = scSr.iterator().next()
+ .getProperty(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH).toString();
+ if (servletContextPath.equals("/"))// default servlet context
+ servletContextPath = "";
+ }
+ } catch (InvalidSyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ if (servletPattern instanceof String)
+ return servletContextPath + servletPattern.toString();
+ else if (servletPattern instanceof String[]) {
+ String[] patterns = (String[]) servletPattern;
+ if (patterns.length == 2 && patterns[1].equals(patterns[0] + "/*")) // RAP servlets
+ return servletContextPath + patterns[0];
+ return servletContextPath + Arrays.asList(patterns).toString();
+ } else
+ throw new IllegalArgumentException("Cannot interpret servlet pattern " + servletPattern.getClass());
+ }
+}
--- /dev/null
+package org.argeo.suite.studio.parts;
+
+import org.argeo.eclipse.ui.TreeParent;
+
+/** Base class for site map elements. */
+abstract class SiteElem extends TreeParent {
+
+ private final String path;
+
+ public SiteElem(String path) {
+ super(extractLastSegment(path));
+ this.path = path;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ static String extractLastSegment(String path) {
+ if (path == null || path.equals(""))
+ throw new IllegalArgumentException("Path should not be null or empty.");
+ if (path.equals("/"))
+ return path;
+ String[] segments = path.split("/");
+ for (int i = segments.length - 1; i >= 0; i--) {
+ if (!segments[i].equals("") && !segments[i].equals("*"))
+ return segments[i];
+ }
+ return "/";
+ }
+
+ @Override
+ public String toString() {
+ return path;
+ }
+
+}
--- /dev/null
+package org.argeo.suite.studio.parts;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.servlet.Servlet;
+
+import org.argeo.eclipse.ui.AbstractTreeContentProvider;
+import org.eclipse.e4.core.di.extensions.OSGiBundle;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.TreeViewerColumn;
+import org.eclipse.rap.rwt.application.ApplicationConfiguration;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+
+/** Overview of the URL paths provides by the system. */
+@SuppressWarnings("restriction")
+public class SiteMapPart {
+// private final static BundleContext bc = FrameworkUtil.getBundle(SiteMapPart.class).getBundleContext();
+
+ private TreeViewer viewer;
+
+ @Inject
+ @OSGiBundle
+ BundleContext bc;
+
+ @PostConstruct
+ public void createPartControl(Composite parent) {
+// new Label(parent, SWT.NONE).setText("TEST");
+//
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+// viewer.getTree().setHeaderVisible(true);
+
+// viewer.setLabelProvider(new ColumnLabelProvider());
+
+ TreeViewerColumn column = new TreeViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setWidth(200);
+ column.getColumn().setText("Path");
+ column.setLabelProvider(new ColumnLabelProvider() {
+ private static final long serialVersionUID = -3122136344359358605L;
+
+ public String getText(Object element) {
+ return ((SiteElem) element).getPath();
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ return super.getImage(element);
+ }
+
+ });
+
+ viewer.setContentProvider(new SitePathContentProvider());
+ viewer.setInput(bc);
+
+ }
+
+ class SitePathContentProvider extends AbstractTreeContentProvider {
+ private static final long serialVersionUID = -5650173256183322051L;
+
+ @Override
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof BundleContext) {
+ BundleContext bundleContext = (BundleContext) inputElement;
+ Map<String, SiteElem> siteElems = new TreeMap<>();
+ try {
+ Collection<ServiceReference<ApplicationConfiguration>> rwtApps = bundleContext
+ .getServiceReferences(ApplicationConfiguration.class, null);
+ for (ServiceReference<ApplicationConfiguration> sr : rwtApps) {
+ RwtAppElem elem = new RwtAppElem(sr);
+ siteElems.put(elem.getPath(), elem);
+ }
+ Collection<ServiceReference<Servlet>> plainServlets = bundleContext
+ .getServiceReferences(Servlet.class, null);
+ for (ServiceReference<Servlet> sr : plainServlets) {
+ ServletElem elem = new ServletElem(sr);
+ siteElems.put(elem.getPath(), elem);
+ }
+ } catch (InvalidSyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ return siteElems.values().toArray();
+ }
+ return null;
+ }
+
+ }
+}