読者です 読者をやめる 読者になる 読者になる

不要なメニューの隠し方

こんな感じでWorkbenchWindowAdvisor#postWindowOpen()で削除しちゃえば消えちゃった。

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }
    
    public void preWindowOpen() {
        IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
//        configurer.setInitialSize(new Point(400, 300));
        configurer.setShowCoolBar(true);
        configurer.setShowPerspectiveBar(true);
		configurer.setShowProgressIndicator(true);
		configurer.setShowStatusLine(true);
    }
    
    @Override
    public void createWindowContents(Shell shell) {
    	Image image = Activator.getDefault().getImageRegistry().get(ImageConstants.WINDOW_TITLE_IMAGE.toString());
		shell.setImage(image);
    	super.createWindowContents(shell);
    }
    
    @Override
    public void postWindowOpen() {
    	ApplicationWindow window = (ApplicationWindow)getWindowConfigurer().getWindow();
    	MenuManager menuBarManager = window.getMenuBarManager();
		System.out.println(menuBarManager.findUsingPath("help/additions"));
		System.out.println(menuBarManager.remove("org.eclipse.ui.run"));
		System.out.println(menuBarManager.remove("org.eclipse.ui.run"));
		menuBarManager.update(true);
    }
    
}