1 24 package org.objectweb.dolphin.rcp; 25 26 import org.eclipse.jface.action.GroupMarker; 27 import org.eclipse.jface.action.IContributionItem; 28 import org.eclipse.jface.action.ICoolBarManager; 29 import org.eclipse.jface.action.IMenuManager; 30 import org.eclipse.jface.action.IToolBarManager; 31 import org.eclipse.jface.action.MenuManager; 32 import org.eclipse.jface.action.Separator; 33 import org.eclipse.jface.action.ToolBarContributionItem; 34 import org.eclipse.jface.action.ToolBarManager; 35 import org.eclipse.swt.SWT; 36 import org.eclipse.ui.IWorkbenchActionConstants; 37 import org.eclipse.ui.IWorkbenchWindow; 38 import org.eclipse.ui.actions.ActionFactory; 39 import org.eclipse.ui.actions.ContributionItemFactory; 40 import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; 41 import org.eclipse.ui.application.ActionBarAdvisor; 42 import org.eclipse.ui.application.IActionBarConfigurer; 43 import org.objectweb.dolphin.actions.ChangeWorkspaceAction; 44 45 46 51 public class DolphinActionBarAdvisor extends ActionBarAdvisor { 52 private IWorkbenchAction exitAction; 54 private IWorkbenchAction undoAction; 56 private IWorkbenchAction redoAction; 57 private IWorkbenchAction cutAction; 58 private IWorkbenchAction copyAction; 59 private IWorkbenchAction pasteAction; 60 private IWorkbenchAction deleteAction; 61 private IWorkbenchAction selectAllAction; 62 private IContributionItem perspectiveList; 64 private IContributionItem viewList; 65 private IWorkbenchAction preferenceAction; 66 private IWorkbenchAction openWindowAction; 67 private IWorkbenchAction helpAction; 69 private IWorkbenchAction aboutAction; 70 71 private ChangeWorkspaceAction changeWorkspace; 72 73 76 public DolphinActionBarAdvisor(IActionBarConfigurer configurer) { 77 super(configurer); 78 } 79 80 88 91 protected void makeActions(final IWorkbenchWindow window) { 92 93 exitAction=ActionFactory.QUIT.create(window); 95 register(exitAction); 96 97 undoAction=ActionFactory.UNDO.create(window); 99 register(undoAction); 100 redoAction=ActionFactory.REDO.create(window); 101 register(redoAction); 102 copyAction=ActionFactory.COPY.create(window); 103 register(copyAction); 104 cutAction=ActionFactory.CUT.create(window); 105 register(cutAction); 106 pasteAction=ActionFactory.PASTE.create(window); 107 register(pasteAction); 108 deleteAction=ActionFactory.DELETE.create(window); 109 register(deleteAction); 110 selectAllAction=ActionFactory.SELECT_ALL.create(window); 111 register(selectAllAction); 112 113 perspectiveList = ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window); 115 viewList = ContributionItemFactory.VIEWS_SHORTLIST.create(window); 116 preferenceAction=ActionFactory.PREFERENCES.create(window); 117 register(preferenceAction); 118 openWindowAction=ActionFactory.OPEN_NEW_WINDOW.create(window); 119 register(openWindowAction); 120 121 helpAction=ActionFactory.HELP_CONTENTS.create(window); 123 register(helpAction); 124 aboutAction=ActionFactory.ABOUT.create(window); 125 register(aboutAction); 126 127 changeWorkspace = new ChangeWorkspaceAction(window); 128 register(changeWorkspace); 129 130 131 } 132 133 136 protected void fillMenuBar(IMenuManager menubar) { 137 createFileMenu(menubar); 138 createEditMenu(menubar); 139 createWindowMenu(menubar); 140 createHelpMenu(menubar); 141 } 142 143 147 private void createFileMenu(IMenuManager menubar) { 148 MenuManager fileMenu = new MenuManager(Messages.getString("FileMenu"), IWorkbenchActionConstants.M_FILE); 149 menubar.add(fileMenu); 150 menubar.add(new GroupMarker(IWorkbenchActionConstants.FILE_START)); 151 menubar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); 152 fileMenu.add(changeWorkspace); 153 fileMenu.add(exitAction); 154 menubar.add(new GroupMarker(IWorkbenchActionConstants.FILE_END)); 155 } 156 157 161 private void createEditMenu(IMenuManager menubar) { 162 MenuManager editmenu = new MenuManager(Messages.getString("EditMenu"),IWorkbenchActionConstants.M_EDIT); menubar.add(editmenu); 164 menubar.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START)); 165 editmenu.add(undoAction); 166 editmenu.add(redoAction); 167 editmenu.add(new Separator()); 168 editmenu.add(copyAction); 169 editmenu.add(cutAction); 170 editmenu.add(pasteAction); 171 editmenu.add(deleteAction); 172 editmenu.add(new Separator()); 173 editmenu.add(selectAllAction); 174 menubar.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END)); 175 menubar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); 176 } 177 178 182 private void createWindowMenu(IMenuManager menubar) { 183 MenuManager menuWindow = new MenuManager(Messages.getString("WindowMenu"), IWorkbenchActionConstants.M_WINDOW); MenuManager perspectiveMenu = new MenuManager(Messages.getString("WindowMenu_OpenPerspective"), "openPerspective"); perspectiveMenu.add(perspectiveList); 186 menuWindow.add(perspectiveMenu); 187 MenuManager viewMenu = new MenuManager(Messages.getString("WindowMenu_ShowView")); viewMenu.add(viewList); 189 menuWindow.add(viewMenu); 190 menuWindow.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); 191 menuWindow.add(preferenceAction); 192 menuWindow.add(openWindowAction); 193 menubar.add(menuWindow); 194 195 } 196 197 201 private void createHelpMenu(IMenuManager menubar) { 202 MenuManager menuHelp = new MenuManager(Messages.getString("HelpMenu"), IWorkbenchActionConstants.M_HELP); menuHelp.add(helpAction); 205 menuHelp.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); 207 menuHelp.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); 208 menuHelp.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); 209 menuHelp.add(new Separator()); 212 menuHelp.add(aboutAction); 213 menubar.add(menuHelp); 214 215 } 216 217 220 protected void fillCoolBar(ICoolBarManager coolbar){ 221 IToolBarManager toolbar = new ToolBarManager(SWT.FLAT|SWT.RIGHT); 222 coolbar.add(new ToolBarContributionItem(toolbar,"main")); 223 toolbar.add(helpAction); 224 toolbar.add(aboutAction); 225 226 } 227 228 } 229 | Popular Tags |