]> git.argeo.org Git - lgpl/argeo-commons.git/blob - SecureWorkbenchAdvisor.java
c2d74009974b4ede506764fb0d12ed7bd67b214f
[lgpl/argeo-commons.git] / 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 public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
10 private String initialPerspective = System.getProperty(
11 INITIAL_PERSPECTIVE_PROPERTY, null);
12
13 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
14 IWorkbenchWindowConfigurer configurer) {
15 return new SecureWorkbenchWindowAdvisor(configurer);
16 }
17
18 public String getInitialWindowPerspectiveId() {
19 if (initialPerspective != null) {
20 // check whether this user can see the declared perspective
21 // (typically the perspective won't be listed if this user doesn't
22 // have the right to see it)
23 IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
24 .getPerspectiveRegistry()
25 .findPerspectiveWithId(initialPerspective);
26 if(pd==null)
27 return null;
28 }
29 return initialPerspective;
30 }
31 }