【问题标题】:Is it possible to get the Feature label name by passing the Plugin Name/ID是否可以通过传递插件名称/ID 来获取功能标签名称
【发布时间】:2017-10-01 06:41:11
【问题描述】:
我正在尝试在卸载插件时获取特定插件的功能名称。我可以使用以下代码获取所需的插件名称和版本。
IRequirement iRequirement = (IRequirement) iterator.next();
String[] arr = iRequirement.toString().split("\\[|\\]|\\s+");
IVersionedId versionedId = new VersionedId(arr[0].trim(), arr[1].trim());
但是,我想在传递插件 ID 或名称时获取功能名称
【问题讨论】:
标签:
java
eclipse
eclipse-plugin
osgi
eclipse-rcp
【解决方案1】:
如果您知道插件名称,可以说"com.my.plugin",您可以使用类似这样的名称来获取功能名称。它存储在Bundle内的字典中
Bundle bundle = Platform.getBundle( "com.my.plugin" );
String featureName = bundle.getHeaders().get( org.osgi.framework.Constants.BUNDLE_NAME );
事实上你也可以得到类似的版本:
Version version = bundle.getVersion();