Bug 83059 [RCP] No enablement of perspective menu items
RCP application using factory methods to create menu items for Close Perspective , Close All Perspectives, Reset Perspective, etc. does not maintain enablement state of actions. This code in WorkbenchAdvisor's fillActionBars() method recreates the problem: //Use standard factory methods for actions IWorkbenchAction resetPersAction = ActionFactory.RESET_PERSPECTIVE.create(window); IWorkbenchAction closePersAction = ActionFactory.CLOSE_PERSPECTIVE.create(window); IWorkbenchAction closeAllPersAction = ActionFactory.CLOSE_ALL_PERSPECTIVES.create(window); //Create menu items IMenuManager mgr = configurer.getMenuManager(); MenuManager windowMenu = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW); mgr.add(windowMenu); windowMenu.add(resetPersAction); windowMenu.add(closePersAction); windowMenu.add(closeAllPersAction); //Register global actions configurer.registerGlobalAction(resetPersAction); configurer.registerGlobalAction(closePersAction); configurer.registerGlobalAction(closeAllPersAction); I have posted this issue to the RCP news group and received a reply stating that the enablement of these actions should be handled by the RCP developer. However, the ActionFactory API suggests that these actions maintain their enablement state.
bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java
goToSubMenu.add(upAction);
        goToSubMenu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
        menu.add(new Separator(IWorkbenchActionConstants.OPEN_EXT));
        for (int i = 2; i < 5; ++i) {
            menu.add(new Separator(IWorkbenchActionConstants.OPEN_EXT + i));
        }
        menu.add(new Separator(IWorkbenchActionConstants.SHOW_EXT));
        {
            MenuManager showInSubMenu = new MenuManager(IDEWorkbenchMessages.Workbench_showIn, "showIn") { 
                public String getMenuText() {
                    String result = super.getMenuText();
                    if (showInQuickMenu == null)
                        return null;
                    String shortCut = showInQuickMenu.getShortCutString();
                    if (shortCut == null)
                        return result;
                    return result + "\t" + shortCut; 
                }
            };
            showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN
                    .create(getWindow()));
            menu.add(showInSubMenu);
        }
        for (int i = 2; i < 5; ++i) {
            menu.add(new Separator(IWorkbenchActionConstants.SHOW_EXT + i));
        }
        menu.add(new Separator());
        menu.add(nextAction);
        menu.add(previousAction);
        menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));