/** * Tests that the Top Level Elements */ @Test public void testTopLevelElementsEntryNoDuplicates() { IActionBars actionBars = projectExplorer.getViewSite().getActionBars(); IMenuManager menuManager = actionBars.getMenuManager(); int topLevelElementsEntriesFound = 0; for (IContributionItem item : menuManager.getItems()) { if (item instanceof MenuManager) { String escapedMenuText = LegacyActionTools.removeMnemonics(((MenuManager) item).getMenuText()); if (escapedMenuText.equals("Top Level Elements")) { topLevelElementsEntriesFound++; } } } assertEquals("There was more than one 'Top Level Elements' entry in the navigator action bar.", topLevelElementsEntriesFound, 1); }
@Override public void fillContextMenu(final IMenuManager menu) { // {@link N4JSProjectActionGroup} does enablement-logic // on its own, thus always invoke it here projectGroup.fillContextMenu(menu); // Only delegate to {@link N4JSWorkingSetActionProvider}, // if the current selection contains working sets. if (selectionContainsWorkingSet) { workingSetActionProvider.fillContextMenu(menu); } if (assignWorkingSetsAction.isEnabled()) { menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, assignWorkingSetsAction); } }
@Override public void fillContextMenu(final IMenuManager menu) { super.fillContextMenu(menu); // If disabled, do not contribute if (!enableContribution) { return; } if (openAction.isEnabled() && enableOpenInContextMenu) menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, openAction); if (closeAction.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, closeAction); if (closeUnrelatedAction.isEnabled() && areOnlyProjectsSelected(closeUnrelatedAction.getStructuredSelection())) menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, closeUnrelatedAction); }
@Override public void fillPopupMenu(IMenuManager manager, SchemaViewer viewer) { // add element ContextualAction action = new AddElementAction("Add", IAction.AS_PUSH_BUTTON, Notifications.notifyRefreshReveal(getContext())); action.init(getContext(), true); manager.add(action); // remove element action = new RemoveElementAction("Remove", IAction.AS_PUSH_BUTTON, Notifications.NOT_REF); action.init(getContext(), true); manager.add(action); // copy action = new CopyElementAction("Copy", IAction.AS_PUSH_BUTTON, Notifications.NONE); action.init(getContext(), true); manager.add(action); // paste action = new PasteElementAction("Paste", IAction.AS_PUSH_BUTTON, Notifications.NOT_REF); action.init(getContext(), true); manager.add(action); }
private void fillContextMenu(IMenuManager manager) { if (_TableViewer.getSelection().isEmpty()) { return; } manager.add(_NewZnodeAction); manager.add(new Separator()); manager.add(_OpenAction); manager.add(new Separator()); manager.add(_TableEditAction); manager.add(_TableEditChildrenAction); manager.add(new Separator()); if (_DeleteAction.isEnabled()) { manager.add(_DeleteAction); } manager.add(new Separator()); manager.add(_RefreshAction); }
public void buildContextMenu(IMenuManager menu) { GEFActionConstants.addStandardActionGroups(menu); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.UNDO.getId())); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId())); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId())); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionIdConstants.MODIFY_ACTION_ID)); IAction saveAction = getAction(ActionFactory.SAVE.getId()); saveAction.setImageDescriptor(Activator.getImageDescriptor(Activator.IMAGE_SAVE)); menu.appendToGroup(GEFActionConstants.GROUP_SAVE, saveAction); menu.appendToGroup(GEFActionConstants.MB_ADDITIONS, createExportMenuManager()); menu.appendToGroup(GEFActionConstants.MB_ADDITIONS, getAction(ActionIdConstants.IMPORT_DATABASE_ACTION_ID)); menu.appendToGroup(GEFActionConstants.MB_ADDITIONS, getAction(ActionIdConstants.CHANGE_DATABASE_ACTION_ID)); }
@Override protected void editorContextMenuAboutToShow(final IMenuManager menu) { super.editorContextMenuAboutToShow(menu); final IContributionItem[] items = menu.getItems(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof IMenuManager) { final IMenuManager subMenu = (IMenuManager) items[i]; final IContributionItem testShowIn = subMenu.find(ContributionItemFactory.VIEWS_SHOW_IN.getId()); if (null != testShowIn) { menu.remove(subMenu); } } } }
/** * This inserts global actions before the "additions-end" separator. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected void addGlobalActions(IMenuManager menuManager) { menuManager.insertAfter("additions-end", new Separator("ui-actions")); menuManager.insertAfter("ui-actions", showPropertiesViewAction); refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); menuManager.insertAfter("ui-actions", refreshViewerAction); super.addGlobalActions(menuManager); }
@Override public void fillContextMenu(final IMenuManager menu) { if (inViewPart && canEnableOpenAction()) { if (openGroup.getOpenAction().isEnabled()) { openGroup.fillContextMenu(menu); } } }
@Override public void fillActionBars(final IActionBars actionBars) { if (hasContributedToViewMenu) { return; } final IMenuManager topLevelSubMenu = new MenuManager("Top Level Elements"); addActions(topLevelSubMenu); final IMenuManager menuManager = actionBars.getMenuManager(); menuManager.insertBefore(IWorkbenchActionConstants.MB_ADDITIONS, topLevelSubMenu); hasContributedToViewMenu = true; }
private void fillContextMenu(IMenuManager manager) { manager.add(actionRelaunch); manager.add(actionRelaunchFailed); manager.add(actionStop); manager.add(new Separator()); manager.add(actionLock); manager.add(new Separator()); // Other plug-ins can contribute their actions here manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); }
private void fillLocalPullDown(IMenuManager manager) { manager.add(actionRelaunch); manager.add(actionRelaunchFailed); manager.add(actionStop); manager.add(new Separator()); manager.add(actionLock); }
private void createMenu() { IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); mgr.setRemoveAllWhenShown(true); addDynamicVisualisationSelection(mgr); mgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager m) { addDynamicVisualisationSelection(m); } }); }
@Override public void fillActionBars(final int flags) { delegate.fillActionBars(flags); // To remove 'Build Working Set' contribution item from the main menu. final IMenuManager menuManager = configurer.getMenuManager(); final MenuManager projectManager = getMenuManager(PROJECT_MENU_PREDICATE, menuManager); if (null != projectManager) { final MenuManager workingSetManager = getMenuManager(WORKING_SET_MENU_PREDICATE, projectManager); projectManager.remove(workingSetManager); projectManager.update(true); } }
/** * Create a new {@link TableViewer} with {@link DataModel} elements. * * @param site The {@link IWorkbenchPartSite} used to register the table's context menu. * @param table The {@link Table}. * @param dataModelClass The {@link DataModel} element {@link Class}. * @param dataModelElementType The {@link DataModel} {@link IElementType}. * @param input The {@link TableViewer} input. * @param inputElementType The input {@link IElementType}. * @return A new {@link TableViewer}. */ public static TableViewer createDataModelTableViewer(IWorkbenchPartSite site, Table table, Class<?> dataModelClass, final IElementType dataModelElementType, Object input, IElementType inputElementType) { TableViewer tableViewer = createTableViewer(table, dataModelClass, dataModelElementType, input, inputElementType, new DataModelElementBinding()); List<BaseAction> tableActions = dataModelElementType.getActions(); if (tableActions != null) { for (BaseAction action : tableActions) { action.setSelectionProvider(tableViewer); } MenuManager menuManager = new MenuManager("#PopupMenu"); menuManager.setRemoveAllWhenShown(true); menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { dataModelElementType.fillContextMenu(manager); } }); Menu menu = menuManager.createContextMenu(table); table.setMenu(menu); site.registerContextMenu(menuManager, tableViewer); } return tableViewer; }
/** * This inserts global actions before the "additions-end" separator. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected void addGlobalActions ( IMenuManager menuManager ) { menuManager.insertAfter ( "additions-end", new Separator ( "ui-actions" ) ); menuManager.insertAfter ( "ui-actions", showPropertiesViewAction ); refreshViewerAction.setEnabled ( refreshViewerAction.isEnabled () ); menuManager.insertAfter ( "ui-actions", refreshViewerAction ); super.addGlobalActions ( menuManager ); }
private void hookTableContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(_TableViewer.getControl()); _TableViewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, _TableViewer); }
private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(_TreeViewer.getControl()); _TreeViewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, _TreeViewer); }
@Override public void fillContextMenu(IMenuManager manager) { BaseOpenAction openAction = getOpenAction(); if (openAction != null && !openAction.getSelectionProvider().getSelection().isEmpty()) { manager.add(openAction); } RefreshAction refreshAction = getRefreshAction(); if (refreshAction != null && !refreshAction.getSelectionProvider().getSelection().isEmpty()) { manager.add(new Separator()); manager.add(refreshAction); } }
/** * This inserts global actions before the "additions-end" separator. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected void addGlobalActions ( IMenuManager menuManager ) { menuManager.insertAfter ( "additions-end", new Separator ( "ui-actions" ) ); //$NON-NLS-1$ //$NON-NLS-2$ menuManager.insertAfter ( "ui-actions", showPropertiesViewAction ); //$NON-NLS-1$ refreshViewerAction.setEnabled ( refreshViewerAction.isEnabled () ); menuManager.insertAfter ( "ui-actions", refreshViewerAction ); //$NON-NLS-1$ super.addGlobalActions ( menuManager ); }
@Override public void fillContextMenu ( final IMenuManager menu ) { if ( this.openAction.isEnabled () ) { // menu.appendToGroup ( ICommonMenuConstants.GROUP_OPEN, this.openAction ); } }
@Override protected void fillMenuBar ( final IMenuManager menuBar ) { final MenuManager fileMenu = new MenuManager ( "&File", IWorkbenchActionConstants.M_FILE ); final MenuManager windowMenu = new MenuManager ( "&Window", IWorkbenchActionConstants.M_WINDOW ); final MenuManager helpMenu = new MenuManager ( "&Help", IWorkbenchActionConstants.M_HELP ); final MenuManager fileNewMenu = new MenuManager ( "&New", IWorkbenchActionConstants.NEW_EXT ); final MenuManager windowNewMenu = new MenuManager ( "Show &View", IWorkbenchActionConstants.SHOW_EXT ); menuBar.add ( fileMenu ); // Add a group marker indicating where action set menus will appear. menuBar.add ( new GroupMarker ( IWorkbenchActionConstants.MB_ADDITIONS ) ); menuBar.add ( windowMenu ); menuBar.add ( helpMenu ); // File fileMenu.add ( this.newWindowAction ); fileMenu.add ( new Separator () ); fileMenu.add ( fileNewMenu ); fileMenu.add ( getAction ( ActionFactory.SAVE.getId () ) ); fileMenu.add ( getAction ( ActionFactory.NEW_EDITOR.getId () ) ); fileMenu.add ( new GroupMarker ( IWorkbenchActionConstants.OPEN_EXT ) ); fileMenu.add ( new Separator () ); fileMenu.add ( this.exitAction ); fileNewMenu.add ( this.newWizards ); // Window windowNewMenu.add ( this.showViews ); windowMenu.add ( windowNewMenu ); windowMenu.add ( getAction ( ActionFactory.PREFERENCES.getId () ) ); // Help helpMenu.add ( this.aboutAction ); helpMenu.add ( getAction ( ActionFactory.INTRO.getId () ) ); }
/** * Create the actions. */ private void createActions() { IMenuManager popup = new MenuManager(); List<IContributionManager> mans = Arrays.asList(getViewSite().getActionBars().getToolBarManager(), getViewSite().getActionBars().getMenuManager(), popup); IAction showHardware = createPreferenceAction("Show Devices", DevicePreferenceConstants.SHOW_HARDWARE, "icons/camera-lens.png"); IAction showMalcolm = createPreferenceAction("Show Malcolm Devices", DevicePreferenceConstants.SHOW_MALCOLM, "icons/alarm-clock-select.png"); IAction showProcessing = createPreferenceAction("Show Processing", DevicePreferenceConstants.SHOW_PROCESSING, "icons/processing.png"); ViewUtil.addGroups("visibility", mans, showHardware, showMalcolm, showProcessing); IAction refresh = new Action("Refresh", Activator.getImageDescriptor("icons/recycle.png")) { @Override public void run() { refresh(); } }; ViewUtil.addGroups("refresh", mans, refresh); IAction configure = new Action("Configure", Activator.getImageDescriptor("icons/configure.png")) { @Override public void run() { configure(); } }; ViewUtil.addGroups("camera", mans, configure); }
/** * This inserts global actions before the "additions-end" separator. <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ @Override protected void addGlobalActions ( final IMenuManager menuManager ) { menuManager.insertAfter ( "additions-end", new Separator ( "ui-actions" ) ); menuManager.insertAfter ( "ui-actions", this.showPropertiesViewAction ); this.refreshViewerAction.setEnabled ( this.refreshViewerAction.isEnabled () ); menuManager.insertAfter ( "ui-actions", this.refreshViewerAction ); menuManager.insertAfter ( "ui-actions", this.saveAsAction ); super.addGlobalActions ( menuManager ); }
private void hookContextMenu () { final MenuManager menuMgr = new MenuManager ( "#PopupMenu", VIEW_ID ); menuMgr.setRemoveAllWhenShown ( true ); menuMgr.addMenuListener ( new IMenuListener () { @Override public void menuAboutToShow ( final IMenuManager manager ) { fillContextMenu ( manager ); } } ); final Menu menu = menuMgr.createContextMenu ( this.viewer.getControl () ); this.viewer.getControl ().setMenu ( menu ); getSite ().registerContextMenu ( menuMgr, this.viewer ); }
protected void hookContextMenu ( final Control control, final ISelectionProvider selectionProvider, final IViewSite viewSite ) { final MenuManager menuMgr = new MenuManager ( "#PopupMenu" ); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown ( true ); menuMgr.addMenuListener ( new IMenuListener () { @Override public void menuAboutToShow ( final IMenuManager manager ) { fillContextMenu ( manager ); } } ); final Menu menu = menuMgr.createContextMenu ( control ); control.setMenu ( menu ); viewSite.registerContextMenu ( menuMgr, selectionProvider ); }