Java Code Examples for org.eclipse.jface.action.IMenuManager#add()
The following examples show how to use
org.eclipse.jface.action.IMenuManager#add() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListBandProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Creates the context menu for the given object. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { if ( !( object instanceof SlotHandle ) ) return; SlotHandle model = (SlotHandle) object; if ( model.getElementHandle( ) instanceof ListHandle && model.getSlotID( ) == ListHandle.GROUP_SLOT ) { InsertAction insertAction = new InsertAction( object, Messages.getString( "ListBandProvider.action.text" ), //$NON-NLS-1$ ReportDesignConstants.LIST_GROUP_ELEMENT ); menu.add( insertAction ); } else { menu.add( new InsertAction( object ) ); } super.createContextMenu( sourceViewer, object, menu ); }
Example 2
Source File: PortingActionProvider.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
private void addExportMenu(IMenuManager aMenu) { exportWizardActionGroup.setContext(getContext()); if (exportWizardActionGroup.getWizardActionIds().length == 0) { aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, exportAction); return; } IMenuManager submenu = new MenuManager( WorkbenchNavigatorMessages.PortingActionProvider_ExportResourcesMenu_label, COMMON_NAVIGATOR_EXPORT_MENU); exportWizardActionGroup.fillContextMenu(submenu); submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); submenu.add(new Separator()); submenu.add(exportAction); aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, submenu); }
Example 3
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 6 votes |
/** * Hook that allows to add actions to the context menu. * <p> * Subclasses may extend in order to add other actions.</p> * * @param menuManager the context menu manager * @since 3.5 */ protected void fillContextMenu(IMenuManager menuManager) { List selectedElements= ((StructuredSelection)list.getSelection()).toList(); Object item= null; for (Iterator it= selectedElements.iterator(); it.hasNext();) { item= it.next(); if (item instanceof ItemsListSeparator || !isHistoryElement(item)) { return; } } if (selectedElements.size() > 0) { removeHistoryItemAction.setText(WorkbenchMessages.FilteredItemsSelectionDialog_removeItemsFromHistoryAction); menuManager.add(removeHistoryActionContributionItem); } }
Example 4
Source File: NavigationActionProvider.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void addCloudMenu(List<INavigationElement<?>> elements, IMenuManager menu) { if (!CloudPreference.doEnable()) return; int registered = 0; IMenuManager subMenu = new MenuManager(M.Repository); if (elements.size() == 1) registered += registerSingleActions(elements.get(0), subMenu, cloudActions); else if (elements.size() > 1) registered += registerMultiActions(elements, subMenu, cloudActions); int subRegistered = 0; IMenuManager compareMenu = new MenuManager(M.CompareWith); if (elements.size() == 1) subRegistered += registerSingleActions(elements.get(0), compareMenu, cloudCompareActions); else if (elements.size() > 1) subRegistered += registerMultiActions(elements, compareMenu, cloudCompareActions); if (subRegistered > 0) { subMenu.add(compareMenu); registered++; } if (registered == 0) return; menu.add(subMenu); menu.add(new Separator()); }
Example 5
Source File: DatabaseMenu.java From olca-app with Mozilla Public License 2.0 | 6 votes |
@Override public void menuAboutToShow(IMenuManager menu) { menu.add(new DbCreateAction()); menu.add(new DbImportAction()); if (Database.getActiveConfiguration() == null) return; Action checkLinksAction = Actions.create( M.CheckLinkingProperties, null, () -> { LinkingPropertiesPage.show(); }); IAction[] actions = new IAction[] { new DbExportAction(), ValidateAction.forDatabase(), new DbCopyAction(), new DbRenameAction(), new DbDeleteAction(), new DbCloseAction(), checkLinksAction, new DbPropertiesAction(), new DbCompressAction(), }; for (IAction a : actions) { menu.add(a); } }
Example 6
Source File: SampleContextMenuProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public void buildContextMenu( IMenuManager menu ) { menu.removeAll( ); for ( int i = 0; i < actionList.size( ); i++ ) { menu.add( actionList.get( i ) ); } }
Example 7
Source File: DesignerActionBarContributor.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void createInsertMenu( IMenuManager insertMenu ) { contributeActionsToMenu( insertMenu, getInsertElementActions( ) ); insertMenu.add( new Separator( ) ); insertMenu.add( getAction( InsertAggregationAction.ID ) ); insertMenu.add( getAction( InsertRelativeTimePeriodAction.ID ) ); insertMenu.add( new Separator( ) ); }
Example 8
Source File: GamaActionBarAdvisor.java From gama with GNU General Public License v3.0 | 5 votes |
/** * Fills the menu bar with the workbench actions. */ @Override protected void fillMenuBar(final IMenuManager menuBar) { menuBar.add(createFileMenu()); menuBar.add(createEditMenu()); menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); menuBar.add(createHelpMenu()); }
Example 9
Source File: TypeScriptContentOutlinePage.java From typescript.java with MIT License | 5 votes |
/** * Register toolbar actions. * * @param actionBars */ private void registerToolbarActions(IActionBars actionBars) { // Toolbar IToolBarManager toolBarManager = actionBars.getToolBarManager(); toolBarManager.add(new CollapseAllAction(this.fOutlineViewer)); // Menu IMenuManager viewMenuManager = actionBars.getMenuManager(); viewMenuManager.add(new Separator("EndFilterGroup")); //$NON-NLS-1$ viewMenuManager.add(new ToggleLinkingAction()); }
Example 10
Source File: ApplicationActionBarAdvisor.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
protected void fillMenuBar(IMenuManager menuBar) { MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); menuBar.add(fileMenu); fileMenu.add(exitAction); MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT); menuBar.add(editMenu); editMenu.add(preferenceAction); }
Example 11
Source File: XFindPanel.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private CheckAction newCheckAction( IMenuManager menu, String name , String label, boolean enable ) { final CheckAction action = new CheckAction(name, label, enable); action.setEnabled(enable); menu.add(action); return action; }
Example 12
Source File: ResourcesView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.0 */ @Override protected void fillTimeGraphEntryContextMenu(@NonNull IMenuManager menuManager) { ISelection selection = getSite().getSelectionProvider().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection sSel = (IStructuredSelection) selection; if (sSel.getFirstElement() instanceof TimeGraphEntry) { TimeGraphEntry resourcesEntry = (TimeGraphEntry) sSel.getFirstElement(); ITmfTreeDataModel model = resourcesEntry.getEntryModel(); if (model instanceof ResourcesEntryModel) { ResourcesEntryModel resourcesModel = (ResourcesEntryModel) model; Type type = resourcesModel.getType(); if (type == Type.CPU || type == Type.CURRENT_THREAD) { ITmfTrace trace = getTrace(resourcesEntry); TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(trace); Integer data = (Integer) ctx.getData(RESOURCES_FOLLOW_CPU); int cpu = data != null ? data.intValue() : -1; if (cpu >= 0) { menuManager.add(new UnfollowCpuAction(ResourcesView.this, resourcesModel.getResourceId(), trace)); } else { menuManager.add(new FollowCpuAction(ResourcesView.this, resourcesModel.getResourceId(), trace)); } } } } } }
Example 13
Source File: WriteReferencesSearchGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private void addAction(IAction action, IMenuManager manager) { if (action.isEnabled()) { manager.add(action); } }
Example 14
Source File: RemoteProfilesPreferencePage.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
private void fillContextMenu(IMenuManager manager) { final IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection(); final List<Object> items = selection.toList(); if (items.size() == 1) { Object item = items.get(0); if (item instanceof RemoteImportProfileElement) { final RemoteImportProfileElement profile = (RemoteImportProfileElement) item; manager.add(new Action(RemoteMessages.RemoteProfilesPreferencePage_NewConnectionNode) { @Override public void run() { newConnectionNode(profile, null); } }); } else if (item instanceof RemoteImportConnectionNodeElement) { final RemoteImportConnectionNodeElement node = (RemoteImportConnectionNodeElement) item; manager.add(new Action(RemoteMessages.RemoteProfilesPreferencePage_NewTraceGroupAction) { @Override public void run() { newTraceGroup(node, null); } }); } else if (item instanceof RemoteImportTraceGroupElement) { final RemoteImportTraceGroupElement traceGroup = (RemoteImportTraceGroupElement) item; manager.add(new Action(RemoteMessages.RemoteProfilesPreferencePage_NewTraceAction) { @Override public void run() { newTrace(traceGroup, null); } }); } } manager.add(new Separator()); manager.add(fDeleteAction); fDeleteAction.setEnabled(!items.isEmpty()); manager.add(new Separator()); manager.add(fCutAction); fCutAction.setEnabled(items.size() == 1); manager.add(fCopyAction); fCopyAction.setEnabled(items.size() == 1); manager.add(fPasteAction); fPasteAction.setEnabled(items.size() <= 1 && validatePaste(selection.getFirstElement())); }
Example 15
Source File: QuickOutlinePopup.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override protected void fillDialogMenu(IMenuManager dialogMenu) { super.fillDialogMenu(dialogMenu); dialogMenu.add(new Separator("XtextContributions")); contributions.register(this, dialogMenu); }
Example 16
Source File: NodeCompactor.java From depan with Apache License 2.0 | 4 votes |
@Override public void addItemActions(IMenuManager manager, final ViewEditor editor) { manager.add(buildAddHierarchy(editor)); manager.add(buildCollapseHierarchy(editor)); }
Example 17
Source File: ServersViewer.java From neoscada with Eclipse Public License 1.0 | 4 votes |
private void fillContextMenu ( final IMenuManager manager ) { manager.add ( new Separator ( IWorkbenchActionConstants.MB_ADDITIONS ) ); }
Example 18
Source File: AnnotationOutline.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * Adds the these actions to the global action handler: {@link DeleteFeatureStructureAction} * SelectAllAction. * * @param actionBars the new action bars */ @Override public void setActionBars(IActionBars actionBars) { DeleteFeatureStructureAction deleteAction = new DeleteFeatureStructureAction(editor); actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), deleteAction); getSite().getSelectionProvider().addSelectionChangedListener(deleteAction); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), new SelectAllAction()); Action action = new SwitchStyleAction(this); IMenuManager dropDownMenu = actionBars.getMenuManager(); dropDownMenu.add(action); IToolBarManager toolBarManager = actionBars.getToolBarManager(); // wide left annotation side action WideLeftAnnotationSideAction wideLeftAnnotationSideAction = new WideLeftAnnotationSideAction( editor); wideLeftAnnotationSideAction.setActionDefinitionId(WideLeftAnnotationSideAction.ID); wideLeftAnnotationSideAction.setText("Wides the left annotation side"); wideLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin .getTaeImageDescriptor(Images.WIDE_LEFT_SIDE)); getSite().getSelectionProvider().addSelectionChangedListener(wideLeftAnnotationSideAction); actionBars.setGlobalActionHandler(WideLeftAnnotationSideAction.ID, wideLeftAnnotationSideAction); toolBarManager.add(wideLeftAnnotationSideAction); // lower left annotation side action LowerLeftAnnotationSideAction lowerLeftAnnotationSideAction = new LowerLeftAnnotationSideAction( editor); lowerLeftAnnotationSideAction.setActionDefinitionId(LowerLeftAnnotationSideAction.ID); lowerLeftAnnotationSideAction.setText("Lowers the left annotation side"); lowerLeftAnnotationSideAction.setImageDescriptor(CasEditorPlugin .getTaeImageDescriptor(Images.LOWER_LEFT_SIDE)); getSite().getSelectionProvider().addSelectionChangedListener(lowerLeftAnnotationSideAction); actionBars.setGlobalActionHandler(LowerLeftAnnotationSideAction.ID, lowerLeftAnnotationSideAction); toolBarManager.add(lowerLeftAnnotationSideAction); // lower right annotation side action LowerRightAnnotationSideAction lowerRightAnnotationSideAction = new LowerRightAnnotationSideAction(editor); lowerRightAnnotationSideAction.setActionDefinitionId(LowerRightAnnotationSideAction.ID); lowerRightAnnotationSideAction.setText("Lowers the right annotation side"); lowerRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin .getTaeImageDescriptor(Images.LOWER_RIGHT_SIDE)); getSite().getSelectionProvider().addSelectionChangedListener(lowerRightAnnotationSideAction); actionBars.setGlobalActionHandler(LowerRightAnnotationSideAction.ID, lowerRightAnnotationSideAction); toolBarManager.add(lowerRightAnnotationSideAction); // wide right annotation side action WideRightAnnotationSideAction wideRightAnnotationSideAction = new WideRightAnnotationSideAction( editor); wideRightAnnotationSideAction.setActionDefinitionId(WideRightAnnotationSideAction.ID); wideRightAnnotationSideAction.setText("Wides the right annotation side"); wideRightAnnotationSideAction.setImageDescriptor(CasEditorPlugin .getTaeImageDescriptor(Images.WIDE_RIGHT_SIDE)); getSite().getSelectionProvider().addSelectionChangedListener(wideRightAnnotationSideAction); actionBars.setGlobalActionHandler(WideRightAnnotationSideAction.ID, wideRightAnnotationSideAction); toolBarManager.add(wideRightAnnotationSideAction); // merge action MergeAnnotationAction mergeAction = new MergeAnnotationAction(editor); getSite().getSelectionProvider().addSelectionChangedListener(mergeAction); mergeAction.setImageDescriptor(CasEditorPlugin.getTaeImageDescriptor(Images.MERGE)); toolBarManager.add(mergeAction); // delete action toolBarManager.add(ActionFactory.DELETE.create(getSite().getWorkbenchWindow())); super.setActionBars(actionBars); }
Example 19
Source File: DesignerActionBarAdvisor.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Fills the coolbar with the workbench actions. */ protected void fillCoolBar( ICoolBarManager coolBar ) { { // Set up the context Menu IMenuManager popUpMenu = new MenuManager( ); popUpMenu.add( new ActionContributionItem( lockToolBarAction ) ); coolBar.setContextMenuManager( popUpMenu ); } coolBar.add( new GroupMarker( IWorkbenchActionConstants.GROUP_FILE ) ); { // File Group IToolBarManager fileToolBar = new ToolBarManager( coolBar.getStyle( ) ); fileToolBar.add(new NewWizardDropDownAction( window)); // fileToolBar.add( newReportAction ); // fileToolBar.add( newLibraryAction ); // fileToolBar.add( newReportTemplateAction ); fileToolBar.add( new GroupMarker( IWorkbenchActionConstants.NEW_EXT ) ); fileToolBar.add( new GroupMarker( IWorkbenchActionConstants.SAVE_GROUP ) ); fileToolBar.add( saveAction ); fileToolBar.add( new GroupMarker( IWorkbenchActionConstants.SAVE_EXT ) ); fileToolBar.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) ); // Add to the cool bar manager coolBar.add( new ToolBarContributionItem( fileToolBar, IWorkbenchActionConstants.TOOLBAR_FILE ) ); } coolBar.add( new GroupMarker( IWorkbenchActionConstants.MB_ADDITIONS ) ); // coolBar.add( new GroupMarker( IWorkbenchConstants.GROUP_NAV ) ); { // Navigate group IToolBarManager navToolBar = new ToolBarManager( coolBar.getStyle( ) ); navToolBar.add( new Separator( IWorkbenchActionConstants.HISTORY_GROUP ) ); navToolBar.add( new GroupMarker( IWorkbenchActionConstants.GROUP_APP ) ); navToolBar.add( backwardHistoryAction ); navToolBar.add( forwardHistoryAction ); navToolBar.add( new Separator( IWorkbenchActionConstants.PIN_GROUP ) ); navToolBar.add( pinEditorContributionItem ); // Add to the cool bar manager coolBar.add( new ToolBarContributionItem( navToolBar, IWorkbenchActionConstants.TOOLBAR_NAVIGATE ) ); } coolBar.add( new GroupMarker( IWorkbenchActionConstants.GROUP_EDITOR ) ); coolBar.add( new GroupMarker( IWorkbenchActionConstants.GROUP_HELP ) ); { // Help group IToolBarManager helpToolBar = new ToolBarManager( coolBar.getStyle( ) ); helpToolBar.add( new Separator( IWorkbenchActionConstants.GROUP_HELP ) ); // Add the group for applications to contribute helpToolBar.add( new GroupMarker( IWorkbenchActionConstants.GROUP_APP ) ); // Add to the cool bar manager coolBar.add( new ToolBarContributionItem( helpToolBar, IWorkbenchActionConstants.TOOLBAR_HELP ) ); } }
Example 20
Source File: CellProvider.java From birt with Eclipse Public License 1.0 | 3 votes |
/** * Creates the context menu for the given object. * * @param menu * the menu * @param object * the object */ public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { menu.add( new InsertAction( object ) ); menu.add( new CopyCellContentsAction( object ) ); super.createContextMenu( sourceViewer, object, menu ); }