]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/RapWorkbenchAdvisor.java
b553dceeaacd38ade3fcf26f5262b16894999e79
[lgpl/argeo-commons.git] / security / plugins / org.argeo.security.ui.rap / src / main / java / org / argeo / security / ui / rap / RapWorkbenchAdvisor.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 /** Eclipse RAP specific workbench advisor */
9 public class RapWorkbenchAdvisor extends WorkbenchAdvisor {
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 private String username;
15
16 public RapWorkbenchAdvisor(String username) {
17 this.username = username;
18 }
19
20 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
21 IWorkbenchWindowConfigurer configurer) {
22 return new RapWindowAdvisor(configurer, username);
23 }
24
25 public String getInitialWindowPerspectiveId() {
26 if (initialPerspective != null) {
27 // check whether this user can see the declared perspective
28 // (typically the perspective won't be listed if this user doesn't
29 // have the right to see it)
30 IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
31 .getPerspectiveRegistry()
32 .findPerspectiveWithId(initialPerspective);
33 if (pd == null)
34 return null;
35 }
36 return initialPerspective;
37 }
38 }