]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/plugins/org.argeo.security.ui.rap/src/main/java/org/argeo/security/ui/rap/RapWindowAdvisor.java
Fix bug 113 : save semantics were not registered since RAP UI refactoring in march...
[lgpl/argeo-commons.git] / security / plugins / org.argeo.security.ui.rap / src / main / java / org / argeo / security / ui / rap / RapWindowAdvisor.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.security.ui.rap;
17
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.graphics.Point;
20 import org.eclipse.swt.graphics.Rectangle;
21 import org.eclipse.swt.widgets.Display;
22 import org.eclipse.ui.IWorkbenchWindow;
23 import org.eclipse.ui.actions.ActionFactory;
24 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
25 import org.eclipse.ui.application.ActionBarAdvisor;
26 import org.eclipse.ui.application.IActionBarConfigurer;
27 import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
28 import org.eclipse.ui.application.WorkbenchWindowAdvisor;
29
30 /** Eclipse RAP specific window advisor */
31 public class RapWindowAdvisor extends WorkbenchWindowAdvisor {
32
33 private String username;
34
35 public RapWindowAdvisor(IWorkbenchWindowConfigurer configurer,
36 String username) {
37 super(configurer);
38 this.username = username;
39 }
40
41 @Override
42 public ActionBarAdvisor createActionBarAdvisor(
43 IActionBarConfigurer configurer) {
44 return new RapActionBarAdvisor(configurer, username);
45 }
46
47 public void preWindowOpen() {
48 IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
49 configurer.setShowCoolBar(true);
50 configurer.setShowMenuBar(false);
51 configurer.setShowStatusLine(false);
52 configurer.setShowPerspectiveBar(true);
53 configurer.setTitle("Argeo Secure UI"); //$NON-NLS-1$
54 // Full screen, see
55 // http://dev.eclipse.org/newslists/news.eclipse.technology.rap/msg02697.html
56 configurer.setShellStyle(SWT.NONE);
57 Rectangle bounds = Display.getCurrent().getBounds();
58 configurer.setInitialSize(new Point(bounds.width, bounds.height));
59 }
60
61 @Override
62 public void postWindowOpen() {
63 String defaultPerspective = getWindowConfigurer()
64 .getWorkbenchConfigurer().getWorkbench()
65 .getPerspectiveRegistry().getDefaultPerspective();
66 if (defaultPerspective == null) {
67 IWorkbenchWindow window = getWindowConfigurer().getWindow();
68 if (window == null)
69 return;
70
71 IWorkbenchAction openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
72 .create(window);
73 openPerspectiveDialogAction.run();
74 }
75 }
76
77 }