0

What is the code to add to the Exit menu (file>exit) to insert an icon in the

-ApplicationActionBarAdvisor.java

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

    private IWorkbenchAction exitAction;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {

        exitAction = ActionFactory.QUIT.create(window);
         exitAction.setImageDescriptor(Activator.getImageDescriptor("/icons/download.png"));
        register(exitAction);

    }

    protected void fillMenuBar(IMenuManager menuBar) {

        MenuManager fileMenu = new MenuManager("&File",
        IWorkbenchActionConstants.M_FILE);

        menuBar.add(fileMenu);
         menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        menuBar.add(helpMenu);


        fileMenu.add(exitAction);

    }
}
greg-449
  • 109,219
  • 232
  • 102
  • 145
  • I assume this is your action bar advisor for your RCP. Since this is something you have written we need to see how you are creating the menu items before we can possibly advise. Show your code. – greg-449 Jul 24 '14 at 07:34
  • public class ApplicationActionBarAdvisor extends ActionBarAdvisor { private IWorkbenchAction exitAction; public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { super(configurer);} protected void makeActions(IWorkbenchWindow window) { exitAction = ActionFactory.QUIT.create(window); register(exitAction);} protected void fillMenuBar(IMenuManager menuBar) { MenuManager fileMenu = new MenuManager("&File",IWorkbenchActionConstants.M_FILE); menuBar.add(fileMenu); fileMenu.add(exitAction); }} – user3817959 Jul 24 '14 at 08:00
  • Edit the question to add the code rather than putting unreadable code in a comment. – greg-449 Jul 24 '14 at 08:47
  • Done, sorry i'm new here. – user3817959 Jul 24 '14 at 08:59

1 Answers1

2

Image paths should be relative to the plugin root, so no leading '/':

exitAction.setImageDescriptor(Activator.getImageDescriptor("icons/download.png"));

Your plugin containing the advisor code must have an icons folder containing the download.png image.

Your build.properties file must include the icons folder in the build.

greg-449
  • 109,219
  • 232
  • 102
  • 145