我有这个问题:我的Eclipse插件中有一个菜单项。它有一个扩展AbstractHandler
并覆盖execute()
的处理程序,它带有ExecutionEvent
个参数。
现在我想做的是在发生特定事件时触发此功能。有人可以告诉我怎么做吗?
我想我必须以某种方式自己创建一个ExecutionEvent
?
答案 0 :(得分:4)
您可以使用IHandlerService
执行处理程序处理的命令,该命令将调用您的处理程序:
IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
handlerService.executeCommand("command id", event);
如果您需要传递命令参数,还有executeCommand
的另一种变体需要ParameterizedCommand
。