我需要一些帮助来显示我的RCP应用程序中的菜单。我知道有两种显示菜单的方法
1. By specifying the <extention point> in plugin.xml
2. By including the menus in the ApplicationActionBarAdvisor.java
我能够查看plugin.xml文件中指定的菜单,但无法查看ApplicationActionBarAdvisor.java类中指定的菜单。我需要在plugin.xml中指定任何设置才能反映出来吗?下面是ApplicationActionBarAdvisor
中的代码public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
private IWorkbenchAction saveAction ;
private IWorkbenchAction saveAsAction ;
private IWorkbenchAction introAction;
private MenuManager newMenu;
//
// Actions - important to allocate these only in makeActions, and then use
// them
// in the fill methods. This ensures that the actions aren't recreated
// when fillActionBars is called with FILL_PROXY.
public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
super(configurer);
}
public void makeActions(IWorkbenchWindow window)
{
this.saveAction = ActionFactory.SAVE.create(window) ;
this.register(this.saveAction) ;
this.saveAsAction = ActionFactory.SAVE_AS.create(window) ;
this.register(this.saveAsAction) ;
//this.introAction = ActionFactory.INTRO.create(window) ;
//this.register(this.introAction) ;
newMenu = new MenuManager("&New", "new");
}
protected void fillMenuBar(IMenuManager menuBar)
{
final MenuManager fileMenu = new MenuManager("&File", "fi");
final MenuManager editMenu = new MenuManager("&Edit", "edit");
final MenuManager helpMenu = new MenuManager("&Help", "maskithelp");
fileMenu.add(newMenu) ;
fileMenu.add(this.saveAction) ;
fileMenu.add(this.saveAsAction) ;
}
}
非常感谢上述任何帮助。在此先感谢
答案 0 :(得分:0)
您可以通过覆盖
指定ActionBarAdvisor
中要使用的WorkbenchWindowAdvisor
public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer)
方法
您的WorkbenchWindowAdvisor
必须在WorkbenchAdvisor
中通过覆盖:
public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer)
必须在
上的WorkbenchAdvisor
中指定IApplication
PlatformUI.createAndRunWorkbench(display, advisor);
呼叫。
必须在IApplication
扩展点的<run class="application">
元素中指定org.eclipse.core.runtime.applications
。
您必须运行此应用程序或使用org.eclipse.core.runtime.products
产品,该产品在<product application="application"
元素中指定应用程序。
答案 1 :(得分:0)
好的,这可能有点晚了,但从我看到的你忘记添加新创建的菜单管理器, fileMenu , editMenu 和 helpMenu , fillMenuBar 方法中的 menuBar 菜单管理器:
protected void fillMenuBar(IMenuManager menuBar) {
final MenuManager fileMenu = new MenuManager("&File", "fi");
final MenuManager editMenu = new MenuManager("&Edit", "edit");
final MenuManager helpMenu = new MenuManager("&Help", "maskithelp");
fileMenu.add(newMenu);
fileMenu.add(this.saveAction);
fileMenu.add(this.saveAsAction);
// these calls are missing
menuBar.add(fileMenu);
menuBar.add(editMenu);
menuBar.add(helpMenu);
}