如何在运行时获取自定义Eclipse功能的版本号?
我想在透视图的标题栏中显示我正在开发的自定义Eclipse特性的版本号。有没有办法从运行时插件和/或工作台获取版本号?类似于:如何在运行时获取自定义Eclipse功能的版本号?,eclipse,eclipse-plugin,version,eclipse-pde,Eclipse,Eclipse Plugin,Version,Eclipse Pde,我想在透视图的标题栏中显示我正在开发的自定义Eclipse特性的版本号。有没有办法从运行时插件和/或工作台获取版本号?类似于: Platform.getBundle("my.feature.id").getHeaders().get("Bundle-Version"); 我们应该做到这一点 注意()它不能在插件本身的任何地方使用: this.getBundle()在对插件调用super.start(BundleContext)之前无效。 因此,如果在调用super.start()之前在构造函数
Platform.getBundle("my.feature.id").getHeaders().get("Bundle-Version");
我们应该做到这一点
注意()它不能在插件本身的任何地方使用:this.getBundle()
在对插件调用super.start(BundleContext)
之前无效。因此,如果在调用
super.start()
之前在构造函数中或在start(BundleContext)
中使用this.getBundle()
,那么它将返回null
如果失败,您可以在此处找到一个:
我使用第一个选项:
protected void fillStatusLine(IStatusLineManager statusLine) {
statusItem = new StatusLineContributionItem("LastModificationDate"); //$NON-NLS-1$
statusItem.setText("Ultima Actualizaci\u00f3n: "); //$NON-NLS-1$
statusLine.add(statusItem);
Dictionary<String, String> directory = Platform.getBundle("ar.com.cse.balanza.core").getHeaders();
String version = directory.get("Bundle-Version");
statusItem = new StatusLineContributionItem("CopyRight"); //$NON-NLS-1$
statusItem.setText(Messages.AppActionBar_18);
statusLine.add(statusItem);
}
protectedvoid fillStatusLine(IStatusLineManager状态行){
statusItem=new StatusLineContributionItem(“LastModificationDate”);//$NON-NLS-1$
statusItem.setText(“Ultima-Actualizaci\u00f3n:”);/$NON-NLS-1$
statusLine.add(statusItem);
Dictionary directory=Platform.getBundle(“ar.com.cse.balanza.core”).getHeaders();
String version=directory.get(“Bundle version”);
statusItem=新的StatusLineContributionItem(“版权”);/$NON-NLS-1$
statusItem.setText(Messages.AppActionBar_18);
statusLine.add(statusItem);
}
正如@zvikico上面所说的,公认的答案不适用于功能,只适用于插件(OSGi捆绑包,而这些功能不适用)。获取有关已安装功能的信息的方法是通过org.eclipse.core.runtime.Platform.getBundleGroupProviders()
as.VonC提供的用于检索主要eclipse版本号的版本,但不引用内部类(您应该避免这样做):
顺便说一句,这适用于插件,但不适用于功能。我不确定是否有办法获得功能的版本。更好的是:String version=Platform.getBundle(“ar.com.cse.balanza.core”).getVersion().toString();
protected void fillStatusLine(IStatusLineManager statusLine) {
statusItem = new StatusLineContributionItem("LastModificationDate"); //$NON-NLS-1$
statusItem.setText("Ultima Actualizaci\u00f3n: "); //$NON-NLS-1$
statusLine.add(statusItem);
Dictionary<String, String> directory = Platform.getBundle("ar.com.cse.balanza.core").getHeaders();
String version = directory.get("Bundle-Version");
statusItem = new StatusLineContributionItem("CopyRight"); //$NON-NLS-1$
statusItem.setText(Messages.AppActionBar_18);
statusLine.add(statusItem);
}
Platform.getBundle(PlatformUI.PLUGIN_ID).getHeaders().get("Bundle-Version");