问题描述
我正在开发几个Eclipse功能部件(构成可安装单元的Eclipse插件组),并且我被要求每个功能部件必须具有被停用的能力,或者换句话说,必须使其不能启动.Eclipse启动时.
I'm developing several Eclipse Features (groups of Eclipse plugins that form an Installable Unit), and I've been given the requirement that each Feature must have the ability to be deactivated, or in other words, made to not start when Eclipse is started.
我有一个可以为UI做出贡献的插件(Perspective,向导,菜单项等),并且我试图像这样拦截拦截该插件的start方法的调用...
I have a plugin that makes contributions to the UI (Perspective, Wizards, Menu items, etc), and I've tried to just intercept the call to the start method of the plugin like so...
请注意,类PluginVerification在另一个插件中运行,该插件将随包含我要停止的插件的Feature安装一起提供.换句话说,我的功能由插件A,B和C组成.PluginVerification位于C中,我想用它来控制插件A和B的启动.
Please note that the class PluginVerification is running in another plugin that will be delivered with the installation of the Feature that contains the plugins that I want to stop. In other words, my Feature consists of Plugins A, B, and C. PluginVerification lives in C, and I want to use it to control the starting of Plugins A and B.
这是插件A和B的Activator类的启动方法
Here's Plugin A and B's Activator class's start method
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
if(PluginVerification.verify(this)) {
super.start(context);
plugin = this;
}
}
如果对PluginVerification.verify(this)的调用返回false,那么我不会启动插件.之所以有效,是因为该插件确实无法启动,但是仍然显示此插件贡献的UI工件.例如,仍然可以通过UI访问此插件提供的向导.但是,当您尝试使用其中之一时,会抛出NullPointerExceptions,因为该插件从未启动.
If the call to PluginVerification.verify(this) returns false, then I don't start the plugin. This works half way, because the plugin truly does not start, but there are UI artifacts that were contributed by this plugin that still show up. For example, the wizards that this plugin contributes are still accessible via the UI. But when you try to use one of them, NullPointerExceptions are thrown because the plugin never started.
我希望有人能够帮助我找到一个更好的位置,以真正阻止插件启动,从而完全不影响UI工件.我打算警告用户,他的产品尚未验证,因此无法启动.我希望用户感觉到该功能似乎已经从他的Eclipse环境中消失了.
I was hoping someone could help me find better place to truly stop a plugin from starting so that it won't contribute it's UI artifacts at all. I'm planning to alert the user that his product isn't verified, and therefore could not be started. I want the user to feel as if the Feature has simply disappeared from his Eclipse environment.
谢谢您的考虑,跟踪
推荐答案
我认为 p2导演.至于为什么某些工件可用的原因,可能是因为您的插件已安装(您可以使用osgi控制台进行检查)但尚未启动..
I think you will have better luck with p2 director. As to why some artifacts are available, probably because your plugins are installed (you can check with osgi console) but are not started..
这篇关于安装Eclipse Feature后如何停止启动它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!