0

i have a very simple eclipse 3.6-based rcp application. i have an existing "Windows" menu to which i am trying to add "Reset Perspective..." sub-menu by creating a command entry with commandId value of org.eclipse.ui.window.resetPerspective. the sub-menu appears just fine, but it is disabled. could someone please help me with enabling it? thank you for your time!!!

user1056027
  • 145
  • 2
  • 2
  • 13

1 Answers1

2

Try using the programmatic solution in your ApplicationActionBarAdvisor  class as following :

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);
        // ...
     }
}
Kelibiano
  • 81
  • 1
  • thank you for the response, Kelibiano. because i already added the menu via plugin.xml, the code you provided within makeActions() function was enough for it to work. thank you! – user1056027 Jul 20 '12 at 03:20