@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); ISelection selection= getContext().getSelection(); if (selection instanceof IStructuredSelection) { if (canEnable((IStructuredSelection)selection)) { MenuManager newMenu = new MenuManager(ActionMessages.NewWizardsActionGroup_new); menu.appendToGroup(IContextMenuConstants.GROUP_NEW, newMenu); newMenu.add(new NewWizardMenu(fSite.getWorkbenchWindow())); } } }
/** * Creates and returns the File menu. */ private MenuManager createFileMenu() { MenuManager menu = new MenuManager(IDEWorkbenchMessages.Workbench_file, IWorkbenchActionConstants.M_FILE); menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START)); { // create the New submenu, using the same id for it as the New // action String newText = IDEWorkbenchMessages.Workbench_new; String newId = ActionFactory.NEW.getId(); MenuManager newMenu = new MenuManager(newText, newId); newMenu.setActionDefinitionId("org.eclipse.ui.file.newQuickMenu"); //$NON-NLS-1$ newMenu.add(new Separator(newId)); this.newWizardMenu = new NewWizardMenu(getWindow()); newMenu.add(this.newWizardMenu); newMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menu.add(newMenu); } menu.add(new GroupMarker(IWorkbenchActionConstants.NEW_EXT)); menu.add(new Separator()); menu.add(closeAction); menu.add(closeAllAction); // menu.add(closeAllSavedAction); menu.add(new GroupMarker(IWorkbenchActionConstants.CLOSE_EXT)); menu.add(new Separator()); menu.add(saveAction); menu.add(saveAsAction); menu.add(saveAllAction); menu.add(getRevertItem()); menu.add(new Separator()); menu.add(getMoveItem()); menu.add(getRenameItem()); menu.add(getRefreshItem()); menu.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT)); menu.add(new Separator()); menu.add(getPrintItem()); menu.add(new GroupMarker(IWorkbenchActionConstants.PRINT_EXT)); menu.add(new Separator()); menu.add(switchWorkspaceAction); menu.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT)); menu.add(new Separator()); menu.add(importResourcesAction); menu.add(exportResourcesAction); menu.add(new GroupMarker(IWorkbenchActionConstants.IMPORT_EXT)); menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); menu.add(new Separator()); menu.add(getPropertiesItem()); menu.add(ContributionItemFactory.REOPEN_EDITORS.create(getWindow())); menu.add(new GroupMarker(IWorkbenchActionConstants.MRU)); menu.add(new Separator()); // If we're on OS X we shouldn't show this command in the File menu. It // should be invisible to the user. However, we should not remove it - // the carbon UI code will do a search through our menu structure // looking for it when Cmd-Q is invoked (or Quit is chosen from the // application menu. ActionContributionItem quitItem = new ActionContributionItem(quitAction); quitItem.setVisible(!Util.isMac()); menu.add(quitItem); menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END)); return menu; }