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?
Asked
Active
Viewed 1,063 times
2
-
See if this question helps: http://stackoverflow.com/q/21872811/207764 – Fredrik Mar 03 '14 at 12:14
-
Answer which is given in the above question is not going to help me as i want to do that programmatically. Visibility of the above menu isn't dependent on user. I don't want the user to see those menu in my perspective. – Napster Mar 03 '14 at 12:54
-
Did you read the code of [CustomizePerspectiveDialog#okPressed](http://grepcode.com/file/repository.grepcode.com/java/eclipse.org/3.6/org.eclipse.ui/workbench/3.6.0/org/eclipse/ui/internal/dialogs/CustomizePerspectiveDialog.java#CustomizePerspectiveDialog.okPressed%28%29)? It's useful for you. – Kohei Mikami Mar 04 '14 at 03:09
1 Answers
1
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.

Napster
- 95
- 8
-
Hi, Is there any way to remove the recent perspective shortcut shown in toolbar(top right corner) [link]http://stackoverflow.com/questions/42874157/how-to-remove-a-perspective-from-perspective-toolbarplaced-in-the-top-right-cor?noredirect=1#comment72864372_42874157[link] – Raj Perumalsamy Mar 21 '17 at 09:12