org.eclipse.jface.action.IMenuListener Java Examples
The following examples show how to use
org.eclipse.jface.action.IMenuListener.
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: BundleView.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * hookContextMenu */ private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); // Create menu. Menu menu = menuMgr.createContextMenu(treeViewer.getControl()); treeViewer.getControl().setMenu(menu); // Register menu for extension. getSite().registerContextMenu(menuMgr, treeViewer); }
Example #2
Source File: GraphStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Adds the actions to the tableviewer context menu. * * @param actions * a collection of IAction objets */ private void hookContextMenu(final Collection<Object> actions, StructuredViewer viewer) { MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { for (Iterator<Object> iter = actions.iterator(); iter.hasNext();) { Object item = iter.next(); if (item instanceof IContributionItem) { manager.add((IContributionItem) item); } else if (item instanceof IAction) { manager.add((IAction) item); } } manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
Example #3
Source File: MarkerStatsView.java From eclipse-cs with GNU Lesser General Public License v2.1 | 6 votes |
/** * Adds the actions to the tableviewer context menu. * * @param actions * a collection of IAction objets */ private void hookContextMenu(final Collection<Object> actions, StructuredViewer viewer) { MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { for (Iterator<Object> iter = actions.iterator(); iter.hasNext();) { Object item = iter.next(); if (item instanceof IContributionItem) { manager.add((IContributionItem) item); } else if (item instanceof IAction) { manager.add((IAction) item); } } manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
Example #4
Source File: AbapGitStagingObjectMenuFactory.java From ADT_Frontend with MIT License | 6 votes |
public AbapGitStagingObjectMenuFactory(TreeViewer treeViewer, boolean unstaged, AbapGitStagingView view, IAbapGitStagingService stagingUtil) { this.treeViewer = treeViewer; this.view = view; this.unstaged = unstaged; this.stagingService = stagingUtil; createActions(); //create the context menu this.menuManager = new MenuManager("#PopupMenu"); //$NON-NLS-1$ this.menuManager.setRemoveAllWhenShown(true); this.menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { buildContextMenu(manager); } }); Menu menu = this.menuManager.createContextMenu(treeViewer.getControl()); treeViewer.getControl().setMenu(menu); }
Example #5
Source File: ServerView.java From RDFS with Apache License 2.0 | 6 votes |
/** * Contextual menu */ private void createContextMenu() { // Create menu manager. MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager mgr) { fillContextMenu(mgr); } }); // Create menu. Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); // Register menu for extension. getSite().registerContextMenu(menuMgr, viewer); }
Example #6
Source File: WorkingSetFilterActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Adds the filter actions to the menu * * @param mm the menu manager */ public void fillViewMenu(IMenuManager mm) { if (mm.find(IWorkingSetActionGroup.ACTION_GROUP) == null) { mm.add(new Separator(IWorkingSetActionGroup.ACTION_GROUP)); } add(mm, fSelectWorkingSetAction); add(mm, fClearWorkingSetAction); add(mm, fEditWorkingSetAction); add(mm, new Separator()); add(mm, new Separator(LRU_GROUP)); fMenuManager= mm; fMenuListener= new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { removePreviousLRUWorkingSetActions(manager); addLRUWorkingSetActions(manager); } }; fMenuManager.addMenuListener(fMenuListener); }
Example #7
Source File: GenerateBuildPathActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (!canOperateOnSelection()) return; String menuText= ActionMessages.BuildPath_label; IMenuManager subMenu= new MenuManager(menuText, MENU_ID); subMenu.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillViewSubMenu(manager); } }); subMenu.setRemoveAllWhenShown(true); subMenu.add(new ConfigureBuildPathAction(fSite)); menu.appendToGroup(fGroupName, subMenu); }
Example #8
Source File: SearchScopeActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public void fillContextMenu(IMenuManager menu) { MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.SearchScopeActionGroup_searchScope, IContextMenuConstants.GROUP_SEARCH); javaSearchMM.setRemoveAllWhenShown(true); javaSearchMM.addMenuListener(new IMenuListener() { /* (non-Javadoc) * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager manager) { fillSearchActions(manager); } }); fillSearchActions(javaSearchMM); menu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, javaSearchMM); }
Example #9
Source File: RefactorActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void addRefactorSubmenu(IMenuManager menu) { MenuManager refactorSubmenu= new MenuManager(ActionMessages.RefactorMenu_label, MENU_ID); refactorSubmenu.setActionDefinitionId(QUICK_MENU_ID); if (fEditor != null) { final ITypeRoot element= getEditorInput(); if (element != null && ActionUtil.isOnBuildPath(element)) { refactorSubmenu.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { refactorMenuShown(manager); } }); refactorSubmenu.add(fNoActionAvailable); menu.appendToGroup(fGroupName, refactorSubmenu); } } else { ISelection selection= fSelectionProvider.getSelection(); for (Iterator<SelectionDispatchAction> iter= fActions.iterator(); iter.hasNext(); ) { iter.next().update(selection); } if (fillRefactorMenu(refactorSubmenu) > 0) menu.appendToGroup(fGroupName, refactorSubmenu); } }
Example #10
Source File: ImageMenuAdapterFactory.java From birt with Eclipse Public License 1.0 | 6 votes |
public Object getAdapter( final Object adaptableObject, Class adapterType ) { if ( ( adaptableObject instanceof ImageHandle ) && adapterType == IMenuListener.class ) { return new ISchematicMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { manager.appendToGroup( GEFActionConstants.GROUP_EDIT, new ReloadImageAction( adaptableObject ) ); } public void setActionRegistry( ActionRegistry actionRegistry ) { } }; } return null; }
Example #11
Source File: BibtexEntryView.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { IStructuredSelection s = (IStructuredSelection) viewer.getSelection(); if(s.getFirstElement() instanceof DocumentImpl) { fillContextMenu(manager); } } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
Example #12
Source File: IndexView.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * hookContextMenu */ private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); // Create menu. Menu menu = menuMgr.createContextMenu(treeViewer.getControl()); treeViewer.getControl().setMenu(menu); // Register menu for extension. getSite().registerContextMenu(menuMgr, treeViewer); }
Example #13
Source File: FilteredItemsSelectionDialog.java From tlaplus with MIT License | 6 votes |
private void createPopupMenu() { removeHistoryItemAction = new RemoveHistoryItemAction(); removeHistoryActionContributionItem = new ActionContributionItem( removeHistoryItemAction); contextMenuManager = new MenuManager(); contextMenuManager.setRemoveAllWhenShown(true); contextMenuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); final Table table = list.getTable(); Menu menu= contextMenuManager.createContextMenu(table); table.setMenu(menu); }
Example #14
Source File: RefactorActionGroup.java From typescript.java with MIT License | 6 votes |
private void addRefactorSubmenu(IMenuManager menu) { MenuManager refactorSubmenu = new MenuManager(RefactoringMessages.RefactorMenu_label, MENU_ID); // refactorSubmenu.setActionDefinitionId(QUICK_MENU_ID); if (fEditor != null) { // final ITypeRoot element= getEditorInput(); // if (element != null && ActionUtil.isOnBuildPath(element)) { refactorSubmenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { refactorMenuShown(manager); } }); refactorSubmenu.add(fNoActionAvailable); menu.appendToGroup(fGroupName, refactorSubmenu); // } } else { ISelection selection = fSelectionProvider.getSelection(); for (Iterator<SelectionDispatchAction> iter = fActions.iterator(); iter.hasNext();) { iter.next().update(selection); } if (fillRefactorMenu(refactorSubmenu) > 0) menu.appendToGroup(fGroupName, refactorSubmenu); } }
Example #15
Source File: GraphNodeViewer.java From depan with Apache License 2.0 | 6 votes |
private void setupHierarchyMenu(final TreeViewer viewer) { MenuManager menuMgr = new MenuManager(); Menu menu = menuMgr.createContextMenu(viewer.getControl()); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { ISelection selection = viewer.getSelection(); List<?> choices = Selections.getObjects(selection); if (choices.isEmpty()) { return; } if (choices.size() > 1) { addMultiActions(manager); return; } Object menuElement = Selections.getFirstObject(selection); addItemActions(manager, menuElement); }}); menuMgr.setRemoveAllWhenShown(true); viewer.getControl().setMenu(menu); }
Example #16
Source File: LaunchConfigurationContent.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private void createContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { populateBrowserActions(launchConfiguration, manager); manager.add(new Separator()); manager.add(new Action("&Copy") { @Override public void run() { copySelectionToClipboard(); } }); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); }
Example #17
Source File: TsfTraceAnalysisView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { TsfTraceAnalysisView.this.fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
Example #18
Source File: LapseView.java From lapse-plus with GNU General Public License v3.0 | 5 votes |
/** * Attaches a contextmenu listener to the tree */ void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) { MenuManager menuMgr= new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(menuListener); Menu menu= menuMgr.createContextMenu(getControl()); getControl().setMenu(menu); viewSite.registerContextMenu(popupId, menuMgr, this); }
Example #19
Source File: LapseView.java From lapse-plus with GNU General Public License v3.0 | 5 votes |
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(fViewer.getControl()); fViewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, fViewer); }
Example #20
Source File: ReportListView.java From CodeCheckerEclipsePlugin with Eclipse Public License 1.0 | 5 votes |
private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { ReportListView.this.fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
Example #21
Source File: SinkView.java From lapse-plus with GNU General Public License v3.0 | 5 votes |
/** * Attaches a contextmenu listener to the tree */ void initContextMenu(IMenuListener menuListener, String popupId, IWorkbenchPartSite viewSite) { MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(menuListener); Menu menu = menuMgr.createContextMenu(getControl()); getControl().setMenu(menu); viewSite.registerContextMenu(popupId, menuMgr, this); }
Example #22
Source File: SourceView.java From lapse-plus with GNU General Public License v3.0 | 5 votes |
private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { SourceView.this.fillContextMenu(manager); } }); Menu menu = menuMgr.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); getSite().registerContextMenu(menuMgr, viewer); }
Example #23
Source File: ScriptTreeNodeProvider.java From birt with Eclipse Public License 1.0 | 5 votes |
public void createContextMenu( TreeViewer sourceViewer, Object object, IMenuManager menu ) { if ( object instanceof IMenuListener ) { ( (IMenuListener) object ).menuAboutToShow( menu ); } }
Example #24
Source File: CrosstabMenuAdapterFactory.java From birt with Eclipse Public License 1.0 | 5 votes |
public Object getAdapter( Object adaptableObject, Class adapterType ) { if ( adaptableObject instanceof ExtendedItemHandle && ( (ExtendedItemHandle) adaptableObject ).getExtensionName( ) .equals( "Crosstab" ) && adapterType == IMenuListener.class ) { final ExtendedItemHandle handle = (ExtendedItemHandle)adaptableObject; return new ISchematicMenuListener( ) { public void menuAboutToShow( IMenuManager manager ) { CrosstabReportItemHandle crosstab = null; try { crosstab = (CrosstabReportItemHandle)( (ExtendedItemHandle) handle ).getReportItem( ); } catch ( ExtendedElementException e ) { return; } //manager.appendToGroup( "additions", new AddComputedMeasureAction( ); //$NON-NLS-1$ manager.appendToGroup( GEFActionConstants.GROUP_VIEW, new AddComputedMeasureAction( crosstab ) ); manager.appendToGroup( GEFActionConstants.GROUP_VIEW, new AddRelativeTimePeriodAction( handle ) ); } public void setActionRegistry( ActionRegistry actionRegistry ) { } }; } return null; }
Example #25
Source File: MechanicStatusControlContribution.java From workspacemechanic with Eclipse Public License 1.0 | 5 votes |
/** * Creates and registers a new popup menu on the supplied control. * * <p> * When the menu is about to be shown the * {@link #fillContextMenu(IMenuManager)} method will be called. */ private void createContextMenu(Control control) { MenuManager mgr = new MenuManager("#PopupMenu"); mgr.setRemoveAllWhenShown(true); mgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { fillContextMenu(manager); } }); Menu menu = mgr.createContextMenu(control); control.setMenu(menu); }
Example #26
Source File: XViewerCustomMenu.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void init(final XViewer xviewer) { this.xViewer = xviewer; setupActions(); xViewer.getTree().addListener(SWT.KeyUp, e-> { if (e.keyCode == 'c' && e.stateMask == (SWT.CONTROL | SWT.SHIFT)) { performCopyColumnCells(); } else if (e.keyCode == 'b' && e.stateMask == (SWT.CONTROL | SWT.SHIFT)) { performViewOrCopyCell(Option.Copy); } else if (e.keyCode == 'v' && e.stateMask == (SWT.CONTROL | SWT.SHIFT)) { performViewOrCopyCell(Option.View); } else if (e.keyCode == 'c' && e.stateMask == SWT.CONTROL) { performCopy(); } }); xViewer.getTree().addListener(SWT.Dispose, e-> { if (clipboard != null) { clipboard.dispose(); } }); xViewer.getMenuManager().addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager) { if (headerMouseClick) { setupMenuForHeader(); xviewer.updateMenuActionsForHeader(); } else { setupMenuForTable(); xViewer.updateMenuActionsForTable(); } } }); xViewer.getTree().addListener(SWT.MenuDetect, event -> { Point pt = Display.getCurrent().map(null, xViewer.getTree(), new Point(event.x, event.y)); Rectangle clientArea = xViewer.getTree().getClientArea(); headerMouseClick = clientArea.y <= pt.y && pt.y < (clientArea.y + xViewer.getTree().getHeaderHeight()); }); }
Example #27
Source File: CodeRecommendationResultsView.java From scava with Eclipse Public License 2.0 | 5 votes |
private void createContextMenu(Viewer viewer) { MenuManager contextMenu = new MenuManager("#ViewerMenu"); //$NON-NLS-1$ contextMenu.setRemoveAllWhenShown(true); contextMenu.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager mgr) { fillContextMenu(mgr); } }); Menu menu = contextMenu.createContextMenu(viewer.getControl()); viewer.getControl().setMenu(menu); }
Example #28
Source File: PerformanceView.java From n4js with Eclipse Public License 1.0 | 5 votes |
private void createMenu() { IMenuManager mgr = getViewSite().getActionBars().getMenuManager(); mgr.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager m) { addDynamicVisualisationSelection(m); } }); }
Example #29
Source File: CallHierarchyViewer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Attaches a context menu listener to the tree * @param menuListener the menu listener * @param viewSite the view site * @param selectionProvider the selection provider */ void initContextMenu(IMenuListener menuListener, IWorkbenchPartSite viewSite, ISelectionProvider selectionProvider) { MenuManager menuMgr= new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(menuListener); Menu menu= menuMgr.createContextMenu(getTree()); getTree().setMenu(menu); viewSite.registerContextMenu(menuMgr, selectionProvider); }
Example #30
Source File: BibOutlinePage.java From texlipse with Eclipse Public License 1.0 | 5 votes |
private void createContextMenu() { // create menu manager MenuManager menuMgr = new MenuManager(); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager mgr) { fillContextMenu(mgr); } }); // create the menu Menu menu = menuMgr.createContextMenu(getTreeViewer().getControl()); getTreeViewer().getControl().setMenu(menu); }