1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.slc.client.rap;
17
18 import org.argeo.cms.ui.workbench.rap.RapWindowAdvisor;
19 import org.argeo.cms.ui.workbench.rap.RapWorkbenchAdvisor;
20 import org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.graphics.Point;
23 import org.eclipse.swt.graphics.Rectangle;
24 import org.eclipse.swt.widgets.Display;
25 import org.eclipse.swt.widgets.Shell;
26 import org.eclipse.ui.IWorkbenchWindow;
27 import org.eclipse.ui.actions.ActionFactory;
28 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
29 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
30 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
31
32
33
34
35
36 public class SlcSecureRap extends RapWorkbenchLogin {
37
38 @Override
39 protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(
40 final String username) {
41 return new RapWorkbenchAdvisor(username) {
42 @Override
43 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
44 IWorkbenchWindowConfigurer configurer) {
45 return new SlcRapWorkbenchWindowAdvisor(configurer, username);
46 }
47
48 };
49 }
50
51
52 class SlcRapWorkbenchWindowAdvisor extends RapWindowAdvisor {
53
54 public SlcRapWorkbenchWindowAdvisor(
55 IWorkbenchWindowConfigurer configurer, String username) {
56 super(configurer, username);
57 }
58
59 public void preWindowOpen() {
60 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
61 configurer.setShowCoolBar(true);
62 configurer.setShowMenuBar(false);
63 configurer.setShowStatusLine(false);
64 configurer.setShowPerspectiveBar(true);
65 configurer.setTitle("Argeo Secure UI");
66
67
68 configurer.setShellStyle(SWT.NO_TRIM);
69 Rectangle bounds = Display.getCurrent().getBounds();
70 configurer.setInitialSize(new Point(bounds.width, bounds.height));
71 }
72
73 @Override
74 public void postWindowCreate() {
75 Shell shell = getWindowConfigurer().getWindow().getShell();
76 shell.setMaximized(true);
77 }
78
79 @Override
80 public void postWindowOpen() {
81 String defaultPerspective = getWindowConfigurer()
82 .getWorkbenchConfigurer().getWorkbench()
83 .getPerspectiveRegistry().getDefaultPerspective();
84 if (defaultPerspective == null) {
85 IWorkbenchWindow window = getWindowConfigurer().getWindow();
86 if (window == null)
87 return;
88
89 IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
90 .create(window);
91 openPerspectiveDialogAction.run();
92 }
93 }
94
95 }
96 }