I am building a plugin for my own custom perspective. In which i want to hide some default menu like navigate, run for my perspective. I don't want unnecessary menu in my perspective. How can i do that programmatically?
I resolved the issue.
Following is the code which hide navigate
menu and project
menu from my perspective.
IWorkbenchWindow window = Workbench.getInstance()
.getActiveWorkbenchWindow();
if (window instanceof WorkbenchWindow) {
MenuManager menuManager = ((WorkbenchWindow) window)
.getMenuManager();
Menu menu = menuManager.getMenu();
System.out.println("Menu : " + menu);
String[] itemIds = { "navigate","Project" };
for (String itemId : itemIds) {
IContributionItem item = menuManager.find(itemId);
if (item != null) {
item.setVisible(false);
menuManager.update();
}
}
}
Hope it helps anybody.