1 20 21 package org.apache.directory.ldapstudio; 22 23 24 import org.apache.directory.ldapstudio.actions.ManageConfigurationAction; 25 import org.apache.directory.ldapstudio.actions.OpenFileAction; 26 import org.apache.directory.ldapstudio.actions.ReportABugAction; 27 import org.apache.directory.ldapstudio.actions.UpdateAction; 28 import org.apache.directory.ldapstudio.view.ImageKeys; 29 import org.eclipse.jface.action.GroupMarker; 30 import org.eclipse.jface.action.IContributionItem; 31 import org.eclipse.jface.action.ICoolBarManager; 32 import org.eclipse.jface.action.IMenuManager; 33 import org.eclipse.jface.action.IToolBarManager; 34 import org.eclipse.jface.action.MenuManager; 35 import org.eclipse.jface.action.Separator; 36 import org.eclipse.jface.action.ToolBarContributionItem; 37 import org.eclipse.jface.action.ToolBarManager; 38 import org.eclipse.swt.SWT; 39 import org.eclipse.ui.IWorkbenchActionConstants; 40 import org.eclipse.ui.IWorkbenchWindow; 41 import org.eclipse.ui.actions.ActionFactory; 42 import org.eclipse.ui.actions.ContributionItemFactory; 43 import org.eclipse.ui.actions.NewWizardDropDownAction; 44 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; 45 import org.eclipse.ui.application.ActionBarAdvisor; 46 import org.eclipse.ui.application.IActionBarConfigurer; 47 import org.eclipse.ui.plugin.AbstractUIPlugin; 48 49 50 58 public class ApplicationActionBarAdvisor extends ActionBarAdvisor 59 { 60 private OpenFileAction openFileAction; 61 private IWorkbenchAction closeAction; 62 private IWorkbenchAction closeAllAction; 63 private IWorkbenchAction saveAction; 64 private IWorkbenchAction saveAsAction; 65 private IWorkbenchAction saveAllAction; 66 private IWorkbenchAction printAction; 67 private IWorkbenchAction refreshAction; 68 private IWorkbenchAction renameAction; 69 private IWorkbenchAction moveAction; 70 private IWorkbenchAction exitAction; 71 private IWorkbenchAction aboutAction; 72 private IWorkbenchAction preferencesAction; 73 private IWorkbenchAction helpAction; 74 private IWorkbenchAction dynamicHelpAction; 75 private UpdateAction updateAction; 76 private ManageConfigurationAction manageConfigurationAction; 77 private IWorkbenchAction newAction; 78 private IWorkbenchAction newDropDownAction; 79 private IWorkbenchAction importAction; 80 private IWorkbenchAction exportAction; 81 private IWorkbenchAction propertiesAction; 82 private IWorkbenchAction closePerspectiveAction; 83 private IWorkbenchAction closeAllPerspectivesAction; 84 private IWorkbenchAction undoAction; 85 private IWorkbenchAction redoAction; 86 private IWorkbenchAction cutAction; 87 private IWorkbenchAction copyAction; 88 private IWorkbenchAction pasteAction; 89 private IWorkbenchAction deleteAction; 90 private IWorkbenchAction selectAllAction; 91 private IWorkbenchAction findAction; 92 private IContributionItem perspectivesList; 93 private IContributionItem viewsList; 94 private IContributionItem reopenEditorsList; 95 private ReportABugAction reportABug; 96 private IWorkbenchAction backwardHistoryAction; 97 private IWorkbenchAction forwardHistoryAction; 98 private IWorkbenchAction nextAction; 99 private IWorkbenchAction previousAction; 100 101 107 public ApplicationActionBarAdvisor( IActionBarConfigurer configurer ) 108 { 109 super( configurer ); 110 } 111 112 113 120 protected void makeActions( final IWorkbenchWindow window ) 121 { 122 128 newAction = ActionFactory.NEW.create( window ); 129 register( newAction ); 130 newAction.setText( "New..." ); 131 132 newDropDownAction = new NewWizardDropDownAction( window ); 133 135 openFileAction = new OpenFileAction( window ); 136 register(openFileAction); 137 138 closeAction = ActionFactory.CLOSE.create( window ); 139 register( closeAction ); 140 141 closeAllAction = ActionFactory.CLOSE_ALL.create( window ); 142 register( closeAllAction ); 143 144 saveAction = ActionFactory.SAVE.create( window ); 145 register( saveAction ); 146 147 saveAsAction = ActionFactory.SAVE_AS.create( window ); 148 register( saveAsAction ); 149 150 saveAllAction = ActionFactory.SAVE_ALL.create( window ); 151 register( saveAllAction ); 152 153 printAction = ActionFactory.PRINT.create( window ); 154 register( printAction ); 155 156 moveAction = ActionFactory.MOVE.create( window ); 157 register( moveAction ); 158 159 renameAction = ActionFactory.RENAME.create( window ); 160 register( renameAction ); 161 162 refreshAction = ActionFactory.REFRESH.create( window ); 163 register( refreshAction ); 164 165 importAction = ActionFactory.IMPORT.create( window ); 166 register( importAction ); 167 168 exportAction = ActionFactory.EXPORT.create( window ); 169 register( exportAction ); 170 171 propertiesAction = ActionFactory.PROPERTIES.create( window ); 172 register( propertiesAction ); 173 174 exitAction = ActionFactory.QUIT.create( window ); 175 register( exitAction ); 176 177 undoAction = ActionFactory.UNDO.create( window ); 178 register( undoAction ); 179 180 redoAction = ActionFactory.REDO.create( window ); 181 register( redoAction ); 182 183 cutAction = ActionFactory.CUT.create( window ); 184 register( cutAction ); 185 186 copyAction = ActionFactory.COPY.create( window ); 187 register( copyAction ); 188 189 pasteAction = ActionFactory.PASTE.create( window ); 190 register( pasteAction ); 191 192 deleteAction = ActionFactory.DELETE.create( window ); 193 register( deleteAction ); 194 195 selectAllAction = ActionFactory.SELECT_ALL.create( window ); 196 register( selectAllAction ); 197 198 findAction = ActionFactory.FIND.create( window ); 199 register( findAction ); 200 201 closePerspectiveAction = ActionFactory.CLOSE_PERSPECTIVE.create( window ); 202 register( closePerspectiveAction ); 203 204 closeAllPerspectivesAction = ActionFactory.CLOSE_ALL_PERSPECTIVES.create( window ); 205 register( closeAllPerspectivesAction ); 206 207 aboutAction = ActionFactory.ABOUT.create( window ); 208 aboutAction.setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID, 209 ImageKeys.ABOUT ) ); 210 register( aboutAction ); 211 212 preferencesAction = ActionFactory.PREFERENCES.create( window ); 213 preferencesAction.setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID, 214 ImageKeys.SHOW_PREFERENCES ) ); 215 register( preferencesAction ); 216 217 updateAction = new UpdateAction( window ); 218 updateAction.setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID, 219 ImageKeys.SEARCH_UPDATES ) ); 220 register( updateAction ); 221 222 manageConfigurationAction = new ManageConfigurationAction( window ); 223 manageConfigurationAction.setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID, 224 ImageKeys.MANAGE_CONFIGURATION ) ); 225 register( manageConfigurationAction ); 226 227 helpAction = ActionFactory.HELP_CONTENTS.create( window ); 228 register( helpAction ); 229 230 dynamicHelpAction = ActionFactory.DYNAMIC_HELP.create( window ); 231 register( dynamicHelpAction ); 232 233 viewsList = ContributionItemFactory.VIEWS_SHORTLIST.create( window ); 234 perspectivesList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create( window ); 235 reopenEditorsList = ContributionItemFactory.REOPEN_EDITORS.create( window ); 236 237 reportABug = new ReportABugAction( window ); 238 reportABug.setImageDescriptor( AbstractUIPlugin.imageDescriptorFromPlugin( Application.PLUGIN_ID, 239 ImageKeys.REPORT_BUG ) ); 240 register( reportABug ); 241 242 forwardHistoryAction = ActionFactory.FORWARD_HISTORY.create( window ); 243 register( forwardHistoryAction ); 244 245 backwardHistoryAction = ActionFactory.BACKWARD_HISTORY.create( window ); 246 register( backwardHistoryAction ); 247 248 nextAction = ActionFactory.NEXT.create( window ); 249 register( nextAction ); 250 251 previousAction = ActionFactory.PREVIOUS.create( window ); 252 register( previousAction ); 253 254 } 255 256 257 260 protected void fillMenuBar( IMenuManager menuBar ) 261 { 262 MenuManager fileMenu = new MenuManager( "&File", IWorkbenchActionConstants.M_FILE ); MenuManager editMenu = new MenuManager( "&Edit", IWorkbenchActionConstants.M_EDIT ); MenuManager navigateMenu = new MenuManager( "&Navigate", IWorkbenchActionConstants.M_NAVIGATE ); MenuManager windowMenu = new MenuManager( "&Window", IWorkbenchActionConstants.M_WINDOW ); MenuManager helpMenu = new MenuManager( "&Help", IWorkbenchActionConstants.M_HELP ); 268 menuBar.add( fileMenu ); 270 menuBar.add( editMenu ); 271 menuBar.add( navigateMenu ); 272 menuBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) ); 274 menuBar.add( windowMenu ); 275 menuBar.add( helpMenu ); 276 277 fileMenu.add( newAction ); 279 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.NEW_EXT ) ); 280 fileMenu.add( openFileAction ); 281 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.OPEN_EXT ) ); 282 fileMenu.add( new Separator() ); 283 fileMenu.add( closeAction ); 284 fileMenu.add( closeAllAction ); 285 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.CLOSE_EXT ) ); 286 fileMenu.add( new Separator() ); 287 fileMenu.add( saveAction ); 288 fileMenu.add( saveAsAction ); 289 fileMenu.add( saveAllAction ); 290 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.SAVE_EXT ) ); 291 fileMenu.add( new Separator() ); 292 fileMenu.add( refreshAction ); 293 fileMenu.add( new Separator() ); 294 fileMenu.add( printAction ); 295 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.PRINT_EXT ) ); 296 fileMenu.add( new Separator() ); 297 fileMenu.add( importAction ); 298 fileMenu.add( exportAction ); 299 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.IMPORT_EXT ) ); 300 fileMenu.add( new Separator() ); 301 fileMenu.add( propertiesAction ); 302 fileMenu.add( reopenEditorsList ); 303 fileMenu.add( new GroupMarker( IWorkbenchActionConstants.MRU ) ); 304 fileMenu.add( new Separator() ); 305 fileMenu.add( exitAction ); 306 307 editMenu.add( undoAction ); 309 editMenu.add( redoAction ); 310 editMenu.add( new Separator() ); 311 editMenu.add( cutAction ); 312 editMenu.add( copyAction ); 313 editMenu.add( pasteAction ); 314 editMenu.add( new Separator() ); 315 editMenu.add( deleteAction ); 316 editMenu.add( selectAllAction ); 317 editMenu.add( new Separator() ); 318 editMenu.add( moveAction ); 319 editMenu.add( renameAction ); 320 editMenu.add( new Separator() ); 321 editMenu.add( findAction ); 322 323 navigateMenu.add( nextAction ); 325 navigateMenu.add( previousAction ); 326 navigateMenu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); 327 navigateMenu.add( new GroupMarker( IWorkbenchActionConstants.NAV_END ) ); 328 navigateMenu.add( new Separator() ); 329 navigateMenu.add( backwardHistoryAction ); 330 navigateMenu.add( forwardHistoryAction ); 331 332 MenuManager perspectiveMenu = new MenuManager("Open Perspective", "openPerspective"); 334 perspectiveMenu.add(perspectivesList); 335 windowMenu.add(perspectiveMenu); 336 MenuManager viewMenu = new MenuManager("Show View"); 337 viewMenu.add(viewsList); 338 windowMenu.add(viewMenu); 339 windowMenu.add( new Separator() ); 340 windowMenu.add( closePerspectiveAction ); 341 windowMenu.add( closeAllPerspectivesAction ); 342 windowMenu.add( new Separator() ); 343 windowMenu.add( preferencesAction ); 344 345 helpMenu.add( helpAction ); 347 helpMenu.add( dynamicHelpAction ); 348 helpMenu.add( reportABug ); 349 helpMenu.add( new Separator() ); 350 MenuManager softwareUpdates = new MenuManager( Messages 351 .getString( "ApplicationActionBarAdvisor.Software_Updates" ), "softwareUpdates" ); softwareUpdates.add( updateAction ); 353 softwareUpdates.add( manageConfigurationAction ); 354 helpMenu.add( softwareUpdates ); 355 helpMenu.add( new Separator() ); 356 helpMenu.add( aboutAction ); 357 } 358 359 360 363 protected void fillCoolBar( ICoolBarManager coolBar ) 364 { 365 IToolBarManager toolbar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); 367 toolbar.add( newDropDownAction ); 368 toolbar.add( preferencesAction ); 369 coolBar.add( new ToolBarContributionItem( toolbar, Application.PLUGIN_ID + ".toolbar" ) ); 371 coolBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) ); 373 374 IToolBarManager navToolBar = new ToolBarManager( SWT.FLAT | SWT.RIGHT ); 377 navToolBar.add( new Separator( IWorkbenchActionConstants.HISTORY_GROUP ) ); 378 navToolBar.add( backwardHistoryAction ); 379 navToolBar.add( forwardHistoryAction ); 380 coolBar.add( new ToolBarContributionItem( navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE ) ); 381 382 } 383 384 } 385 | Popular Tags |