From 21a7775f246e442c5fa73f16c8e108d81aa0ffd8 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Sun, 4 Sep 2011 18:23:02 +0000 Subject: [PATCH] Introduce OSGi Explorer Improve RAP git-svn-id: https://svn.argeo.org/commons/trunk@4712 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- demo/argeo_node_web.properties | 7 +- .../org.argeo.eclipse.dep.rap/pom.xml | 4 +- .../eclipse/ui/ColumnViewerComparator.java | 82 ++++ .../org.argeo.osgi.ui.explorer/.classpath | 7 + .../org.argeo.osgi.ui.explorer/.project | 28 ++ .../.settings/org.eclipse.jdt.core.prefs | 8 + .../META-INF/MANIFEST.MF | 13 + .../build.properties | 6 + .../icons/active.gif | Bin 0 -> 193 bytes .../icons/bundles.gif | Bin 0 -> 344 bytes .../icons/installed.gif | Bin 0 -> 183 bytes .../icons/osgi_explorer.gif | Bin 0 -> 359 bytes .../icons/resolved.gif | Bin 0 -> 176 bytes .../icons/starting.gif | Bin 0 -> 181 bytes .../org.argeo.osgi.ui.explorer/plugin.xml | 57 +++ .../org.argeo.osgi.ui.explorer/pom.xml | 8 +- .../osgi/ui/explorer/OsgiExplorerImages.java | 15 + .../ui/explorer/OsgiExplorerPerspective.java | 15 + .../osgi/ui/explorer/OsgiExplorerPlugin.java | 61 +++ .../osgi/ui/explorer/views/BundlesView.java | 187 +++++++++ .../osgi/ui/explorer/views/ModulesView.java | 364 ++++++++++++++++++ osgi/pom.xml | 1 + .../org.argeo.security.dep.node.rap/pom.xml | 5 + .../org.argeo.security.dep.node.rcp/pom.xml | 8 +- .../branding/default.htm | 6 +- .../org.argeo.security.ui.rap/plugin.xml | 16 +- .../security/ui/rap/SecureEntryPoint.java | 24 -- .../security/ui/rap/SecureRapActivator.java | 13 +- .../ui/rap/SecureWorkbenchAdvisor.java | 17 +- .../ui/rap/SecureWorkbenchWindowAdvisor.java | 18 + 30 files changed, 907 insertions(+), 63 deletions(-) create mode 100644 eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/ColumnViewerComparator.java create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/.classpath create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/.project create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/.settings/org.eclipse.jdt.core.prefs create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/META-INF/MANIFEST.MF create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/build.properties create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/icons/active.gif create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/icons/bundles.gif create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/icons/installed.gif create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/icons/osgi_explorer.gif create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/icons/resolved.gif create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/icons/starting.gif create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/plugin.xml create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerImages.java create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPerspective.java create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPlugin.java create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/BundlesView.java create mode 100644 osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/ModulesView.java diff --git a/demo/argeo_node_web.properties b/demo/argeo_node_web.properties index 900e31ef7..e602fa8a0 100644 --- a/demo/argeo_node_web.properties +++ b/demo/argeo_node_web.properties @@ -12,14 +12,11 @@ org.eclipse.equinox.launcher,\ 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 diff --git a/eclipse/features/org.argeo.eclipse.dep.rap/pom.xml b/eclipse/features/org.argeo.eclipse.dep.rap/pom.xml index 9fb76a540..fcd6a56a3 100644 --- a/eclipse/features/org.argeo.eclipse.dep.rap/pom.xml +++ b/eclipse/features/org.argeo.eclipse.dep.rap/pom.xml @@ -94,7 +94,7 @@ org.eclipse.rap.ui - + + org.eclipse.core diff --git a/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/ColumnViewerComparator.java b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/ColumnViewerComparator.java new file mode 100644 index 000000000..dd7df8d30 --- /dev/null +++ b/eclipse/runtime/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/ui/ColumnViewerComparator.java @@ -0,0 +1,82 @@ +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 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 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); + } +} diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/.classpath b/osgi/plugins/org.argeo.osgi.ui.explorer/.classpath new file mode 100644 index 000000000..92f19d2ff --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/.project b/osgi/plugins/org.argeo.osgi.ui.explorer/.project new file mode 100644 index 000000000..1a4f4d3bd --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/.project @@ -0,0 +1,28 @@ + + + org.argeo.osgi.ui.explorer + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/.settings/org.eclipse.jdt.core.prefs b/osgi/plugins/org.argeo.osgi.ui.explorer/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..9916a2282 --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#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 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/META-INF/MANIFEST.MF b/osgi/plugins/org.argeo.osgi.ui.explorer/META-INF/MANIFEST.MF new file mode 100644 index 000000000..c37dfbcca --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +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 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/build.properties b/osgi/plugins/org.argeo.osgi.ui.explorer/build.properties new file mode 100644 index 000000000..4f799f2d3 --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/build.properties @@ -0,0 +1,6 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = META-INF/,\ + .,\ + icons/,\ + plugin.xml diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/icons/active.gif b/osgi/plugins/org.argeo.osgi.ui.explorer/icons/active.gif new file mode 100644 index 0000000000000000000000000000000000000000..7d24707ee82f54aa9fb10d1d9050013cbf161a7a GIT binary patch literal 193 zcmV;y06zamNk%w1VGsZi0K@VRxXubL!4|)qjO}gg>klxZ?TGXw~#-V zU_Y2&N}FX?r*L1YbYiM-aj|xBv2}#Mgo3?-guaA=wSS1Yfrz+)iMWB7#*ml2h^x<; ztIwFU(w+bR{{R30A^8LW0015UEC2ui01yBW000F(peK%GX`X1Rt}L1aL$Vf5mpMgx vG+WO#2NYmJDM}^)l;8n@L?90V%CN9pFcyU&MPO(u48jTlL$uClRtNw)MiWcq literal 0 HcmV?d00001 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/icons/bundles.gif b/osgi/plugins/org.argeo.osgi.ui.explorer/icons/bundles.gif new file mode 100644 index 0000000000000000000000000000000000000000..e9a6bd966a5392e7755776c0c69d9385e2298f69 GIT binary patch literal 344 zcmZ?wbhEHb6krfwxXQqATF>%kT-v?-@+VE5wmHkVTv{Z9CaA~F67cSj3!gY^$Cc!j z?G@W+s5JN+bVhUKn2QwHM9hwjm>rX~I;&tw`sx;`<&9Fy8>Hryh|MVxn~^IrIYVSd zuIRr@wUg6@|LqU{|NlP&ErH@s7DfgJ1qL0EB_KaBu$4MYDDcqXVm$F=!ovcCwuZ(M z1_2`}5wFLbOdR`~v{o2udP^N|uu`aVxi|5+pp2NF+|A>UX1MT)3sku^x3o5Mak+_# zy0Njjip$E1xo~lCbUI1O&ykmK=3r;%aGpJPz5*8~3k&B=1(``w&a7LvxyVVkwK_6b F0|3)}RLKAU literal 0 HcmV?d00001 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/icons/installed.gif b/osgi/plugins/org.argeo.osgi.ui.explorer/icons/installed.gif new file mode 100644 index 0000000000000000000000000000000000000000..298871653f056a8123af853bd587a3a394a208f0 GIT binary patch literal 183 zcmZ?wbhEHb6krfwIKsg2JR$LfrojmVlM|YTCuDU#`Nn+ojrm&Ea6(e+`Q+}C&Ne6A z?M~WReVf$xJR#w0P0icp=KufyGY}0Ff3h$#FbFc}fOLTDWMDN(Q0Ys_oR_g`UCwH~ wf;~&Tl5cyRGV#A}pn33MfPoClO2#9M3=T}1PDxg(O9XD{96I`To)d#L0F!by`Tzg` literal 0 HcmV?d00001 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/icons/osgi_explorer.gif b/osgi/plugins/org.argeo.osgi.ui.explorer/icons/osgi_explorer.gif new file mode 100644 index 0000000000000000000000000000000000000000..27bf10eb03b4b84fd0bb3734eda583961ef45bec GIT binary patch literal 359 zcmZ?wbhEHb6krfwxXQrr?d9&z4>x^%y!FGqP48~6e{*x)!5J=}ZmoKAeciLmYd*ZV z@#DjTAD^DRxw!PrrDbm}uXu50;q%iA-dtGv{Pe=7rx!msJm=xjd5@1TcyMIiy~FeG z9-8<0^@F3$MtAnly0Lr4=U4X+R_X37*SWG~;`QxQZtj|Xedn}Yg<6+4^)WS(c=6!HgB#1@lqZMEuS!(ekfwfWS^J_$r9vC=0yFV>1re404hL2&`2YVu12&-e zlZBCi!Gb{tBnk2p16zy3oB|IWsqW3nf=5_(&RU?%@j&A$2cyrGj0y+0t({ARtj?Lq zU-NZzn%QxH~df0|0c* BrpN#Q literal 0 HcmV?d00001 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/icons/resolved.gif b/osgi/plugins/org.argeo.osgi.ui.explorer/icons/resolved.gif new file mode 100644 index 0000000000000000000000000000000000000000..f4a1ea1507068ad913d6151b496e2b303bec9dfe GIT binary patch literal 176 zcmZ?wbhEHb6krfwIKsdX(zwmBe0@;cuHd#^aw&_I)0bG5Z?LS`AP_T0C~mH3{5-LQ z`I5;CWKtH%q%M+4StygbP%d?`QpQrX?B(h?%m4rX&wv*w{$ycfU=U@{0jUDn$-t_c zpxT#`IWJ??x}4KN!O#5FDL$gHF5i7)qQg`cF$1XJyZSvvl;8!CMAi|&nQV6n>fz?Ps zwJ#-eUdF0*IbH&~j0_v1I4TmBoId!c=P<+44xhfs9!jheEmS+E9{!nODz$daHc=)9 FYXDFdK#l+a literal 0 HcmV?d00001 diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/plugin.xml b/osgi/plugins/org.argeo.osgi.ui.explorer/plugin.xml new file mode 100644 index 000000000..825d43be8 --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/plugin.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/pom.xml b/osgi/plugins/org.argeo.osgi.ui.explorer/pom.xml index c955ad9f9..9571ff057 100644 --- a/osgi/plugins/org.argeo.osgi.ui.explorer/pom.xml +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.argeo.commons.osgi @@ -9,6 +10,11 @@ org.argeo.osgi.ui.explorer Commons OSGi Explorer + + org.argeo.commons.eclipse + org.argeo.eclipse.ui + 0.3.4-SNAPSHOT + diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerImages.java b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerImages.java new file mode 100644 index 000000000..3e16a764d --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerImages.java @@ -0,0 +1,15 @@ +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(); +} diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPerspective.java b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPerspective.java new file mode 100644 index 000000000..2665929cc --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPerspective.java @@ -0,0 +1,15 @@ +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); + + } + +} diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPlugin.java b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPlugin.java new file mode 100644 index 000000000..42c343329 --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/OsgiExplorerPlugin.java @@ -0,0 +1,61 @@ +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); + } + +} diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/BundlesView.java b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/BundlesView.java new file mode 100644 index 000000000..166941180 --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/BundlesView.java @@ -0,0 +1,187 @@ +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(column, new Comparator() { + 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(column, new Comparator() { + 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(column, new Comparator() { + 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(column, new Comparator() { + 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 "<>"; + return "STARTING"; + case Bundle.STOPPING: + return "STOPPING"; + case Bundle.ACTIVE: + return "ACTIVE"; + default: + return null; + } + } + + } +} diff --git a/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/ModulesView.java b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/ModulesView.java new file mode 100644 index 000000000..1293506c4 --- /dev/null +++ b/osgi/plugins/org.argeo.osgi.ui.explorer/src/main/java/org/argeo/osgi/ui/explorer/views/ModulesView.java @@ -0,0 +1,364 @@ +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; + +/** Experimental 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 exportedPackageComparator = new Comparator() { + + 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> importedPackages = new HashMap>(); + Map> packages = new TreeMap>(); + 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( + exportedPackageComparator)); + Set expPackages = (Set) 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( + exportedPackageComparator)); + Set impPackages = (Set) importedPackages + .get(b); + impPackages.add(pkg); + } + } + } + } + + TreeParent mPackageNode = new TreeParent("Multiple Packages"); + // TreeParent aPackageNode = new TreeParent("All Packages"); + for (String packageName : packages.keySet()) { + Set 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 dependencySpace(Bundle bundle, + Map> importedPackages, + Map> traces) { + log.debug("Dependency space for " + bundle.getSymbolicName()); + Map space = new TreeMap(); + fillDependencySpace(space, bundle, importedPackages, + bundle.getSymbolicName(), traces); + return space; + } + + /** Recursive */ + protected void fillDependencySpace(Map space, + Bundle bundle, Map> importedPackages, + String currTrace, Map> traces) { + if (importedPackages.containsKey(bundle)) { + Set 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()); + 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 exportedPackages; + + public MultiplePackagesNode(String packageName, + Set 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 bundles = new TreeMap(); + 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 bundles = new TreeMap(); + 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)); + } + } + } +} diff --git a/osgi/pom.xml b/osgi/pom.xml index 9873b5587..5fb919ac2 100644 --- a/osgi/pom.xml +++ b/osgi/pom.xml @@ -12,6 +12,7 @@ pom runtime + plugins dep \ No newline at end of file diff --git a/security/features/org.argeo.security.dep.node.rap/pom.xml b/security/features/org.argeo.security.dep.node.rap/pom.xml index 8c167d4ae..af69f1b39 100644 --- a/security/features/org.argeo.security.dep.node.rap/pom.xml +++ b/security/features/org.argeo.security.dep.node.rap/pom.xml @@ -43,6 +43,11 @@ org.argeo.jcr.ui.explorer 0.3.4-SNAPSHOT + + org.argeo.commons.osgi + org.argeo.osgi.ui.explorer + 0.3.4-SNAPSHOT + org.argeo.commons.security org.argeo.security.ui.admin diff --git a/security/features/org.argeo.security.dep.node.rcp/pom.xml b/security/features/org.argeo.security.dep.node.rcp/pom.xml index d786a7f62..8994fe15e 100644 --- a/security/features/org.argeo.security.dep.node.rcp/pom.xml +++ b/security/features/org.argeo.security.dep.node.rcp/pom.xml @@ -1,4 +1,5 @@ - + 4.0.0 org.argeo.commons.security @@ -44,6 +45,11 @@ org.argeo.jcr.ui.explorer 0.3.4-SNAPSHOT + + org.argeo.commons.osgi + org.argeo.osgi.ui.explorer + 0.3.4-SNAPSHOT + org.argeo.commons.security org.argeo.security.ui.admin diff --git a/security/plugins/org.argeo.security.ui.rap/branding/default.htm b/security/plugins/org.argeo.security.ui.rap/branding/default.htm index 67c89f4fe..6de7eb216 100644 --- a/security/plugins/org.argeo.security.ui.rap/branding/default.htm +++ b/security/plugins/org.argeo.security.ui.rap/branding/default.htm @@ -5,7 +5,11 @@
- Login... + Login...
diff --git a/security/plugins/org.argeo.security.ui.rap/plugin.xml b/security/plugins/org.argeo.security.ui.rap/plugin.xml index 7e192647d..9b284c251 100644 --- a/security/plugins/org.argeo.security.ui.rap/plugin.xml +++ b/security/plugins/org.argeo.security.ui.rap/plugin.xml @@ -9,26 +9,14 @@ parameter="secureWebUi"> - - - - - - diff --git a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java index 2ddfe0705..9f54e4c75 100644 --- a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java +++ b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureEntryPoint.java @@ -33,7 +33,6 @@ public class SecureEntryPoint implements IEntryPoint { 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 @@ -73,29 +72,6 @@ public class SecureEntryPoint implements IEntryPoint { 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); diff --git a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureRapActivator.java b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureRapActivator.java index 2a29ba7e0..762b22783 100644 --- a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureRapActivator.java +++ b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureRapActivator.java @@ -7,33 +7,22 @@ import org.eclipse.equinox.security.auth.LoginContextFactory; 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); diff --git a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchAdvisor.java b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchAdvisor.java index 072d7de5e..06a83306d 100644 --- a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchAdvisor.java +++ b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchAdvisor.java @@ -1,16 +1,15 @@ 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) { @@ -18,6 +17,16 @@ public class SecureWorkbenchAdvisor extends WorkbenchAdvisor { } 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; } } diff --git a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchWindowAdvisor.java b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchWindowAdvisor.java index f4c07a84a..c2675d58b 100644 --- a/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchWindowAdvisor.java +++ b/security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchWindowAdvisor.java @@ -1,6 +1,9 @@ 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; @@ -26,7 +29,22 @@ public class SecureWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { 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(); + } } } -- 2.30.2