Java Code Examples for org.eclipse.jface.action.IMenuManager#remove()

The following examples show how to use org.eclipse.jface.action.IMenuManager#remove() . 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: GamlEditor.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void rulerContextMenuAboutToShow(final IMenuManager menu) {
	super.rulerContextMenuAboutToShow(menu);
	menu.remove("projection");

	final IMenuManager foldingMenu = new MenuManager(XtextUIMessages.Editor_FoldingMenu_name, "projection"); //$NON-NLS-1$
	menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu);
	IAction action = getAction("FoldingToggle"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingExpandAll"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingCollapseAll"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingCollapseStrings"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingRestore"); //$NON-NLS-1$
	foldingMenu.add(action);
}
 
Example 2
Source File: CleanupHelper.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
private static void changeIcon(final IMenuManager menu, final IContributionItem item,
		final ImageDescriptor image) {
	if (item instanceof ActionContributionItem) {
		((ActionContributionItem) item).getAction().setImageDescriptor(image);
	} else if (item instanceof CommandContributionItem) {
		final CommandContributionItemParameter data = ((CommandContributionItem) item).getData();
		data.commandId = ((CommandContributionItem) item).getCommand().getId();
		data.icon = image;
		final CommandContributionItem newItem = new CommandContributionItem(data);
		newItem.setId(item.getId());
		menu.insertAfter(item.getId(), newItem);
		menu.remove(item);
		item.dispose();
	} else if (item instanceof ActionSetContributionItem) {
		changeIcon(menu, ((ActionSetContributionItem) item).getInnerItem(), image);
	} else if (item instanceof MenuManager) {
		((MenuManager) item).setImageDescriptor(image);
	}
}
 
Example 3
Source File: N4JSEditor.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@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);
			}
		}
	}
}
 
Example 4
Source File: XdsConsolePage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
protected void contextMenuAboutToShow(IMenuManager menuManager) {
    super.contextMenuAboutToShow(menuManager);
    menuManager.add(fScrollLockAction);
    XdsConsoleViewer viewer = (XdsConsoleViewer) getViewer();
    if (!viewer.isReadOnly()) {
        menuManager.remove(ActionFactory.CUT.getId());
        menuManager.remove(ActionFactory.PASTE.getId());
    }
}
 
Example 5
Source File: ProjectExplorerActionProvider.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillActionBars(IActionBars actionBars) {
	IMenuManager viewMenu = actionBars.getMenuManager();
	ICommonActionExtensionSite site = getActionSite();
	IContributionItem contributionItem = viewMenu.find(ShowResourcesContribution.ID);
	if (contributionItem != null) {
		viewMenu.remove(contributionItem);
	}
	if (ProjectUtils.isWorkspaceContainsXdsProjects()) {
		viewMenu.add(new ShowResourcesContribution(site.getStructuredViewer(), site.getExtensionStateModel()));
	}
}
 
Example 6
Source File: CustomFiltersActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void removePreviousLRUFilterActions(IMenuManager mm) {
	if (fFilterIdsUsedInLastViewMenu == null)
		return;

	for (int i= 0; i < fFilterIdsUsedInLastViewMenu.length; i++)
		mm.remove(fFilterIdsUsedInLastViewMenu[i]);
}
 
Example 7
Source File: CategoryFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void updateMenu(IMenuManager manager) {
	IContributionItem[] items= manager.getItems();
	if (items != null) {
		for (int i= 0; i < items.length; i++) {
			IContributionItem item= items[i];
			if (item != null && item.getId() != null && item.getId().equals(FILTER_CATEGORY_ACTION_ID)) {
				IContributionItem removed= manager.remove(item);
				if (removed != null) {
					item.dispose();
				}
			}
		}
	}
	List<String> menuEntries= new ArrayList<String>();
	boolean hasUncategorizedMembers= getMenuCategories(menuEntries);
	Collections.sort(menuEntries, Collator.getInstance());

	if (menuEntries.size() > 0 && hasUncategorizedMembers)
		manager.appendToGroup(CATEGORY_MENU_GROUP_NAME, new FilterUncategorizedMembersAction());

	int count= 0;
	for (Iterator<String> iter= menuEntries.iterator(); iter.hasNext();) {
		String category= iter.next();
		manager.appendToGroup(CATEGORY_MENU_GROUP_NAME, new CategoryFilterAction(category, count + 1));
		count++;
	}
}
 
Example 8
Source File: WorkingSetShowActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void cleanViewMenu(IMenuManager menuManager) {
	for (Iterator<IContributionItem> iter= fContributions.iterator(); iter.hasNext();) {
		IContributionItem removed= menuManager.remove(iter.next());
		if (removed != null) {
			removed.dispose();
		}
	}
	fContributions.clear();
}
 
Example 9
Source File: WorkingSetFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void removePreviousLRUWorkingSetActions(IMenuManager mm) {
	for (int i= 1; i < fLRUMenuCount; i++) {
		String id= WorkingSetMenuContributionItem.getId(i);
		IContributionItem item= mm.remove(id);
		if (item != null) {
			item.dispose();
			fContributions.remove(item);
		}
	}
}
 
Example 10
Source File: WorkingSetFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void cleanViewMenu(IMenuManager menuManager) {
	for (Iterator<IContributionItem> iter= fContributions.iterator(); iter.hasNext();) {
		IContributionItem removed= menuManager.remove(iter.next());
		if (removed != null) {
			removed.dispose();
		}
	}
	fContributions.clear();
	fMenuManager.removeMenuListener(fMenuListener);
	fMenuListener= null;
}
 
Example 11
Source File: LangEditorContextMenuContributor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void prepareSourceMenu(IMenuManager ctxMenu) {
	ctxMenu.remove(ITextEditorActionConstants.SHIFT_RIGHT);
	ctxMenu.remove(ITextEditorActionConstants.SHIFT_LEFT);
	
	
	// I wonder if it's ok to reuse the same menu id as the workbench menu
	IMenuManager sourceMenu = createSourceMenuSkeleton();
	
	contributeSourceMenu(sourceMenu);
	ctxMenu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, sourceMenu);
}
 
Example 12
Source File: XtextEditor.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
protected void editorContextMenuAboutToShow(IMenuManager menu) {
	super.editorContextMenuAboutToShow(menu);
	menu.remove(ITextEditorActionConstants.SHIFT_RIGHT);
	menu.remove(ITextEditorActionConstants.SHIFT_LEFT);
}
 
Example 13
Source File: CppStyleConsolePage.java    From CppStyle with MIT License 4 votes vote down vote up
@Override
protected void contextMenuAboutToShow(IMenuManager menuManager) {
	super.contextMenuAboutToShow(menuManager);
	menuManager.remove(ActionFactory.CUT.getId());
	menuManager.remove(ActionFactory.PASTE.getId());
}