List of usage examples for org.eclipse.jface.action IMenuManager removeMenuListener
public void removeMenuListener(IMenuListener listener);
From source file:com.isb.datamodeler.internal.ui.views.actions.workingset.CompoundContributionItem.java
License:Open Source License
public void setParent(IContributionManager parent) { if (getParent() instanceof IMenuManager) { IMenuManager menuMgr = (IMenuManager) getParent(); menuMgr.removeMenuListener(menuListener); }//from w w w . j a v a 2 s. c o m if (parent instanceof IMenuManager) { IMenuManager menuMgr = (IMenuManager) parent; menuMgr.addMenuListener(menuListener); } super.setParent(parent); }
From source file:gov.nasa.ensemble.core.plan.editor.actions.AbstractCommandItemContributor.java
License:Open Source License
@Override public void setParent(IContributionManager parent) { if (getParent() instanceof IMenuManager) { IMenuManager menuMgr = (IMenuManager) getParent(); menuMgr.removeMenuListener(menuListener); }/*from ww w . j a v a 2 s .co m*/ if (parent instanceof IMenuManager) { IMenuManager menuMgr = (IMenuManager) parent; menuMgr.addMenuListener(menuListener); } super.setParent(parent); }
From source file:net.sf.eclipsensis.editor.NSISActionContributor.java
License:Open Source License
private void doSetActiveEditor(IEditorPart part) { IEditorPart oldEditor = getActiveEditorPart(); if (oldEditor != null) { IMenuManager manager = oldEditor.getEditorSite().getActionBars().getMenuManager(); if (manager != null) { manager.removeMenuListener(this); }/* w ww . j a v a 2 s. c o m*/ } ITextEditor editor = null; if (part instanceof ITextEditor) { editor = (ITextEditor) part; } if (editor != null) { try { IMenuManager manager = editor.getEditorSite().getActionBars().getMenuManager(); manager = manager.findMenuUsingPath("net.sf.eclipsensis.Menu"); //$NON-NLS-1$ if (manager != null) { manager.addMenuListener(this); } } catch (NullPointerException e) { EclipseNSISPlugin.getDefault().log(e); } } mContentAssistProposal.setAction(getAction(editor, INSISEditorConstants.CONTENT_ASSIST_PROPOSAL)); mInsertTemplate.setAction(getAction(editor, INSISEditorConstants.INSERT_TEMPLATE)); mTabsToSpaces.setAction(getAction(editor, INSISEditorConstants.TABS_TO_SPACES)); mToggleComment.setAction(getAction(editor, INSISEditorConstants.TOGGLE_COMMENT)); mAddBlockComment.setAction(getAction(editor, INSISEditorConstants.ADD_BLOCK_COMMENT)); mRemoveBlockComment.setAction(getAction(editor, INSISEditorConstants.REMOVE_BLOCK_COMMENT)); mInsertFile.setAction(getAction(editor, INSISEditorConstants.INSERT_FILE)); mInsertDirectory.setAction(getAction(editor, INSISEditorConstants.INSERT_DIRECTORY)); mInsertColor.setAction(getAction(editor, INSISEditorConstants.INSERT_COLOR)); mInsertRegFile.setAction(getAction(editor, INSISEditorConstants.INSERT_REGFILE)); mInsertRegKey.setAction(getAction(editor, INSISEditorConstants.INSERT_REGKEY)); mInsertRegVal.setAction(getAction(editor, INSISEditorConstants.INSERT_REGVAL)); }
From source file:org.eclipse.edt.ide.ui.internal.editor.EGLEditor.java
License:Open Source License
protected void editorContextMenuAboutToShow(IMenuManager menu) { super.editorContextMenuAboutToShow(menu); addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.SELECT_ALL); addAction(menu, ITextEditorActionConstants.GROUP_FIND, ITextEditorActionConstants.FIND); addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.REDO); menu.addMenuListener(new IMenuListener() { @Override/*from www. j a va 2 s .c o m*/ public void menuAboutToShow(IMenuManager menu) { try { IContributionItem item = menu.find("org.eclipse.edt.ide.ui.file.sourceMenu"); if (item != null) { menu.remove(item); } } finally { menu.removeMenuListener(this); } } }); }
From source file:org.eclipse.sirius.ui.tools.internal.views.common.ContextMenuFiller.java
License:Open Source License
@Override public void menuAboutToHide(IMenuManager manager) { // As the menu is about to be hidden, and because all actions filled by // this menu filler will be re-calculated, // we dispose all the contributed actions Collection<IContributionItem> toRemove = Sets.newLinkedHashSet(); for (IContributionItem item : manager.getItems()) { if (addedIContributionItemCache.keySet().contains(item)) { toRemove.add(item);// www. j av a2 s .c o m } } for (IContributionItem item : toRemove) { manager.remove(item); } // No need to listen to the manager any more manager.removeMenuListener(this); addedIContributionItemCache.clear(); }