2 * Copyright (C) 2007-2012 Mathieu Baudier
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
.rcp
;
18 import org
.eclipse
.jface
.action
.GroupMarker
;
19 import org
.eclipse
.jface
.action
.ICoolBarManager
;
20 import org
.eclipse
.jface
.action
.IMenuManager
;
21 import org
.eclipse
.jface
.action
.IToolBarManager
;
22 import org
.eclipse
.jface
.action
.MenuManager
;
23 import org
.eclipse
.jface
.action
.Separator
;
24 import org
.eclipse
.jface
.action
.ToolBarManager
;
25 import org
.eclipse
.swt
.SWT
;
26 import org
.eclipse
.ui
.IWorkbenchActionConstants
;
27 import org
.eclipse
.ui
.IWorkbenchWindow
;
28 import org
.eclipse
.ui
.actions
.ActionFactory
;
29 import org
.eclipse
.ui
.actions
.ActionFactory
.IWorkbenchAction
;
30 import org
.eclipse
.ui
.application
.ActionBarAdvisor
;
31 import org
.eclipse
.ui
.application
.IActionBarConfigurer
;
33 public class SecureActionBarAdvisor
extends ActionBarAdvisor
{
34 private IWorkbenchAction exitAction
;
35 private IWorkbenchAction openPerspectiveDialogAction
;
36 private IWorkbenchAction showViewMenuAction
;
37 private IWorkbenchAction preferences
;
38 private IWorkbenchAction saveAction
;
39 private IWorkbenchAction saveAsAction
;
40 private IWorkbenchAction saveAllAction
;
41 private IWorkbenchAction closeAllAction
;
43 // private final Boolean isRcp;
45 public SecureActionBarAdvisor(IActionBarConfigurer configurer
, Boolean isRcp
) {
47 // this.isRcp = isRcp;
50 protected void makeActions(IWorkbenchWindow window
) {
51 preferences
= ActionFactory
.PREFERENCES
.create(window
);
52 register(preferences
);
53 openPerspectiveDialogAction
= ActionFactory
.OPEN_PERSPECTIVE_DIALOG
55 register(openPerspectiveDialogAction
);
56 showViewMenuAction
= ActionFactory
.SHOW_VIEW_MENU
.create(window
);
57 register(showViewMenuAction
);
59 exitAction
= ActionFactory
.QUIT
.create(window
);
63 saveAction
= ActionFactory
.SAVE
.create(window
);
65 saveAsAction
= ActionFactory
.SAVE_AS
.create(window
);
66 register(saveAsAction
);
67 saveAllAction
= ActionFactory
.SAVE_ALL
.create(window
);
68 register(saveAllAction
);
69 closeAllAction
= ActionFactory
.CLOSE_ALL
.create(window
);
70 register(closeAllAction
);
74 protected void fillMenuBar(IMenuManager menuBar
) {
75 MenuManager fileMenu
= new MenuManager("&File",
76 IWorkbenchActionConstants
.M_FILE
);
77 MenuManager editMenu
= new MenuManager("&Edit",
78 IWorkbenchActionConstants
.M_EDIT
);
79 MenuManager windowMenu
= new MenuManager("&Window",
80 IWorkbenchActionConstants
.M_WINDOW
);
82 menuBar
.add(fileMenu
);
83 menuBar
.add(editMenu
);
84 menuBar
.add(windowMenu
);
85 // Add a group marker indicating where action set menus will appear.
86 menuBar
.add(new GroupMarker(IWorkbenchActionConstants
.MB_ADDITIONS
));
89 fileMenu
.add(saveAction
);
90 fileMenu
.add(saveAsAction
);
91 fileMenu
.add(saveAllAction
);
92 fileMenu
.add(closeAllAction
);
93 fileMenu
.add(new GroupMarker(IWorkbenchActionConstants
.MB_ADDITIONS
));
94 fileMenu
.add(new Separator());
95 fileMenu
.add(exitAction
);
98 editMenu
.add(preferences
);
101 windowMenu
.add(openPerspectiveDialogAction
);
102 windowMenu
.add(showViewMenuAction
);
106 protected void fillCoolBar(ICoolBarManager coolBar
) {
107 IToolBarManager saveToolbar
= new ToolBarManager(SWT
.FLAT
| SWT
.RIGHT
);
108 saveToolbar
.add(saveAction
);
109 saveToolbar
.add(saveAllAction
);
110 coolBar
.add(saveToolbar
);