带对象参数的 RCP 命令

发布于 2024-09-16 05:19:12 字数 408 浏览 4 评论 0原文

我想在代码中调用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清旖 2024-09-23 05:19:12

使用 ParameterizedCommand.generateCommand()。您可以传递命令对象(从 ICommandService 获取)和映射中的参数。

Use ParameterizedCommand.generateCommand(). You can pass the command object (obtained from ICommandService) and the parameters in a map.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文