Search code examples
eclipseeclipse-pluginswteclipse-rcpjface

In ecplipse RCP application automatically get Run option in menubar Want to remove it


enter image description hereIn my Eclipse RCP application i am getting Run option automatically in menu bar. Without writing any code.So, i want to remove this.

Also getting search menu by default. which is ok for this application. But, my manually created menu item like(File, editor) , these items and search menu item distance not same manner.please help me out this situation to overcome on distance on manu item in eclipse RCP.


Solution

  • Just paste this below code in ApplicationWorkbenchWindowAdvisor.java class.

    public void postWindowOpen() { 
        // remove unwanted UI contributions that eclipse makes by default
        IWorkbenchWindow[] windows = PlatformUI.getWorkbench ().getWorkbenchWindows();
        for (int i = 0; i < windows.length; ++i) {
            IWorkbenchPage page = windows[i].getActivePage();
            if (page != null) {
    
                WorkbenchWindow workbenchWin = (WorkbenchWindow)PlatformUI.getWorkbench().getActiveWorkbenchWindow();
                MenuManager menuManager = workbenchWin.getMenuManager();
                IContributionItem[] items = menuManager.getItems();
    
                for(IContributionItem item : items) {
                    if(item.getId().equals("org.eclipse.ui.run")){
                  item.setVisible(false);
                    }
                }
                // hide 'Search' commands
                page.hideActionSet("org.eclipse.search.searchActionSet");
    
            }
        }
    }