]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/SecureWorkbenchAdvisor.java
Introduce OSGi Explorer
[lgpl/argeo-commons.git] / security / plugins / org.argeo.security.ui.rap / src / main / java / org / argeo / security / ui / rap / SecureWorkbenchAdvisor.java
1 package org.argeo.security.ui.rap;
2
3 import org.eclipse.ui.IPerspectiveDescriptor;
4 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
5 import org.eclipse.ui.application.WorkbenchAdvisor;
6 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
7
8 public class SecureWorkbenchAdvisor extends WorkbenchAdvisor {
9 //static final String DEFAULT_PERSPECTIVE_ID = "org.argeo.security.ui.adminSecurityPerspective"; //$NON-NLS-1$
10 public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
11 private String initialPerspective = System.getProperty(
12 INITIAL_PERSPECTIVE_PROPERTY, null);
13
14 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
15 IWorkbenchWindowConfigurer configurer) {
16 return new SecureWorkbenchWindowAdvisor(configurer);
17 }
18
19 public String getInitialWindowPerspectiveId() {
20 if (initialPerspective != null) {
21 // check whether this user can see the declared perspective
22 // (typically the perspective won't be listed if this user doesn't
23 // have the right to see it)
24 IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
25 .getPerspectiveRegistry()
26 .findPerspectiveWithId(initialPerspective);
27 if(pd==null)
28 return null;
29 }
30 return initialPerspective;
31 }
32 }