我有一个动态创建菜单贡献的类:

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
...
 }
...
}

这不适用于Eclipse Juno . 调用 command.define(...)MakeHandlersGo 处理程序替换指定的处理程序,菜单贡献保持禁用(但显示它们) .

我试图在 command.define(...) 之后调用 command.setHandler(...) ,它启用了菜单贡献,但点击它们会抛出:

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

上面的代码工作(显示菜单贡献并单击它使处理程序执行其操作) OK for any other Eclipse version tried (Indigo,Kepler,Luna,Mars) .

这在我看来是Eclipse IDE中的一个错误,但我无法找到Juno报告的任何相关问题 . Eclipse Juno是否需要一些特定的方式来动态创建菜单贡献?