eclipse菜单项编程

想要定制菜单,多数菜单项从ActionFactory创建出来,如

MenuManager helpMenu = new MenuManager("帮助(&H)",IWorkbenchActionConstants.M_HELP);
IWorkbenchAction aboutAction = ActionFactory.ABOUT.create(window);
menuBar.add(helpMenu);
但是显示视图的菜单却找不到,下文解答了这个问题,转自 eclipseZone

Re: Show View Action

Vinicius Ferraz Campos schrieb:
> What I need to do to create a Show View Action (open whatever window) in
> my RCP application like in the eclipse?

// snippet
IContributionItem viewsShortList = ContributionItemFactory.VIEWS_SHORTLIST.create(window);
...
MenuManager perpectiveMenu = new MenuManager("Show &View");
viewsMenu.add(viewsShortList);
windowMenu.add(viewsMenu);
// end snippet

The only way to add this menu is programatically.

To contribute views to the short list of this menu see:
http://help.eclipse.org/help32/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_perspectiveExtensions.html


你可能感兴趣的:(eclipse菜单项编程)