2 * Copyright (C) 2007-2012 Argeo GmbH
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.security
.ui
.rap
;
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
.swt
.widgets
.Event
;
23 import org
.eclipse
.swt
.widgets
.Listener
;
24 import org
.eclipse
.swt
.widgets
.Shell
;
25 import org
.eclipse
.ui
.IWorkbenchWindow
;
26 import org
.eclipse
.ui
.actions
.ActionFactory
;
27 import org
.eclipse
.ui
.actions
.ActionFactory
.IWorkbenchAction
;
28 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
29 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
30 import org
.eclipse
.ui
.application
.IWorkbenchWindowConfigurer
;
31 import org
.eclipse
.ui
.application
.WorkbenchWindowAdvisor
;
32 import org
.eclipse
.ui
.internal
.UIPlugin
;
34 /** Eclipse RAP specific window advisor */
35 public class RapWindowAdvisor
extends WorkbenchWindowAdvisor
{
37 private String username
;
39 public RapWindowAdvisor(IWorkbenchWindowConfigurer configurer
,
42 this.username
= username
;
46 public ActionBarAdvisor
createActionBarAdvisor(
47 IActionBarConfigurer configurer
) {
48 return new RapActionBarAdvisor(configurer
, username
);
51 public void preWindowOpen() {
52 IWorkbenchWindowConfigurer configurer
= getWindowConfigurer();
53 configurer
.setShowCoolBar(true);
54 configurer
.setShowMenuBar(false);
55 configurer
.setShowStatusLine(false);
56 configurer
.setShowPerspectiveBar(true);
57 configurer
.setTitle("Argeo Web UI"); //$NON-NLS-1$
59 // http://wiki.eclipse.org/RAP/FAQ#How_to_create_a_fullscreen_application
60 configurer
.setShellStyle(SWT
.NO_TRIM
);
61 Rectangle bounds
= Display
.getCurrent().getBounds();
62 configurer
.setInitialSize(new Point(bounds
.width
, bounds
.height
));
64 // Handle window resize in Rap 2.1+ see https://bugs.eclipse.org/bugs/show_bug.cgi?id=417254
65 Display
.getCurrent().addListener(SWT
.Resize
, new Listener() {
67 public void handleEvent(Event event
) {
68 Rectangle bounds
= event
.display
.getBounds();
69 IWorkbenchWindow iww
= UIPlugin
.getDefault().getWorkbench()
70 .getActiveWorkbenchWindow();
71 iww
.getShell().setBounds(bounds
);
77 public void postWindowCreate() {
78 Shell shell
= getWindowConfigurer().getWindow().getShell();
79 shell
.setMaximized(true);
83 public void postWindowOpen() {
84 String defaultPerspective
= getWindowConfigurer()
85 .getWorkbenchConfigurer().getWorkbench()
86 .getPerspectiveRegistry().getDefaultPerspective();
87 if (defaultPerspective
== null) {
88 IWorkbenchWindow window
= getWindowConfigurer().getWindow();
92 IWorkbenchAction openPerspectiveDialogAction
= ActionFactory
.OPEN_PERSPECTIVE_DIALOG
94 openPerspectiveDialogAction
.run();