| 1 | package de.uka.ipd.sdq.pcmbench.application; |
| 2 | |
| 3 | import org.eclipse.debug.ui.actions.OpenLaunchDialogAction; |
| 4 | import org.eclipse.jface.action.GroupMarker; |
| 5 | import org.eclipse.jface.action.IAction; |
| 6 | import org.eclipse.jface.action.ICoolBarManager; |
| 7 | import org.eclipse.jface.action.IMenuManager; |
| 8 | import org.eclipse.jface.action.MenuManager; |
| 9 | import org.eclipse.jface.action.Separator; |
| 10 | import org.eclipse.ui.IWorkbenchActionConstants; |
| 11 | import org.eclipse.ui.IWorkbenchWindow; |
| 12 | import org.eclipse.ui.actions.ActionFactory; |
| 13 | import org.eclipse.ui.actions.ContributionItemFactory; |
| 14 | import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; |
| 15 | import org.eclipse.ui.application.ActionBarAdvisor; |
| 16 | import org.eclipse.ui.application.IActionBarConfigurer; |
| 17 | |
| 18 | public class PCMBenchApplicationActionBarAdvisor extends ActionBarAdvisor { |
| 19 | |
| 20 | private IWorkbenchAction introAction; |
| 21 | |
| 22 | public PCMBenchApplicationActionBarAdvisor(IActionBarConfigurer configurer) { |
| 23 | super(configurer); |
| 24 | } |
| 25 | |
| 26 | protected void makeActions(IWorkbenchWindow window) { |
| 27 | introAction = ActionFactory.INTRO.create(window); |
| 28 | register(introAction); |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | protected void fillCoolBar(ICoolBarManager coolBar) { |
| 33 | super.fillCoolBar(coolBar); |
| 34 | } |
| 35 | |
| 36 | protected void fillMenuBar(IMenuManager menuBar) { |
| 37 | IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow(); |
| 38 | |
| 39 | menuBar.add(createFileMenu(window)); |
| 40 | menuBar.add(createEditMenu(window)); |
| 41 | menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 42 | menuBar.add(createWindowMenu(window)); |
| 43 | menuBar.add(createHelpMenu(window)); |
| 44 | } |
| 45 | |
| 46 | /** |
| 47 | * Creates the 'File' menu. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @generated |
| 51 | */ |
| 52 | protected IMenuManager createFileMenu(IWorkbenchWindow window) { |
| 53 | IMenuManager menu = new MenuManager("&File", |
| 54 | IWorkbenchActionConstants.M_FILE); |
| 55 | menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START)); |
| 56 | addToMenuAndRegister(menu, ActionFactory.NEW.create(window)); |
| 57 | |
| 58 | IMenuManager newMenu = new MenuManager("&New", "new"); |
| 59 | newMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 60 | |
| 61 | menu.add(newMenu); |
| 62 | menu.add(new Separator()); |
| 63 | menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 64 | menu.add(new Separator()); |
| 65 | addToMenuAndRegister(menu, ActionFactory.CLOSE.create(window)); |
| 66 | addToMenuAndRegister(menu, ActionFactory.CLOSE_ALL.create(window)); |
| 67 | menu.add(new Separator()); |
| 68 | addToMenuAndRegister(menu, ActionFactory.SAVE.create(window)); |
| 69 | addToMenuAndRegister(menu, ActionFactory.SAVE_AS.create(window)); |
| 70 | addToMenuAndRegister(menu, ActionFactory.SAVE_ALL.create(window)); |
| 71 | menu.add(new Separator()); |
| 72 | addToMenuAndRegister(menu, ActionFactory.QUIT.create(window)); |
| 73 | menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END)); |
| 74 | return menu; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Creates the 'Edit' menu. |
| 79 | * <!-- begin-user-doc --> |
| 80 | * <!-- end-user-doc --> |
| 81 | * @generated |
| 82 | */ |
| 83 | protected IMenuManager createEditMenu(IWorkbenchWindow window) { |
| 84 | IMenuManager menu = new MenuManager("&Edit", |
| 85 | IWorkbenchActionConstants.M_EDIT); |
| 86 | menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START)); |
| 87 | |
| 88 | addToMenuAndRegister(menu, ActionFactory.UNDO.create(window)); |
| 89 | addToMenuAndRegister(menu, ActionFactory.REDO.create(window)); |
| 90 | menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT)); |
| 91 | menu.add(new Separator()); |
| 92 | |
| 93 | addToMenuAndRegister(menu, ActionFactory.CUT.create(window)); |
| 94 | addToMenuAndRegister(menu, ActionFactory.COPY.create(window)); |
| 95 | addToMenuAndRegister(menu, ActionFactory.PASTE.create(window)); |
| 96 | menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT)); |
| 97 | menu.add(new Separator()); |
| 98 | |
| 99 | addToMenuAndRegister(menu, ActionFactory.DELETE.create(window)); |
| 100 | addToMenuAndRegister(menu, ActionFactory.SELECT_ALL.create(window)); |
| 101 | menu.add(new Separator()); |
| 102 | |
| 103 | menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT)); |
| 104 | |
| 105 | menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END)); |
| 106 | menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 107 | return menu; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * Creates the 'Window' menu. |
| 112 | * <!-- begin-user-doc --> |
| 113 | * <!-- end-user-doc --> |
| 114 | * @generated |
| 115 | */ |
| 116 | protected IMenuManager createWindowMenu(IWorkbenchWindow window) { |
| 117 | IMenuManager menu = new MenuManager("&Window", |
| 118 | IWorkbenchActionConstants.M_WINDOW); |
| 119 | |
| 120 | addToMenuAndRegister(menu, ActionFactory.OPEN_NEW_WINDOW.create(window)); |
| 121 | addToMenuAndRegister(menu, ActionFactory.SHOW_VIEW_MENU.create(window)); |
| 122 | |
| 123 | IMenuManager subMenu = new MenuManager("Open &View"); |
| 124 | subMenu.add(ContributionItemFactory.VIEWS_SHORTLIST.create(window)); |
| 125 | menu.add(subMenu); |
| 126 | addToMenuAndRegister(menu, ActionFactory.RESET_PERSPECTIVE.create(window)); |
| 127 | menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 128 | menu.add(ContributionItemFactory.OPEN_WINDOWS.create(window)); |
| 129 | |
| 130 | return menu; |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Creates the 'Help' menu. |
| 135 | * <!-- begin-user-doc --> |
| 136 | * <!-- end-user-doc --> |
| 137 | * @generated |
| 138 | */ |
| 139 | protected IMenuManager createHelpMenu(IWorkbenchWindow window) { |
| 140 | IMenuManager menu = new MenuManager("&Help", IWorkbenchActionConstants.M_HELP); |
| 141 | // Welcome or intro page would go here |
| 142 | // Help contents would go here |
| 143 | // Tips and tricks page would go here |
| 144 | menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); |
| 145 | menu.add(introAction); |
| 146 | addToMenuAndRegister(menu, ActionFactory.HELP_CONTENTS.create(window)); |
| 147 | menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); |
| 148 | menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); |
| 149 | addToMenuAndRegister(menu, ActionFactory.ABOUT.create(window)); |
| 150 | return menu; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Adds the specified action to the given menu and also registers the action with the |
| 155 | * action bar configurer, in order to activate its key binding. |
| 156 | * <!-- begin-user-doc --> |
| 157 | * <!-- end-user-doc --> |
| 158 | * @generated |
| 159 | */ |
| 160 | protected void addToMenuAndRegister(IMenuManager menuManager, IAction action) { |
| 161 | menuManager.add(action); |
| 162 | getActionBarConfigurer().registerGlobalAction(action); |
| 163 | } |
| 164 | } |