从其他插件执行现有插件的命令/处理程序 [英] Execute command/handler of an existing plugin from a different plugin

查看:72
本文介绍了从其他插件执行现有插件的命令/处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有现有命令和处理程序的RCP应用程序,可以通过编程方式切换透视图.而且,我还拥有现有RCP应用程序使用的新插件.我希望这个新插件执行我的RCP应用程序的命令/处理程序,对此有什么可能的解决方案?

I have an RCP application with an existing command and handler to switch perspective programmatically. And I also have and new plugin consumed by the existing RCP application. I want this new plugin to execute the command/handler of my RCP application, what can be the possible solution for this?

推荐答案

您可能需要为该命令定义一个处理程序(不确定),但是以编程方式执行命令如下所示:

You may need to define a handler for that command (not sure), but executing commands programmatically looks like this:

Command command = ((ICommandService) getSite().getService(ICommandService.class)).getCommand(commandId);
...
final Event trigger = new Event();
ExecutionEvent executionEvent = ((IHandlerService) getSite().getService(IHandlerService.class)).createExecutionEvent(command, trigger);
command.executeWithChecks(executionEvent);

这篇关于从其他插件执行现有插件的命令/处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆