【问题标题】:"Reset Perspective..." menu is disabled in my eclipse rcp application在我的 Eclipse rcp 应用程序中禁用了“重置透视...”菜单
【发布时间】:2012-07-17 20:58:08
【问题描述】:

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

【问题讨论】:

    标签: eclipse rcp perspective


    【解决方案1】:

    尝试在 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);
            // ...
         }
    }
    

    【讨论】:

    • 感谢您的回复,凯利比亚诺。因为我已经通过 plugin.xml 添加了菜单,所以您在 makeActions() 函数中提供的代码足以让它工作。谢谢!
    猜你喜欢
    • 2011-09-17
    • 2013-11-12
    • 2011-07-17
    • 2012-10-19
    • 2013-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多