]> git.argeo.org Git - gpl/argeo-slc.git/blob - legacy/argeo-commons/org.argeo.cms.ui.workbench.rap/src/org/argeo/cms/ui/workbench/rap/RapWorkbenchAdvisor.java
Remove old license headers
[gpl/argeo-slc.git] / legacy / argeo-commons / org.argeo.cms.ui.workbench.rap / src / org / argeo / cms / ui / workbench / rap / RapWorkbenchAdvisor.java
1 package org.argeo.cms.ui.workbench.rap;
2
3 import org.eclipse.ui.IPerspectiveDescriptor;
4 import org.eclipse.ui.application.IWorkbenchConfigurer;
5 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
6 import org.eclipse.ui.application.WorkbenchAdvisor;
7 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
8
9 /** Eclipse RAP specific workbench advisor */
10 public class RapWorkbenchAdvisor extends WorkbenchAdvisor {
11 public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
12 public final static String SAVE_AND_RESTORE_PROPERTY = "org.argeo.security.ui.saveAndRestore";
13
14 private String initialPerspective = System.getProperty(
15 INITIAL_PERSPECTIVE_PROPERTY, null);
16
17 private String username;
18
19 public RapWorkbenchAdvisor(String username) {
20 this.username = username;
21 }
22
23 @Override
24 public void initialize(IWorkbenchConfigurer configurer) {
25 super.initialize(configurer);
26 Boolean saveAndRestore = Boolean.parseBoolean(System.getProperty(
27 SAVE_AND_RESTORE_PROPERTY, "false"));
28 configurer.setSaveAndRestore(saveAndRestore);
29 }
30
31 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
32 IWorkbenchWindowConfigurer configurer) {
33 return new RapWindowAdvisor(configurer, username);
34 }
35
36 public String getInitialWindowPerspectiveId() {
37 if (initialPerspective != null) {
38 // check whether this user can see the declared perspective
39 // (typically the perspective won't be listed if this user doesn't
40 // have the right to see it)
41 IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
42 .getPerspectiveRegistry()
43 .findPerspectiveWithId(initialPerspective);
44 if (pd == null)
45 return null;
46 }
47 return initialPerspective;
48 }
49 }