]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ui/rcp/SecureWorkbenchAdvisor.java
Prepare next development cycle
[lgpl/argeo-commons.git] / ui / rcp / SecureWorkbenchAdvisor.java
1 package org.argeo.security.ui.rcp;
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 private final String username;
14
15 public SecureWorkbenchAdvisor(String username) {
16 this.username = username;
17 }
18
19 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
20 IWorkbenchWindowConfigurer configurer) {
21 return new SecureWorkbenchWindowAdvisor(configurer, username);
22 }
23
24 public String getInitialWindowPerspectiveId() {
25 if (initialPerspective != null) {
26 // check whether this user can see the declared perspective
27 // (typically the perspective won't be listed if this user doesn't
28 // have the right to see it)
29 IPerspectiveDescriptor pd = getWorkbenchConfigurer().getWorkbench()
30 .getPerspectiveRegistry()
31 .findPerspectiveWithId(initialPerspective);
32 if (pd == null)
33 return null;
34 }
35 return initialPerspective;
36 }
37
38 }