带对象参数的RCP命令 [英] RCP Command with object argument
问题描述
我想在代码中调用RCP命令,如下所示:
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);
有了更多的代码,我可以通过组装一个参数化对象然后使用一个字符串参数来调用命令 ParameterizedCommand
等,但是参数化仅允许字符串值,并且不能被子类化。
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?
推荐答案
使用 ParameterizedCommand.generateCommand()
。您可以传递命令对象(从 ICommandService
获取)和地图中的参数。
Use ParameterizedCommand.generateCommand()
. You can pass the command object (obtained from ICommandService
) and the parameters in a map.
这篇关于带对象参数的RCP命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!