1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.cms.ui.workbench.rap;
17
18 import org.eclipse.ui.IPerspectiveDescriptor;
19 import org.eclipse.ui.application.IWorkbenchConfigurer;
20 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
21 import org.eclipse.ui.application.WorkbenchAdvisor;
22 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
23
24
25 public class RapWorkbenchAdvisor extends WorkbenchAdvisor {
26 public final static String INITIAL_PERSPECTIVE_PROPERTY = "org.argeo.security.ui.initialPerspective";
27 public final static String SAVE_AND_RESTORE_PROPERTY = "org.argeo.security.ui.saveAndRestore";
28
29 private String initialPerspective = System.getProperty(
30 INITIAL_PERSPECTIVE_PROPERTY, null);
31
32 private String username;
33
34 public RapWorkbenchAdvisor(String username) {
35 this.username = username;
36 }
37
38 @Override
39 public void initialize(IWorkbenchConfigurer configurer) {
40 super.initialize(configurer);
41 Boolean saveAndRestore = Boolean.parseBoolean(System.getProperty(
42 SAVE_AND_RESTORE_PROPERTY, "false"));
43 configurer.setSaveAndRestore(saveAndRestore);
44 }
45
46 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
47 IWorkbenchWindowConfigurer configurer) {
48 return new RapWindowAdvisor(configurer, username);
49 }
50
51 public String getInitialWindowPerspectiveId() {
52 if (initialPerspective != null) {
53
54
55
56 IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
57 .getPerspectiveRegistry()
58 .findPerspectiveWithId(initialPerspective);
59 if (pd == null)
60 return null;
61 }
62 return initialPerspective;
63 }
64 }