]> git.argeo.org Git - lgpl/argeo-commons.git/blob - rap/RapWindowAdvisor.java
Prepare next development cycle
[lgpl/argeo-commons.git] / rap / RapWindowAdvisor.java
1 package org.argeo.security.ui.rap;
2
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.graphics.Point;
5 import org.eclipse.swt.graphics.Rectangle;
6 import org.eclipse.swt.widgets.Display;
7 import org.eclipse.ui.IWorkbenchWindow;
8 import org.eclipse.ui.actions.ActionFactory;
9 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
10 import org.eclipse.ui.application.ActionBarAdvisor;
11 import org.eclipse.ui.application.IActionBarConfigurer;
12 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
13 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
14
15 /** Eclipse RAP specific window advisor */
16 public class RapWindowAdvisor extends WorkbenchWindowAdvisor {
17
18 private String username;
19
20 public RapWindowAdvisor(IWorkbenchWindowConfigurer configurer,
21 String username) {
22 super(configurer);
23 this.username = username;
24 }
25
26 @Override
27 public ActionBarAdvisor createActionBarAdvisor(
28 IActionBarConfigurer configurer) {
29 return new RapActionBarAdvisor(configurer, username);
30 }
31
32 public void preWindowOpen() {
33 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
34 configurer.setShowCoolBar(true);
35 configurer.setShowMenuBar(false);
36 configurer.setShowStatusLine(false);
37 configurer.setShowPerspectiveBar(true);
38 configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
39 // Full screen, see
40 // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
41 configurer.setShellStyle(SWT.NONE);
42 Rectangle bounds = Display.getCurrent().getBounds();
43 configurer.setInitialSize(new Point(bounds.width, bounds.height));
44 }
45
46 @Override
47 public void postWindowOpen() {
48 String defaultPerspective = getWindowConfigurer()
49 .getWorkbenchConfigurer().getWorkbench()
50 .getPerspectiveRegistry().getDefaultPerspective();
51 if (defaultPerspective == null) {
52 IWorkbenchWindow window = getWindowConfigurer().getWindow();
53 if (window == null)
54 return;
55
56 IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
57 .create(window);
58 openPerspectiveDialogAction.run();
59 }
60 }
61
62 }