パースペクティブのタイトル バーに開発中のカスタム Eclipse 機能のバージョン番号を表示したいと考えています。ランタイム プラグインやワークベンチからバージョン番号を取得する方法はありますか?
5332 次
4 に答える
6
何かのようなもの:
Platform.getBundle("my.feature.id").getHeaders().get("Bundle-Version");
トリックを行う必要があります。
(このスレッドから)プラグイン自体のどこでも使用できないことに注意してください:プラグインでAFTERが呼び出される
this.getBundle()まで有効ではありません。
したがって、コンストラクター内または呼び出す前に内で使用している場合は、nullが返されます。super.start(BundleContext)this.getBundle()start(BundleContext)super.start()
それが失敗した場合は、ここにもっと完全な「バージョン」があります:
public static String getPlatformVersion() {
String version = null;
try {
Dictionary dictionary =
org.eclipse.ui.internal.WorkbenchPlugin.getDefault().getBundle().getHeaders();
version = (String) dictionary.get("Bundle-Version"); //$NON-NLS-1$
} catch (NoClassDefFoundError e) {
version = getProductVersion();
}
return version;
}
public static String getProductVersion() {
String version = null;
try {
// this approach fails in "Rational Application Developer 6.0.1"
IProduct product = Platform.getProduct();
String aboutText = product.getProperty("aboutText"); //$NON-NLS-1$
String pattern = "Version: (.*)\n"; //$NON-NLS-1$
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(aboutText);
boolean found = m.find();
if (found) {
version = m.group(1);
}
} catch (Exception e) {
}
return version;
}
于 2009-05-03T17:54:59.700 に答える
1
私は最初のオプションを使用します:
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);
}
于 2011-12-02T16:13:07.480 に答える
0
@zvikicoが上で述べたように、受け入れられた回答は機能では機能せず、プラグイン(機能ではないOSGiバンドル)のみで機能します。インストールされている機能に関する情報を取得する方法は、こちらで説明されorg.eclipse.core.runtime.Platform.getBundleGroupProviders()ているとおりです。
于 2013-03-13T20:14:03.600 に答える