- 1.7.6 초기 코드
[Tadpole.git] / com.hangum.tadpole.applicaion.start / src / com / hangum / tadpole / application / start / ApplicationActionBarAdvisor.java
blobe76f501bac3b57599262cf4cc129b3c2682e73c9
1 /*******************************************************************************
2 * Copyright (c) 2013 hangum.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the GNU Lesser Public License v2.1
5 * which accompanies this distribution, and is available at
6 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7 *
8 * Contributors:
9 * hangum - initial API and implementation
10 ******************************************************************************/
11 package com.hangum.tadpole.application.start;
13 import org.eclipse.jface.action.GroupMarker;
14 import org.eclipse.jface.action.IAction;
15 import org.eclipse.jface.action.ICoolBarManager;
16 import org.eclipse.jface.action.IMenuManager;
17 import org.eclipse.jface.action.IToolBarManager;
18 import org.eclipse.jface.action.MenuManager;
19 import org.eclipse.jface.action.Separator;
20 import org.eclipse.jface.action.ToolBarContributionItem;
21 import org.eclipse.jface.action.ToolBarManager;
22 import org.eclipse.swt.SWT;
23 import org.eclipse.ui.IWorkbenchActionConstants;
24 import org.eclipse.ui.IWorkbenchWindow;
25 import org.eclipse.ui.actions.ActionFactory;
26 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
27 import org.eclipse.ui.application.ActionBarAdvisor;
28 import org.eclipse.ui.application.IActionBarConfigurer;
30 import com.hangum.tadpole.application.start.action.AboutAction;
31 import com.hangum.tadpole.application.start.action.BugIssueAction;
32 import com.hangum.tadpole.application.start.action.NewVersionCheckAction;
33 import com.hangum.tadpole.application.start.action.UserManuelAction;
34 import com.hangum.tadpole.commons.admin.core.actions.AdminSystemSettingAction;
35 import com.hangum.tadpole.commons.admin.core.actions.AdminUserAction;
36 import com.hangum.tadpole.commons.admin.core.actions.JDBCDriverManagerAction;
37 import com.hangum.tadpole.commons.admin.core.actions.SendMessageAction;
38 import com.hangum.tadpole.commons.libs.core.define.PublicTadpoleDefine;
39 import com.hangum.tadpole.engine.permission.PermissionChecker;
40 import com.hangum.tadpole.manager.core.actions.global.AdminTransactionConnectionManagerAction;
41 import com.hangum.tadpole.manager.core.actions.global.DBManagerAction;
42 import com.hangum.tadpole.manager.core.actions.global.ResourceManagerAction;
43 import com.hangum.tadpole.manager.core.actions.global.RestfulAPIManagerAction;
44 import com.hangum.tadpole.manager.core.actions.global.SQLAuditAction;
45 import com.hangum.tadpole.manager.core.actions.global.SchemaHistoryAction;
46 import com.hangum.tadpole.manager.core.actions.global.TransactionConnectionManagerAction;
47 import com.hangum.tadpole.monitoring.core.actions.monitoring.MonitoringRealTimeAction;
48 import com.hangum.tadpole.preference.define.GetAdminPreference;
49 import com.hangum.tadpole.rdb.core.actions.global.ConnectDatabaseAction;
50 import com.hangum.tadpole.rdb.core.actions.global.DeleteResourceAction;
51 import com.hangum.tadpole.rdb.core.actions.global.ExitAction;
52 import com.hangum.tadpole.rdb.core.actions.global.OpenDBRelationAction;
53 import com.hangum.tadpole.rdb.core.actions.global.OpenObjectQueryEditorAction;
54 import com.hangum.tadpole.rdb.core.actions.global.OpenQueryEditorAction;
55 import com.hangum.tadpole.rdb.core.actions.global.PreferenceAction;
56 import com.hangum.tadpole.session.manager.SessionManager;
58 /**
59 * Define at action, toolbar, menu
61 * @author hangum
63 public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
64 private IWorkbenchAction exitAction;
66 private IAction saveAction;
67 private IAction saveAsAction;
69 private IAction connectAction;
70 private IAction queryOpenAction;
71 private IAction openObjectQueryEditorAction;
72 private IAction dbRelationOpenAction;
73 private IAction deleteResourceAction;
75 private IAction restFulAPIAction;
77 /** send message */
78 private IAction adminSendMessageAction;
79 private IAction adminUserAction;
80 // private IAction adminSQLAuditAction;
81 private IAction adminSystemSettingAction;
83 /** User permission action */
84 private IAction dbMgmtAction;
86 /** transaction connection */
87 private IAction transactionConnectionAction;
88 private IAction adminTransactionConnectionManagerAction;
90 /** executed sql */
91 private IAction executedSQLAction;
93 /** schedule action */
94 // private IAction monitoringManageAction;
95 private IAction monitoringRealTimeAction;
97 private IAction jDBCDriverManagerAction;
98 private IAction schemaHistoryAction;
99 // private IAction openCompareAction;
100 private IAction resourceManageAction;
102 private IAction preferenceAction;
103 private IAction aboutAction;
104 private IAction bugIssueAction;
105 private IAction userManuelAction;
106 private IAction newVersionCheckAction;
108 // private IAction billAction;
110 public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
111 super(configurer);
114 protected void makeActions(final IWorkbenchWindow window) {
116 saveAction = ActionFactory.SAVE.create(window);
117 register(saveAction);
119 saveAsAction = ActionFactory.SAVE_AS.create(window);
120 register(saveAsAction);
122 connectAction = new ConnectDatabaseAction(window);
123 register(connectAction);
125 queryOpenAction = new OpenQueryEditorAction(window);
126 register(queryOpenAction);
128 openObjectQueryEditorAction = new OpenObjectQueryEditorAction(window);
129 register(openObjectQueryEditorAction);
131 dbRelationOpenAction = new OpenDBRelationAction(window);
132 register(dbRelationOpenAction);
134 deleteResourceAction = new DeleteResourceAction(window);
135 register(deleteResourceAction);
137 adminSendMessageAction = new SendMessageAction(window);
138 register(adminSendMessageAction);
140 adminUserAction = new AdminUserAction(window);
141 register(adminUserAction);
143 dbMgmtAction = new DBManagerAction(window);
144 register(dbMgmtAction);
146 transactionConnectionAction = new TransactionConnectionManagerAction(window);
147 register(transactionConnectionAction);
149 adminTransactionConnectionManagerAction = new AdminTransactionConnectionManagerAction(window);
150 register(adminTransactionConnectionManagerAction);
152 executedSQLAction = new SQLAuditAction(window);
153 register(executedSQLAction);
155 // monitoringManageAction = new MonitoringManageAction(window);
156 // register(monitoringManageAction);
158 monitoringRealTimeAction = new MonitoringRealTimeAction(window);
159 register(monitoringRealTimeAction);
161 jDBCDriverManagerAction = new JDBCDriverManagerAction(window);
162 register(jDBCDriverManagerAction);
164 // adminSQLAuditAction = new AdminSQLAuditAction(window);
165 // register(adminSQLAuditAction);
167 adminSystemSettingAction = new AdminSystemSettingAction(window);
168 register(adminSystemSettingAction);
170 schemaHistoryAction = new SchemaHistoryAction(window);
171 register(schemaHistoryAction);
173 // openCompareAction = new OpenCompareAction(window);
174 // register(openCompareAction);
176 resourceManageAction = new ResourceManagerAction(window);
177 register(resourceManageAction);
179 restFulAPIAction = new RestfulAPIManagerAction(window);
180 register(restFulAPIAction);
182 exitAction = new ExitAction(window);
183 register(exitAction);
185 preferenceAction = new PreferenceAction(window);
186 register(preferenceAction);
188 aboutAction = new AboutAction(window);
189 register(aboutAction);
191 bugIssueAction = new BugIssueAction(window);
192 register(bugIssueAction);
194 userManuelAction = new UserManuelAction(window);
195 register(userManuelAction);
197 newVersionCheckAction = new NewVersionCheckAction(window);
198 register(newVersionCheckAction);
200 // billAction = new BillAction(window);
201 // register(billAction);
205 * Comment at 2.1 RC3 has error(https://bugs.eclipse.org/bugs/show_bug.cgi?id=410260)
207 protected void fillMenuBar(IMenuManager menuBar) {
208 MenuManager fileMenu = new MenuManager(Messages.get().ApplicationActionBarAdvisor_0, IWorkbenchActionConstants.M_FILE);
209 MenuManager manageMenu = new MenuManager(Messages.get().ApplicationActionBarAdvisor_1, IWorkbenchActionConstants.M_PROJECT);
210 MenuManager adminMenu = null;
211 MenuManager observerMenu = null;
212 // MenuManager serviceMenu = null;
214 boolean isAdmin = PermissionChecker.isUserAdmin(SessionManager.getRepresentRole());
215 boolean isObserver = PermissionChecker.isUserObserver(SessionManager.getRepresentRole());
216 if(isAdmin) {
217 adminMenu = new MenuManager(Messages.get().ApplicationActionBarAdvisor_2, IWorkbenchActionConstants.MENU_PREFIX + Messages.get().ApplicationActionBarAdvisor_3);
218 } else if(isObserver) {
219 observerMenu = new MenuManager(Messages.get().ApplicationActionBarAdvisor_Observer, IWorkbenchActionConstants.MENU_PREFIX + Messages.get().ApplicationActionBarAdvisor_Observer);
222 MenuManager preferenceMenu = new MenuManager(Messages.get().ApplicationActionBarAdvisor_4, IWorkbenchActionConstants.M_PROJECT_CONFIGURE);
223 MenuManager helpMenu = new MenuManager(Messages.get().ApplicationActionBarAdvisor_5, IWorkbenchActionConstants.M_HELP);
225 menuBar.add(fileMenu);
226 menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
227 menuBar.add(manageMenu);
228 menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
229 if(isAdmin) {
230 menuBar.add(adminMenu);
231 menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
232 } else if(isObserver) {
233 menuBar.add(observerMenu);
234 menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
237 // if(ApplicationArgumentUtils.isOnlineServer()) {
238 // serviceMenu = new MenuManager(Messages.get().ServiceBill, IWorkbenchActionConstants.M_PROJECT_CONFIGURE);
239 // menuBar.add(serviceMenu);
240 // serviceMenu.add(billAction);
241 // }
242 menuBar.add(preferenceMenu);
243 menuBar.add(helpMenu);
245 // File
246 fileMenu.add(connectAction);
247 fileMenu.add(saveAction);
248 fileMenu.add(saveAsAction);
249 fileMenu.add(new Separator());
250 fileMenu.add(deleteResourceAction);
251 // if(!TadpoleApplicationContextManager.isPersonOperationType()) {
252 fileMenu.add(new Separator());
253 fileMenu.add(exitAction);
254 // }
256 // Manage menu
257 manageMenu.add(restFulAPIAction);
259 // 일반 유저는 모두 표시해 준다.
260 if(!PublicTadpoleDefine.USER_ROLE_TYPE.API_USER.name().equals(SessionManager.getRepresentRole())) {
261 manageMenu.add(transactionConnectionAction);
262 manageMenu.add(resourceManageAction);
263 manageMenu.add(dbMgmtAction);
265 manageMenu.add(executedSQLAction);
266 manageMenu.add(schemaHistoryAction);
268 // manageMenu.add(openCompareAction);
270 if(isAdmin) {
271 adminMenu.add(adminSendMessageAction);
272 adminMenu.add(new Separator());
273 adminMenu.add(adminSystemSettingAction);
274 adminMenu.add(new Separator());
275 adminMenu.add(adminUserAction);
276 // adminMenu.add(adminSQLAuditAction);
277 adminMenu.add(adminTransactionConnectionManagerAction);
278 adminMenu.add(new Separator());
279 adminMenu.add(jDBCDriverManagerAction);
280 } else if(isObserver) {
281 observerMenu.add(adminUserAction);
284 // preference action
285 preferenceMenu.add(preferenceAction);
287 // Help
288 helpMenu.add(userManuelAction);
289 helpMenu.add(bugIssueAction);
290 helpMenu.add(newVersionCheckAction);
291 helpMenu.add(aboutAction);
294 protected void fillCoolBar(ICoolBarManager coolBar) {
295 IToolBarManager toolbar = new ToolBarManager(SWT.FLAT | SWT.RIGHT);
296 coolBar.add(new ToolBarContributionItem(toolbar, "main")); //$NON-NLS-1$
298 toolbar.add(connectAction);
299 toolbar.add(new Separator());
301 toolbar.add(saveAction);
302 toolbar.add(saveAsAction);
303 toolbar.add(new Separator());
305 toolbar.add(queryOpenAction);
306 toolbar.add(openObjectQueryEditorAction);
307 toolbar.add(new Separator());
308 toolbar.add(dbRelationOpenAction);
309 toolbar.add(new Separator());
311 // toolbar.add(monitoringManageAction);
312 if("YES".equals(GetAdminPreference.getSupportMonitoring())) {
313 toolbar.add(monitoringRealTimeAction);
315 // toolbar.add(deleteResourceAction);
316 // toolbar.add(new Separator());
318 // if(PermissionChecker.isAdmin(SessionManager.getRepresentRole())) {
319 // toolbar.add(sendMessageAction);
320 // toolbar.add(new Separator());
321 // toolbar.add(userLoginHistoryAction);
322 // toolbar.add(new Separator());
323 // }
325 // toolbar.add(restFulAPIAction);
326 // toolbar.add(new Separator());
328 // toolbar.add(transactionConnectionAction);
329 // toolbar.add(new Separator());
331 // toolbar.add(resourceManageAction);
332 // toolbar.add(new Separator());
334 // toolbar.add(userPermissionAction);
335 // toolbar.add(new Separator());
337 // toolbar.add(executedSQLAction);
338 // toolbar.add(new Separator());
340 // toolbar.add(schemaHistoryAction);
341 // toolbar.add(new Separator());
343 // toolbar.add(preferenceAction);
344 // toolbar.add(new Separator());
346 // toolbar.add(bugIssueAction);
347 // toolbar.add(aboutAction);
348 // if(!TadpoleApplicationContextManager.isPersonOperationType()) {
349 // toolbar.add(new Separator());
350 toolbar.add(exitAction);
351 // }