| 
 | 
 | 
 | 
 | 
| Re: Remove search and Run menu for menu bar [message #554937 is a reply to message #554833] | 
Tue, 24 August 2010 15:50    | 
 
Eclipse User  | 
 | 
 | 
   | 
 
I tried the following code and it removed single entries from the menus but not the menus itself (like the Run or Search menu). 
 
    @Override
    public void postWindowCreate() {
        // remove unwanted menu entries
	List<String> unwantedItems = Arrays.asList(
		"org.eclipse.ui.openLocalFile", 
		"converstLineDelimitersTo", 
		"org.eclipse.ui.cheatsheets.actions.CheatSheetHelpMenuAction",
		"org.eclipse.debug.ui.actions.BreakpointTypesContribution" ,
		"ExternalToolsGroup" ,
		"org.eclipse.ui.externaltools.ExternalToolMenuDelegateMenu" ,
		"navigate" ,
		"org.eclipse.search.menu", 
		"org.eclipse.ui.run"
	);
	
        IMenuManager menuManager = getWindowConfigurer().getActionBarConfigurer().getMenuManager();
        removeUnwantedItems(unwantedItems, menuManager);
        
    }
    
    private void removeUnwantedItems(final List<String> unwantedItems, final IMenuManager menuManager) {
	IContributionItem[] items = menuManager.getItems();
	
	for (IContributionItem item : items) {
	    if (item instanceof IMenuManager) {
		removeUnwantedItems(unwantedItems, (IMenuManager) item);
	    }
	    
	    if (unwantedItems.contains(item.getId())) {
		menuManager.remove(item);
	    }
	}
    }
 
 
Any ideas why Run and Search are not removed?
 |  
 |  
  | 
 | 
Powered by 
FUDForum. Page generated in 0.06821 seconds