1

I have a class that creates some menu contributions dynamically:

public class DynamicHelpMenuFactory extends ExtensionContributionFactory {
...
 public void createContributionItems(IServiceLocator sl, IContributionRoot ad) {
...
  ICommandService commandService = getCommandService();
...
  // create the command
  Command command = commandService.getCommand("com.foo.bar");
  command.setHandler(new MyHandler());
  command.define("com.foo.bar.name", "com.foo.bar.description", "category.foo.bar");
...    
  // create the menu contribution
...
 }
...
}

This does not work on Eclipse Juno. The call command.define(...) replaces the specified handler with MakeHandlersGo handler and the menu contributions remain disabled (but they are shown).

I tried to call the command.setHandler(...) after the command.define(...) which made the menu contributions enabled, but clicking on them throws:

org.eclipse.core.commands.NotHandledException: There is no handler to execute for command com.foo.bar

The code above works (the menu contribution is shown & clicking on it makes the handler to execute its action) OK for any other Eclipse version tried (Indigo, Kepler, Luna, Mars).

This seems to me as a bug in Eclipse IDE, but I was not able to find any relevant problems reported for Juno. Does Eclipse Juno need some specific way to create menu contributions dynamically?

napets
  • 133
  • 1
  • 7

0 Answers0