org.argeo.dep.osgi.catalina.start,\
org.argeo.jackrabbit.webapp,\
org.argeo.server.rap.webapp,\
-org.argeo.jcr.ui.explorer,\
-org.argeo.security.ui,\
-org.argeo.security.ui.rap,\
-org.argeo.security.ui.admin,\
org.argeo.server.ads.server,\
org.springframework.osgi.web.extender,\
-org.argeo.security.ui.initialPerspective=org.argeo.jcr.ui.explorer.perspective
+#org.argeo.security.ui.initialPerspective=org.argeo.jcr.ui.explorer.perspective
+org.argeo.security.ui.initialPerspective=org.argeo.osgi.ui.explorer.perspective
argeo.node.repo.home=~/.argeo/server_noderepo
argeo.node.repo.dburl=jdbc:h2:file:~/.argeo/h2/server_noderepo_db
<artifactId>org.eclipse.rap.ui</artifactId>
</dependency>
- <!-- Jetty (TO BE REMOVED and replaced by Tomcat -->
+ <!-- Jetty (TO BE REMOVED and replaced by Tomcat
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.http.jetty</artifactId>
<groupId>org.mortbay.jetty</groupId>
<artifactId>org.mortbay.jetty.util</artifactId>
</dependency>
+ -->
+
<!-- Eclipse -->
<dependency>
<groupId>org.eclipse.core</groupId>
--- /dev/null
+package org.argeo.eclipse.ui;
+
+import java.util.Comparator;
+
+import org.eclipse.jface.viewers.ColumnViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+
+/** Generic column viewer sortter */
+public class ColumnViewerComparator<T> extends ViewerComparator {
+ public static final int ASC = 1;
+
+ public static final int NONE = 0;
+
+ public static final int DESC = -1;
+
+ private int direction = 0;
+
+ private TableViewerColumn column;
+
+ private ColumnViewer viewer;
+
+ public ColumnViewerComparator(TableViewerColumn column,
+ Comparator<T> comparator) {
+ super(comparator);
+ this.column = column;
+ this.viewer = column.getViewer();
+ this.column.getColumn().addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ if (ColumnViewerComparator.this.viewer.getComparator() != null) {
+ if (ColumnViewerComparator.this.viewer.getComparator() == ColumnViewerComparator.this) {
+ int tdirection = ColumnViewerComparator.this.direction;
+
+ if (tdirection == ASC) {
+ setSortDirection(DESC);
+ } else if (tdirection == DESC) {
+ setSortDirection(NONE);
+ }
+ } else {
+ setSortDirection(ASC);
+ }
+ } else {
+ setSortDirection(ASC);
+ }
+ }
+ });
+ }
+
+ private void setSortDirection(int direction) {
+ if (direction == NONE) {
+ column.getColumn().getParent().setSortColumn(null);
+ column.getColumn().getParent().setSortDirection(SWT.NONE);
+ viewer.setComparator(null);
+ } else {
+ column.getColumn().getParent().setSortColumn(column.getColumn());
+ this.direction = direction;
+
+ if (direction == ASC) {
+ column.getColumn().getParent().setSortDirection(SWT.DOWN);
+ } else {
+ column.getColumn().getParent().setSortDirection(SWT.UP);
+ }
+
+ if (viewer.getComparator() == this) {
+ viewer.refresh();
+ } else {
+ viewer.setComparator(this);
+ }
+
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ return direction * getComparator().compare((T) e1, (T) e2);
+ }
+}
--- /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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.argeo.osgi.ui.explorer</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
--- /dev/null
+#Sun Sep 04 16:04:00 CEST 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
--- /dev/null
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSGi Explorer
+Bundle-SymbolicName: org.argeo.osgi.ui.explorer;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.argeo.osgi.ui.explorer.OsgiExplorerPlugin
+Require-Bundle: org.eclipse.ui;resolution:=optional,
+ org.eclipse.rap.ui;resolution:=optional,
+ org.eclipse.core.runtime
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Import-Package: org.apache.commons.logging;version="1.1.1",
+ org.argeo.eclipse.ui
--- /dev/null
+source.. = src/main/java/
+output.. = target/classes/
+bin.includes = META-INF/,\
+ .,\
+ icons/,\
+ plugin.xml
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.perspectives">
+ <perspective
+ name="OSGi Explorer"
+ class="org.argeo.osgi.ui.explorer.OsgiExplorerPerspective"
+ id="org.argeo.osgi.ui.explorer.perspective"
+ icon="icons/osgi_explorer.gif">
+ </perspective>
+ </extension>
+ <extension point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="org.argeo.osgi.ui.explorer.perspective">
+ <view id="org.argeo.osgi.ui.explorer.modulesView" minimized="false"
+ ratio="0.5" relationship="left" relative="org.eclipse.ui.editorss"/>
+ <view id="org.argeo.osgi.ui.explorer.bundlesView" minimized="false"
+ relationship="stack" relative="org.argeo.osgi.ui.explorer.modulesView"/>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ class="org.argeo.osgi.ui.explorer.views.ModulesView"
+ icon="icons/bundles.gif"
+ id="org.argeo.osgi.ui.explorer.modulesView"
+ name="Modules">
+ </view>
+ <view
+ class="org.argeo.osgi.ui.explorer.views.BundlesView"
+ icon="icons/bundles.gif"
+ id="org.argeo.osgi.ui.explorer.bundlesView"
+ name="Bundles">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.activities">
+ <activity
+ description="Only for admins"
+ id="org.argeo.osgi.ui.explorer.adminActivity"
+ name="Admin">
+ <enabledWhen>
+ <with variable="roles">
+ <iterate ifEmpty="false" operator="or">
+ <equals value="ROLE_ADMIN" />
+ </iterate>
+ </with>
+ </enabledWhen>
+ </activity>
+ <activityPatternBinding
+ activityId="org.argeo.osgi.ui.explorer.adminActivity"
+ isEqualityPattern="true"
+ pattern="org.argeo.osgi.ui.explorer/org.argeo.osgi.ui.explorer.perspective">
+ </activityPatternBinding>
+ </extension>
+</plugin>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons.osgi</groupId>
<artifactId>org.argeo.osgi.ui.explorer</artifactId>
<name>Commons OSGi Explorer</name>
<dependencies>
+ <dependency>
+ <groupId>org.argeo.commons.eclipse</groupId>
+ <artifactId>org.argeo.eclipse.ui</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
<!-- RCP only dependency, needed at compile time -->
<dependency>
--- /dev/null
+package org.argeo.osgi.ui.explorer;
+
+import org.eclipse.swt.graphics.Image;
+
+/** Shared icons. */
+public class OsgiExplorerImages {
+ public final static Image INSTALLED = OsgiExplorerPlugin
+ .getImageDescriptor("icons/installed.gif").createImage();
+ public final static Image RESOLVED = OsgiExplorerPlugin.getImageDescriptor(
+ "icons/resolved.gif").createImage();
+ public final static Image STARTING = OsgiExplorerPlugin.getImageDescriptor(
+ "icons/starting.gif").createImage();
+ public final static Image ACTIVE = OsgiExplorerPlugin.getImageDescriptor(
+ "icons/active.gif").createImage();
+}
--- /dev/null
+package org.argeo.osgi.ui.explorer;
+
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+
+/** OSGi explorer perspective (to be enriched declaratively) */
+public class OsgiExplorerPerspective implements IPerspectiveFactory {
+
+ public void createInitialLayout(IPageLayout layout) {
+ layout.setEditorAreaVisible(true);
+ layout.setFixed(false);
+
+ }
+
+}
--- /dev/null
+package org.argeo.osgi.ui.explorer;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class OsgiExplorerPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.argeo.osgi.ui.explorer"; //$NON-NLS-1$
+
+ // The shared instance
+ private static OsgiExplorerPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public OsgiExplorerPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+ * )
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+ * )
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static OsgiExplorerPlugin getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+
+}
--- /dev/null
+package org.argeo.osgi.ui.explorer.views;
+
+import java.util.Comparator;
+
+import org.argeo.eclipse.ui.ColumnViewerComparator;
+import org.argeo.osgi.ui.explorer.OsgiExplorerImages;
+import org.argeo.osgi.ui.explorer.OsgiExplorerPlugin;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.part.ViewPart;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+/**
+ * Overview of the bundles as a table. Equivalent to Equinox 'ss' console
+ * command.
+ */
+public class BundlesView extends ViewPart {
+ private TableViewer viewer;
+
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TableViewer(parent);
+ viewer.setContentProvider(new BundleContentProvider());
+ viewer.getTable().setHeaderVisible(true);
+
+ // FIXME methodNotFound issue in RAP when built in Maven against RCP
+ try {
+ ColumnViewerToolTipSupport.enableFor(viewer);
+ } catch (Exception e) {
+ viewer.getControl()
+ .setData(Table.ENABLE_CELL_TOOLTIP, Boolean.TRUE);
+ }
+
+ // ID
+ TableViewerColumn column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setWidth(30);
+ column.getColumn().setText("ID");
+ column.getColumn().setAlignment(SWT.RIGHT);
+ column.setLabelProvider(new ColumnLabelProvider() {
+ public String getText(Object element) {
+ return Long.toString(((Bundle) element).getBundleId());
+ }
+ });
+ new ColumnViewerComparator<Bundle>(column, new Comparator<Bundle>() {
+ public int compare(Bundle o1, Bundle o2) {
+ return (int) (o1.getBundleId() - o2.getBundleId());
+ }
+ });
+
+ // State
+ column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setWidth(16);
+ column.getColumn().setText("State");
+ column.setLabelProvider(new StateLabelProvider());
+ new ColumnViewerComparator<Bundle>(column, new Comparator<Bundle>() {
+ public int compare(Bundle o1, Bundle o2) {
+ return o1.getState() - o2.getState();
+ }
+ });
+
+ // Symbolic name
+ column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setWidth(300);
+ column.getColumn().setText("Symbolic Name");
+ column.setLabelProvider(new ColumnLabelProvider() {
+ public String getText(Object element) {
+ return ((Bundle) element).getSymbolicName();
+ }
+ });
+ new ColumnViewerComparator<Bundle>(column, new Comparator<Bundle>() {
+ public int compare(Bundle o1, Bundle o2) {
+ return o1.getSymbolicName().compareTo(o2.getSymbolicName());
+ }
+ });
+
+ // Version
+ column = new TableViewerColumn(viewer, SWT.NONE);
+ column.getColumn().setWidth(150);
+ column.getColumn().setText("Version");
+ column.setLabelProvider(new ColumnLabelProvider() {
+ public String getText(Object element) {
+ return ((Bundle) element).getVersion().toString();
+ }
+ });
+ new ColumnViewerComparator<Bundle>(column, new Comparator<Bundle>() {
+ public int compare(Bundle o1, Bundle o2) {
+ return o1.getVersion().compareTo(o2.getVersion());
+ }
+ });
+
+ viewer.setInput(OsgiExplorerPlugin.getDefault().getBundle()
+ .getBundleContext());
+
+ }
+
+ @Override
+ public void setFocus() {
+ if (viewer != null)
+ viewer.getControl().setFocus();
+ }
+
+ /** Content provider managing the array of bundles */
+ private static class BundleContentProvider implements
+ IStructuredContentProvider {
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof BundleContext) {
+ BundleContext bc = (BundleContext) inputElement;
+ return bc.getBundles();
+ }
+ return null;
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ }
+
+ /** Label provider for the state column */
+ private static class StateLabelProvider extends ColumnLabelProvider {
+ @Override
+ public Image getImage(Object element) {
+ Integer state = ((Bundle) element).getState();
+ switch (state) {
+ case Bundle.UNINSTALLED:
+ return OsgiExplorerImages.INSTALLED;
+ case Bundle.INSTALLED:
+ return OsgiExplorerImages.INSTALLED;
+ case Bundle.RESOLVED:
+ return OsgiExplorerImages.RESOLVED;
+ case Bundle.STARTING:
+ return OsgiExplorerImages.STARTING;
+ case Bundle.STOPPING:
+ return OsgiExplorerImages.STARTING;
+ case Bundle.ACTIVE:
+ return OsgiExplorerImages.ACTIVE;
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public String getText(Object element) {
+ return null;
+ }
+
+ @Override
+ public String getToolTipText(Object element) {
+ Bundle bundle = (Bundle) element;
+ Integer state = bundle.getState();
+ switch (state) {
+ case Bundle.UNINSTALLED:
+ return "UNINSTALLED";
+ case Bundle.INSTALLED:
+ return "INSTALLED";
+ case Bundle.RESOLVED:
+ return "RESOLVED";
+ case Bundle.STARTING:
+ String activationPolicy = bundle.getHeaders()
+ .get(Constants.BUNDLE_ACTIVATIONPOLICY).toString();
+ if (activationPolicy != null
+ && activationPolicy.equals(Constants.ACTIVATION_LAZY))
+ return "<<LAZY>>";
+ return "STARTING";
+ case Bundle.STOPPING:
+ return "STOPPING";
+ case Bundle.ACTIVE:
+ return "ACTIVE";
+ default:
+ return null;
+ }
+ }
+
+ }
+}
--- /dev/null
+package org.argeo.osgi.ui.explorer.views;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.argeo.eclipse.ui.TreeParent;
+import org.argeo.osgi.ui.explorer.OsgiExplorerPlugin;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.ViewPart;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/** <b>Experimental</b> The OSGi runtime from a module perspective. */
+public class ModulesView extends ViewPart {
+ private final static Log log = LogFactory.getLog(ModulesView.class);
+
+ private TreeViewer viewer;
+
+ private PackageAdmin packageAdmin;
+
+ private Comparator<ExportedPackage> exportedPackageComparator = new Comparator<ExportedPackage>() {
+
+ public int compare(ExportedPackage o1, ExportedPackage o2) {
+ if (!o1.getName().equals(o2.getName()))
+ return o1.getName().compareTo(o2.getName());
+ else
+ return o1.getVersion().compareTo(o2.getVersion());
+ }
+ };
+
+ @Override
+ public void createPartControl(Composite parent) {
+ viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setContentProvider(new ModulesContentProvider());
+ viewer.setLabelProvider(new ModulesLabelProvider());
+ viewer.setInput(OsgiExplorerPlugin.getDefault().getBundle()
+ .getBundleContext());
+ }
+
+ @Override
+ public void setFocus() {
+ viewer.getTree().setFocus();
+ }
+
+ private class ModulesContentProvider implements ITreeContentProvider {
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof BundleContext) {
+ BundleContext bundleContext = (BundleContext) parentElement;
+ Bundle[] bundles = bundleContext.getBundles();
+
+ TreeParent bundlesNode = new TreeParent("Bundles");
+ for (Bundle bundle : bundles) {
+ if (bundle.getState() == Bundle.ACTIVE)
+ bundlesNode.addChild(new BundleNode(bundle));
+ }
+
+ // scan packages
+ ServiceReference paSr = bundleContext
+ .getServiceReference(PackageAdmin.class.getName());
+ // TODO: make a cleaner referencing
+ packageAdmin = (PackageAdmin) bundleContext.getService(paSr);
+
+ Bundle bundle1 = null;
+ Bundle bundle2 = null;
+
+ Map<Bundle, Set<ExportedPackage>> importedPackages = new HashMap<Bundle, Set<ExportedPackage>>();
+ Map<String, Set<ExportedPackage>> packages = new TreeMap<String, Set<ExportedPackage>>();
+ for (Bundle bundle : bundles) {
+ if (bundle.getSymbolicName()
+ .equals("org.argeo.security.ui"))
+ bundle1 = bundle;
+ if (bundle.getSymbolicName().equals(
+ "org.argeo.security.equinox"))
+ bundle2 = bundle;
+
+ ExportedPackage[] pkgs = packageAdmin
+ .getExportedPackages(bundle);
+ if (pkgs != null)
+ for (ExportedPackage pkg : pkgs) {
+ if (!packages.containsKey(pkg.getName()))
+ packages.put(pkg.getName(),
+ new TreeSet<ExportedPackage>(
+ exportedPackageComparator));
+ Set<ExportedPackage> expPackages = (Set<ExportedPackage>) packages
+ .get(pkg.getName());
+ expPackages.add(pkg);
+
+ // imported
+ for (Bundle b : pkg.getImportingBundles()) {
+ if (bundle.getBundleId() != b.getBundleId()) {
+ if (!importedPackages.containsKey(b))
+ importedPackages
+ .put(b,
+ new TreeSet<ExportedPackage>(
+ exportedPackageComparator));
+ Set<ExportedPackage> impPackages = (Set<ExportedPackage>) importedPackages
+ .get(b);
+ impPackages.add(pkg);
+ }
+ }
+ }
+ }
+
+ TreeParent mPackageNode = new TreeParent("Multiple Packages");
+ // TreeParent aPackageNode = new TreeParent("All Packages");
+ for (String packageName : packages.keySet()) {
+ Set<ExportedPackage> pkgs = packages.get(packageName);
+ if (pkgs.size() > 1) {
+ MultiplePackagesNode mpn = new MultiplePackagesNode(
+ packageName, pkgs);
+ mPackageNode.addChild(mpn);
+ // aPackageNode.addChild(mpn);
+ } else {
+ // aPackageNode.addChild(new ExportedPackageNode(pkgs
+ // .iterator().next()));
+ }
+ }
+
+ return new Object[] { bundlesNode, mPackageNode };// ,
+ // aPackageNode
+ // };
+ } else if (parentElement instanceof TreeParent) {
+ return ((TreeParent) parentElement).getChildren();
+ } else {
+ return null;
+ }
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ if (element instanceof TreeParent) {
+ return ((TreeParent) element).hasChildren();
+ }
+ return false;
+ }
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ protected Map<String, ExportedPackage> dependencySpace(Bundle bundle,
+ Map<Bundle, Set<ExportedPackage>> importedPackages,
+ Map<String, Set<String>> traces) {
+ log.debug("Dependency space for " + bundle.getSymbolicName());
+ Map<String, ExportedPackage> space = new TreeMap<String, ExportedPackage>();
+ fillDependencySpace(space, bundle, importedPackages,
+ bundle.getSymbolicName(), traces);
+ return space;
+ }
+
+ /** Recursive */
+ protected void fillDependencySpace(Map<String, ExportedPackage> space,
+ Bundle bundle, Map<Bundle, Set<ExportedPackage>> importedPackages,
+ String currTrace, Map<String, Set<String>> traces) {
+ if (importedPackages.containsKey(bundle)) {
+ Set<ExportedPackage> imports = importedPackages.get(bundle);
+ // log.debug("## Fill dependency space for " + bundle + " : ");
+ for (ExportedPackage pkg : imports) {
+ if (!traces.containsKey(pkg.getName()))
+ traces.put(pkg.getName(), new TreeSet<String>());
+ traces.get(pkg.getName()).add(currTrace);
+ if (!space.containsKey(pkg.getName())) {
+ space.put(pkg.getName(), pkg);
+ Bundle exportingBundle = pkg.getExportingBundle();
+ // if (bundle.getBundleId() !=
+ // exportingBundle.getBundleId())
+ fillDependencySpace(space, exportingBundle,
+ importedPackages, currTrace + " > "
+ + exportingBundle.getSymbolicName(), traces);
+ }
+ }
+ }
+ }
+
+ private class ModulesLabelProvider extends LabelProvider implements
+ ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ return getText(element);
+ }
+
+ }
+
+ class BundleNode extends TreeParent {
+ private final Bundle bundle;
+
+ public BundleNode(Bundle bundle) {
+ super(bundle.getSymbolicName());
+ this.bundle = bundle;
+
+ // Registered services
+ ServiceReference[] registeredServices = bundle
+ .getRegisteredServices();
+ if (registeredServices != null) {
+ TreeParent registeredServicesNode = new TreeParent(
+ "Registered Services");
+ addChild(registeredServicesNode);
+ for (ServiceReference sr : registeredServices) {
+ if (sr != null)
+ registeredServicesNode
+ .addChild(new ServiceReferenceNode(sr));
+ }
+ }
+
+ // Used services
+ ServiceReference[] usedServices = bundle.getRegisteredServices();
+ if (usedServices != null) {
+ TreeParent usedServicesNode = new TreeParent("Used Services");
+ addChild(usedServicesNode);
+ for (ServiceReference sr : usedServices) {
+ if (sr != null)
+ usedServicesNode.addChild(new ServiceReferenceNode(sr));
+ }
+ }
+ }
+
+ public Bundle getBundle() {
+ return bundle;
+ }
+
+ }
+
+ class ServiceReferenceNode extends TreeParent {
+ private final ServiceReference serviceReference;
+
+ public ServiceReferenceNode(ServiceReference serviceReference) {
+ super(serviceReference.toString());
+ this.serviceReference = serviceReference;
+
+ Bundle[] usedBundles = serviceReference.getUsingBundles();
+ if (usedBundles != null) {
+ TreeParent usingBundles = new TreeParent("Using Bundles");
+ addChild(usingBundles);
+ for (Bundle b : usedBundles) {
+ if (b != null)
+ usingBundles.addChild(new TreeParent(b
+ .getSymbolicName()));
+ }
+ }
+
+ TreeParent properties = new TreeParent("Properties");
+ addChild(properties);
+ for (String key : serviceReference.getPropertyKeys()) {
+ properties.addChild(new TreeParent(key + "="
+ + serviceReference.getProperty(key)));
+ }
+
+ }
+
+ public ServiceReference getServiceReference() {
+ return serviceReference;
+ }
+
+ }
+
+ class MultiplePackagesNode extends TreeParent {
+ private String packageName;
+ private Set<ExportedPackage> exportedPackages;
+
+ public MultiplePackagesNode(String packageName,
+ Set<ExportedPackage> exportedPackages) {
+ super(packageName);
+ this.packageName = packageName;
+ this.exportedPackages = exportedPackages;
+ for (ExportedPackage pkg : exportedPackages) {
+ addChild(new ExportedPackageNode(pkg));
+ }
+ }
+
+ }
+
+ class ConflictingPackageNode extends TreeParent {
+ private ExportedPackage exportedPackage;
+
+ public ConflictingPackageNode(ExportedPackage exportedPackage) {
+ super(exportedPackage.getName() + " - "
+ + exportedPackage.getVersion() + " ("
+ + exportedPackage.getExportingBundle() + ")");
+ this.exportedPackage = exportedPackage;
+
+ TreeParent bundlesNode = new TreeParent("Dependent Bundles");
+ this.addChild(bundlesNode);
+ Map<String, Bundle> bundles = new TreeMap<String, Bundle>();
+ for (Bundle b : exportedPackage.getImportingBundles()) {
+ bundles.put(b.getSymbolicName(), b);
+ }
+ for (String key : bundles.keySet()) {
+ addDependentBundles(bundlesNode, bundles.get(key));
+ }
+ }
+ }
+
+ protected void addDependentBundles(TreeParent parent, Bundle bundle) {
+ TreeParent bundleNode = new TreeParent(bundle.toString());
+ parent.addChild(bundleNode);
+ Map<String, Bundle> bundles = new TreeMap<String, Bundle>();
+ ExportedPackage[] pkgs = packageAdmin.getExportedPackages(bundle);
+ if (pkgs != null)
+ for (ExportedPackage pkg : pkgs) {
+ for (Bundle b : pkg.getImportingBundles()) {
+ if (!bundles.containsKey(b.getSymbolicName())
+ && b.getBundleId() != bundle.getBundleId()) {
+ bundles.put(b.getSymbolicName(), b);
+ }
+ }
+ }
+
+ for (String key : bundles.keySet()) {
+ addDependentBundles(bundleNode, bundles.get(key));
+ }
+ }
+
+ class ExportedPackageNode extends TreeParent {
+ private ExportedPackage exportedPackage;
+
+ public ExportedPackageNode(ExportedPackage exportedPackage) {
+ super(exportedPackage.getName() + " - "
+ + exportedPackage.getVersion() + " ("
+ + exportedPackage.getExportingBundle() + ")");
+ this.exportedPackage = exportedPackage;
+ for (Bundle bundle : exportedPackage.getImportingBundles()) {
+ addChild(new BundleNode(bundle));
+ }
+ }
+ }
+}
<packaging>pom</packaging>
<modules>
<module>runtime</module>
+ <module>plugins</module>
<module>dep</module>
</modules>
</project>
\ No newline at end of file
<artifactId>org.argeo.jcr.ui.explorer</artifactId>
<version>0.3.4-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.argeo.commons.osgi</groupId>
+ <artifactId>org.argeo.osgi.ui.explorer</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.argeo.commons.security</groupId>
<artifactId>org.argeo.security.ui.admin</artifactId>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons.security</groupId>
<artifactId>org.argeo.jcr.ui.explorer</artifactId>
<version>0.3.4-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.argeo.commons.osgi</groupId>
+ <artifactId>org.argeo.osgi.ui.explorer</artifactId>
+ <version>0.3.4-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.argeo.commons.security</groupId>
<artifactId>org.argeo.security.ui.admin</artifactId>
<table height="100%">
<tr>
<td style="vertical-align:middle">
- <a style="font-family:sans-serif;color:#0066CC;text-decoration:none;" href="./secureWebUi">Login...</a>
+ <a
+ style="font-family:sans-serif;color:#0066CC;text-decoration:none;"
+ href="javascript:location.reload(true);"
+ title="Click to log in"
+ >Login...</a>
</td>
</tr>
</table>
parameter="secureWebUi">
</entrypoint>
</extension>
- <extension
- id="secureWebapp"
- name="Argeo Secure Web App"
- point="org.eclipse.core.runtime.applications">
- <application cardinality="singleton-global"
- thread="main"
- visible="true">
- <run
- class="org.argeo.security.ui.rap.SecureEntryPoint">
- </run>
- </application>
- </extension>
<extension
point="org.eclipse.rap.ui.branding">
<branding
id="org.argeo.security.ui.rap.branding"
- servletName="secureWebUi"
+ servletName="node"
defaultEntrypointId="org.argeo.security.ui.rap.secureEntryPoint"
- title="Argeo Secure Web UI"
+ title="Argeo Web UI"
favicon="branding/favicon.ico"
body="branding/default.htm">
</branding>
private Integer loginTimeout = 1 * 60;
private Integer sessionTimeout = 15 * 60;
- @SuppressWarnings("unchecked")
@Override
public int createUI() {
// Short login timeout so that the modal dialog login doesn't hang
throw td;
}
- // if (e.getCause() != null) {
- // Throwable firstCause = e.getCause();
- // // log.error("Cause", firstCause);
- // if (firstCause instanceof LoginException
- // && firstCause.getCause() != null) {
- // Throwable secondCause = firstCause.getCause();
- // if (secondCause instanceof BadCredentialsException) {
- // MessageDialog.openInformation(
- // display.getActiveShell(),
- // "Bad Credentials",
- // "Your credentials are incorrect");
- // // retry login
- // continue tryLogin;
- // } else if (secondCause instanceof ThreadDeath) {
- // // rethrow thread death caused by dialog UI timeout
- // throw (ThreadDeath) secondCause;
- // }
- //
- // } else if (firstCause instanceof ThreadDeath) {
- // throw (ThreadDeath) firstCause;
- // }
- // }
-
if (!display.isDisposed()) {
org.argeo.eclipse.ui.Error.show(
"Unexpected exception during authentication", e);
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
+/** Configure Equinox login context from the bundle context. */
public class SecureRapActivator implements BundleActivator {
public final static String ID = "org.argeo.security.ui.rap";
public final static String CONTEXT_SPRING = "SPRING";
private static final String JAAS_CONFIG_FILE = "/META-INF/jaas_default.txt";
- //private static ILoginContext loginContext = null;
-
private static BundleContext bundleContext;
public void start(BundleContext bundleContext) throws Exception {
SecureRapActivator.bundleContext = bundleContext;
-// URL configUrl = bundleContext.getBundle().getEntry(JAAS_CONFIG_FILE);
-// loginContext = LoginContextFactory.createContext(CONTEXT_SPRING,
-// configUrl);
}
public void stop(BundleContext context) throws Exception {
}
-// static ILoginContext getLoginContext() {
-// if (loginContext == null)
-// throw new ArgeoException(
-// "No Equinox login context available, check your configuration");
-// return loginContext;
-// }
-
static ILoginContext createLoginContext() {
URL configUrl = bundleContext.getBundle().getEntry(JAAS_CONFIG_FILE);
return LoginContextFactory.createContext(CONTEXT_SPRING, configUrl);
package org.argeo.security.ui.rap;
+import org.eclipse.ui.IPerspectiveDescriptor;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;
public class SecureWorkbenchAdvisor extends WorkbenchAdvisor {
-
- static final String DEFAULT_PERSPECTIVE_ID = "org.argeo.security.ui.adminSecurityPerspective"; //$NON-NLS-1$
-
+ //static final String DEFAULT_PERSPECTIVE_ID = "org.argeo.security.ui.adminSecurityPerspective"; //$NON-NLS-1$
public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
private String initialPerspective = System.getProperty(
- INITIAL_PERSPECTIVE_PROPERTY, DEFAULT_PERSPECTIVE_ID);
+ INITIAL_PERSPECTIVE_PROPERTY, null);
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
}
public String getInitialWindowPerspectiveId() {
+ if (initialPerspective != null) {
+ // check whether this user can see the declared perspective
+ // (typically the perspective won't be listed if this user doesn't
+ // have the right to see it)
+ IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
+ .getPerspectiveRegistry()
+ .findPerspectiveWithId(initialPerspective);
+ if(pd==null)
+ return null;
+ }
return initialPerspective;
}
}
package org.argeo.security.ui.rap;
import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
configurer.setShowPerspectiveBar(true);
configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
+ }
+ @Override
+ public void postWindowOpen() {
+ String defaultPerspective = getWindowConfigurer()
+ .getWorkbenchConfigurer().getWorkbench()
+ .getPerspectiveRegistry().getDefaultPerspective();
+ if (defaultPerspective == null) {
+ IWorkbenchWindow window = getWindowConfigurer().getWindow();
+ if (window == null)
+ return;
+
+ IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
+ .create(window);
+ openPerspectiveDialogAction.run();
+ }
}
}