我的eclipse rcp应用程序中禁用了“Reset Perspective ...”菜单

时间:2012-07-18 18:23:54

标签: eclipse rcp perspective

我有一个非常简单的基于eclipse 3.6的rcp应用程序。我有一个现有的“Windows”菜单,我试图通过创建 commandId 值为 org.eclipse.ui的命令条目来添加“重置透视...”子菜单。 window.resetPerspective 即可。子菜单看起来很好,但它被禁用。有人可以帮我启用吗?谢谢你的时间!!!

1 个答案:

答案 0 :(得分:2)

尝试使用ApplicationActionBarAdvisor类中的编程解决方案,如下所示:

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction resetPerspectiveAction;

    @Override
    protected void makeActions(IWorkbenchWindow window) { 
        // ...
        // create and register the actions
        resetPerspectiveAction = ActionFactory.RESET_PERSPECTIVE.create(window);
        register(resetPerspectiveAction);
        // ...
    }

    @Override
    protected void fillMenuBar(IMenuManager menuBar) {
        // ...
        // create and fill the window menu
        MenuManager windowMenu = new MenuManager("&Window", WorkbenchActionConstants.M_WINDOW);
        menuBar.add(windowMenu);
        windowMenu.add(resetPerspectiveAction);
        // ...
     }
}