如何获取plugin.xml中定义的资源



一个bundle,获取org.eclipse.ui.views扩展点的viewpart图标

通过iconfigationelement
只能获得一个字符串,例如:(icons/full/obj16/julaunch.png)

但是我不能得到它的bundle,而且我不能拼接一个类似的URL
例如。(平台:/plugin/org.eclipse.unittest.ui/icons/full/obj16/julaunch.png)

我该怎么办?

如果您有一个IContributionElement,并希望在元素中获得属性所提供的资源,您可以这样做:

String pluginId = element.getContributor().getName();
Bundle bundle = Platform.getBundle(pluginId);
String path = element.getAttribute("attribute id");
URL url = FileLocator.find(bundle, new Path(path), null);

最新更新