org.eclipse.jface.action.IMenuListener2 Java Examples
The following examples show how to use
org.eclipse.jface.action.IMenuListener2.
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: TmfView.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Add the "New view" action to the view menu. This action spawns a new view of * the same type as the caller. */ private void contributeNewViewActionToLocalMenu(IMenuManager menuManager) { if (!menuManager.isEmpty()) { menuManager.add(new Separator()); } if (this instanceof ITmfPinnable) { MenuManager newViewMenu = new MenuManager(MessageFormat.format(Messages.TmfView_NewViewActionText, this.getTitle())); newViewMenu.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NEW_VIEW)); newViewMenu.setRemoveAllWhenShown(true); newViewMenu.addMenuListener(new IMenuListener2() { @Override public void menuAboutToShow(IMenuManager mgr) { Set<@NonNull ITmfTrace> openedTraces = TmfTraceManager.getInstance().getOpenedTraces(); ITmfTrace activeTrace = ((ITmfPinnable) TmfView.this).getTrace(); if (activeTrace != null) { mgr.add(new NewTmfViewAction(TmfView.this, activeTrace, true)); mgr.add(new Separator()); } for (ITmfTrace trace : openedTraces) { mgr.add(new NewTmfViewAction(TmfView.this, trace)); } mgr.add(new Separator()); mgr.add(new NewTmfViewAction(TmfView.this, null)); } @Override public void menuAboutToHide(IMenuManager manager) { /* Clear menu to release action references to trace instances */ manager.removeAll(); } }); menuManager.add(newViewMenu); } else { NewTmfViewAction action = new NewTmfViewAction(TmfView.this); menuManager.add(action); } }
Example #2
Source File: MenuManagerCopiedToAddCreateMenuWithMenuParent.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Notifies any menu listeners that a menu is about to hide. * Only listeners registered at the time this method is called are notified. * * @param manager the menu manager * */ private void fireAboutToHide(IMenuManager manager) { final Object[] listeners = this.listeners.getListeners(); for (int i = 0; i < listeners.length; ++i) { final Object listener = listeners[i]; if (listener instanceof IMenuListener2) { final IMenuListener2 listener2 = (IMenuListener2) listener; listener2.menuAboutToHide(manager); } } }