编辑:
我想做的是以编程方式将首选项页面添加到 Rclipse-RCP 3.7 应用程序的首选项菜单中。不幸的是,如
本文所述,这似乎无法以编程方式工作。
作为一种解决方案,我考虑创建一个特殊的插件,它将保持偏好。此插件应在其 plugin.xml 中声明所有首选项页面并自行卸载/安装以应用首选项菜单中的更改。
问题:
有没有可能
- 以编程方式更改插件自己的plugin.xml?
- 是否有可能以编程方式更新插件,从 plugin.xml 重新加载新设置?
编辑:
我想做的是以编程方式将首选项页面添加到 Rclipse-RCP 3.7 应用程序的首选项菜单中。不幸的是,如
本文所述,这似乎无法以编程方式工作。
作为一种解决方案,我考虑创建一个特殊的插件,它将保持偏好。此插件应在其 plugin.xml 中声明所有首选项页面并自行卸载/安装以应用首选项菜单中的更改。
问题:
有没有可能
It would be helpful to understand the problem you are trying to solve, instead of what you are doing.
In general, there's no easy way to do what you want.
You can force a reload of your plugin.xml by using OSGi to uninstall and re-install your bundle. See org.osgi.framework.Bundle.uninstall()
. But depending on the extensions contributed by the plugin.xml, not extension point consumers are written to be dynamic aware.
The other option for an RCP app is to contribute extensions using org.eclipse.core.runtime.IExtensionRegistry.addContribution(InputStream, IContributor, boolean, String, ResourceBundle, Object)
. This is great for dynamic additions, it's less reliable for removing extensions, and the same caveat applies (how dynamic-aware is the consumer of the extension point). You use it in RCP apps by setting the user token to null.