tags:

views:

14

answers:

1

HI,

I am facing some problem.. I want to hide the menu when eclipse workbench starts. But the problem is menu is not hiding when the eclipse workbench starts. It is hiding only when some refresh is happened. for example: when I change the default perspective to some other perspective, I am getting the desired out put. That means menu is hiding. But when the eclipse workbench is loaded it is not hiding the menu. Below is my code.

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
            public void run() {
                try {
IWorkbenchWindow window = Workbench.getInstance().getActiveWorkbenchWindow()
if(window instanceof WorkbenchWindow) {
   MenuManager menuManager = ((WorkbenchWindow)window).getMenuManager();
IContributionItem[] items = menuManager.getItems();
           for(IContributionItem item:items){
                  System.out.println("item.getId()::: "+item.getId());
                  menuManager.remove("org.eclipse.ui.run");
                  menuManager.remove("help");
                  menuManager.remove("project");
           }
   }
}`
}
};
A: 

Would you pls paste how do you call above code?

And another way to hide the menus is using activities extension point.

Kane
I will call the above code under earlyStartup() method of IStartup interface. So it will autmatically call the plugin.
Bhanu
The sequence of workbench initializing and calling the early startup is unstable. So sometimes the workbench window is not be initialized when removing the menu item of window.
Kane
I have a blog post(http://kane-mx.blogspot.com/2008/03/get-rid-of-menus-of-eclipse-platform.html) related to how to use activities extension point to remove menu item. Hope it useful.
Kane

related questions