为现有的eclipse插件添加无头功能 [英] Add headless capability to existing eclipse plugin

查看:74
本文介绍了为现有的eclipse插件添加无头功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的Eclipse插件,可以作为常规的IDE插件运行,从GUI接收命令并在自定义视图中返回输出。

I have an existing Eclipse plugin which run as a regular IDE plugin, receiving commands from the GUI and returning output in custom views.

我想添加一个功能还可以 以无头模式运行该插件,并且从命令行接收到输入,并且输出进入某个文件。除了现有的常规执行方式之外,是否可以通过某种方式修改现有插件以支持该执行方式,还是我必须创建一个新的无头插件并仅使用第一个插件的代码? / p>

I want to add an ability to also be able to run that plugin in headless mode, with the input received from the command-line and the output going to some file. Is there some way of modifying the existing plugin to support that mode of execution in addition to the existing regular execution, or do I have to create a new headless plugin and just use code from the first one?

推荐答案

这取决于您计划使用此插件的方式以及主要问题:在某些情况下,您的UI依赖项不会是否可用,即是否有没有SWT和RCP捆绑包的捆绑包配置?

It depends on how you plan to use this plugin and the main question: is there a case, where your UI dependencies will not be available, i.e. whether there is a bundle configuration without SWT and RCP bundles?

没有可用的UI

在这种情况下,您需要将插件的无头部分提取到新插件中,然后向其注册无头入口点。插件的UI部分将依赖于新插件,并将UI请求委托给无头部分中的相应API。

In this case, you'll need to extract the headless part of your plugin into new plugin, which then registers the headless entry point to it. The UI part of the plugin will depend on the new plugin and just delegate UI requests to the appropriate API in the headless part.

为了提供无头应用程序,您应该分别查看 org.eclipse.equinox.app.IApplication 接口和 org.eclipse.equinox.applications 扩展名点。定义应用程序后,只需调用以下内容即可启动它:

In order to provide headless application, you should take a look at org.eclipse.equinox.app.IApplication interface and respectively org.eclipse.equinox.applications extension point. When you've defined the application, you launch it by simply invoking:

eclipse -application< app-id> < app-param>

更多信息,请参见 Eclipse帮助

可用的用户界面

更简单的情况。只需要指定无头入口点,一切就可以像以前一样工作。

The simpler case. Only the headless entry point needs to be specified and everything will work as previously.

但是,我的经验表明,迟早会出现这种情况,即插件需要被拆分,并且取决于其复杂性,与之前拆分相比,它可能会引起更多的麻烦。

My experience, however, shows that sooner or later, the case arise where the plugin needs to be split and depending on its complexity it might cause more trouble than it would have been if it was split earlier.

这篇关于为现有的eclipse插件添加无头功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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