]> git.argeo.org Git - lgpl/argeo-commons.git/blob - SecureActionBarAdvisor.java
481865bfa7070971291e0c2a42b98dc45023f132
[lgpl/argeo-commons.git] / SecureActionBarAdvisor.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
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.rcp;
17
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;
32
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;
42
43 // private final Boolean isRcp;
44
45 public SecureActionBarAdvisor(IActionBarConfigurer configurer, Boolean isRcp) {
46 super(configurer);
47 // this.isRcp = isRcp;
48 }
49
50 protected void makeActions(IWorkbenchWindow window) {
51 preferences = ActionFactory.PREFERENCES.create(window);
52 register(preferences);
53 openPerspectiveDialogAction = ActionFactory.OPEN_PERSPECTIVE_DIALOG
54 .create(window);
55 register(openPerspectiveDialogAction);
56 showViewMenuAction = ActionFactory.SHOW_VIEW_MENU.create(window);
57 register(showViewMenuAction);
58
59 exitAction = ActionFactory.QUIT.create(window);
60 register(exitAction);
61
62 // Save semantiocs
63 saveAction = ActionFactory.SAVE.create(window);
64 register(saveAction);
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);
71
72 }
73
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);
81
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));
87
88 // File
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);
96
97 // Edit
98 editMenu.add(preferences);
99
100 // Window
101 windowMenu.add(openPerspectiveDialogAction);
102 windowMenu.add(showViewMenuAction);
103 }
104
105 @Override
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);
111 }
112
113 }