私はEclipse用のカスタムエディタを持っています。特別な理由から、このエディタは、エディタ用のeclipseによって提供される標準のアクションバーに基づいていない2つのツールバー領域を提供します。この2つの場所は他のプラグインが貢献するために用意されています。私の意図は、カスタムのmenuContribution/locationURI
を持つ "org.eclipse.ui.menus"拡張ポイントを利用して、他のプラグインがこの拡張子を使って貢献でき、toolbar:my.editor.toolbar1
とtoolbar:my.editor.toolbar2
をlocationURI
として関連付けます。既存のorg.eclipse.ui.menus拡張機能を活用したツールバーの作成
私の問題は、ツールバーを特定の場所に「接続」する方法です。私はアプローチに従いましたが、結果は良くありません。私はカスタムToolbarContributionRoot
イベントを作成してください。CustomContributionFactory
を作成してExtensionContributionFactory
を作成してください。それはかなりうまくいくが、問題は、サブメニューが正しく解決されていないプルダウンコマンドである。 「ユーザー」の
toolbarManager = new ToolBarManager(SWT.FLAT);
ToolbarContributionRoot toolbarRoot = new ToolbarContributionRoot(toolbarManager);
IServiceLocator workbench = PlatformUI.getWorkbench();
IConfigurationElement[] allMenuElements
= Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.ui.menus");
for (IConfigurationElement menuContribution : allMenuElements) {
String locationURI = menuContribution.getAttribute("locationURI");
if ("toolbar:my.editor.toolbar1".equals(locationURI)) {
try {
ExtensionContributionFactory factory = CustomContributionFactory.create(menuContribution);
factory.createContributionItems(workbench, toolbarRoot);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
toolbar = toolbarManager.createControl(root);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, false, false, 1, 1);
toolbar.setLayoutData(gridData);
toolbar.pack();
のplugin.xmlは、次のようになります。
<extension point="org.eclipse.ui.menus" id="my.helper.id">
<menuContribution locationURI="toolbar:my.editor.toolbar1">
<command commandId="my.editor.special.command1" />...
あなたが一緒に私のカスタムツールバーと"org.eclipse.ui.menus"
拡張子をブレンドする方法任意の提案を持っていますか?
私はこのコードを使用しようとしている、そしてそれは、コールworkbench.getService(IMenuServiceから返されるWorkbenchMenuServiceのバージョンので動作しません。 .class)に欠陥があります。欠点は、メソッドpopulateContributionManager(toolbarManager、TOOLBAR_LOCATION)が実装されておらず、その中に// TODOメッセージがあることです。この実装されていないメソッドは、org.eclipse.ui.workbench_3.104.0.v20130204_164612.jarから来ています。どのようにコードを動作させましたか? – twindham
このコードは、EclipseのIndigoリリースを使用して完全に動作します。しかし、これまでのところJunoではうまくいきません。 –