]> git.argeo.org Git - gpl/argeo-slc.git/blob - org.argeo.slc.client.rap/src/org/argeo/slc/client/rap/SlcSecureRap.java
Add doAs in RCP CmsView.
[gpl/argeo-slc.git] / org.argeo.slc.client.rap / src / org / argeo / slc / client / rap / SlcSecureRap.java
1 package org.argeo.slc.client.rap;
2
3 import org.argeo.cms.ui.workbench.rap.RapWindowAdvisor;
4 import org.argeo.cms.ui.workbench.rap.RapWorkbenchAdvisor;
5 import org.argeo.cms.ui.workbench.rap.RapWorkbenchLogin;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.graphics.Point;
8 import org.eclipse.swt.graphics.Rectangle;
9 import org.eclipse.swt.widgets.Display;
10 import org.eclipse.swt.widgets.Shell;
11 import org.eclipse.ui.IWorkbenchWindow;
12 import org.eclipse.ui.actions.ActionFactory;
13 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
14 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
15 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
16
17 /**
18 * This class controls all aspects of the application's execution and is
19 * contributed through the plugin.xml.
20 */
21 public class SlcSecureRap extends RapWorkbenchLogin {
22
23 @Override
24 protected RapWorkbenchAdvisor createRapWorkbenchAdvisor(
25 final String username) {
26 return new RapWorkbenchAdvisor(username) {
27 @Override
28 public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
29 IWorkbenchWindowConfigurer configurer) {
30 return new SlcRapWorkbenchWindowAdvisor(configurer, username);
31 }
32
33 };
34 }
35
36 /** Workaround for resize issue */
37 class SlcRapWorkbenchWindowAdvisor extends RapWindowAdvisor {
38
39 public SlcRapWorkbenchWindowAdvisor(
40 IWorkbenchWindowConfigurer configurer, String username) {
41 super(configurer, username);
42 }
43
44 public void preWindowOpen() {
45 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
46 configurer.setShowCoolBar(true);
47 configurer.setShowMenuBar(false);
48 configurer.setShowStatusLine(false);
49 configurer.setShowPerspectiveBar(true);
50 configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
51 // Full screen, see
52 // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
53 configurer.setShellStyle(SWT.NO_TRIM);
54 Rectangle bounds = Display.getCurrent().getBounds();
55 configurer.setInitialSize(new Point(bounds.width, bounds.height));
56 }
57
58 @Override
59 public void postWindowCreate() {
60 Shell shell = getWindowConfigurer().getWindow().getShell();
61 shell.setMaximized(true);
62 }
63
64 @Override
65 public void postWindowOpen() {
66 String defaultPerspective = getWindowConfigurer()
67 .getWorkbenchConfigurer().getWorkbench()
68 .getPerspectiveRegistry().getDefaultPerspective();
69 if (defaultPerspective == null) {
70 IWorkbenchWindow window = getWindowConfigurer().getWindow();
71 if (window == null)
72 return;
73
74 IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
75 .create(window);
76 openPerspectiveDialogAction.run();
77 }
78 }
79
80 }
81 }