带对象参数的 RCP 命令
我想在代码中调用 RCP 命令,如下所示:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
handlerService.executeCommand(cmdID, null);
通过相当多的代码,我可以通过组装参数化对象然后构建 ParameterizedCommand 等等来调用带有字符串参数的命令,但参数化仅允许对于字符串值,并且不能被子类化。
我真正想做的是以对象作为参数来调用命令。我该怎么做?
I want to call an RCP command in code, like this:
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class);
handlerService.executeCommand(cmdID, null);
With considerably more code, I can call the command with a string argument by assembling a Parameterization object then building a ParameterizedCommand
and so forth but Paramaterization only allows for string values, and can't be subclassed.
What I really want to do is call the command with an object as a parameter. How can I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ParameterizedCommand.generateCommand()。您可以传递命令对象(从
ICommandService
获取)和映射中的参数。Use
ParameterizedCommand.generateCommand()
. You can pass the command object (obtained fromICommandService
) and the parameters in a map.