RCP 自定义透视栏
我必须在 RCP 应用程序中自定义透视栏。在扩展选项卡中,我有这样的层次结构:
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="toolbar:org.eclipse.ui.trim.command1">
<toolbar id="thevendor.horizontalBar1">
<control
class="thevendor.MyButton"
id="thevendor.MyButton">
</control>
<control
class="thevendor.AnotherContribution"
id="thevendor.AnotherContribution">
</control>
</toolbar>
</menuContribution>
</extension>
问题是 RCP 显示带有 MyButton
、AnotherContribution
的工具栏和我不想要的透视菜单。我尝试将 IWorkbenchWindowConfigurer.setShowPerspectiveBar
设置为 false
,但整个工具栏消失了。 如何仅隐藏此透视菜单,仅显示 MyButton
和 AnotherContribution
?
I have to customize the perspective bar in an RCP application. In the extensions tab I have this hierarchy:
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="toolbar:org.eclipse.ui.trim.command1">
<toolbar id="thevendor.horizontalBar1">
<control
class="thevendor.MyButton"
id="thevendor.MyButton">
</control>
<control
class="thevendor.AnotherContribution"
id="thevendor.AnotherContribution">
</control>
</toolbar>
</menuContribution>
</extension>
the problem is that RCP display the toolbar with MyButton
, AnotherContribution
and a perspective menu that I don't want. I try to set IWorkbenchWindowConfigurer.setShowPerspectiveBar
to false
, but the whole toolbar disappears.
How to hide only this perspective menu, showing only MyButton
and AnotherContribution
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的工具栏设置可能不正确。前几天我尝试过类似的操作,但使用了错误的扩展层次结构,因此工具栏根本不起作用...
要将自定义工具栏添加到您的 RCP,请执行以下操作:
在您的
plugin.xml
,转到扩展页面。右键单击扩展org.eclipse.ui.menus
,选择新建,然后选择menuContribution。在表单中,将字段
locationURI
设置为“toolbar:org.eclipse.ui.main.toolbar”(不带引号)。右键单击您刚刚编辑的“menuContribution”,选择新建,选择工具栏。
(编辑工具栏以满足您的需要。)
右键单击新的工具栏扩展,选择新建,选择命令。。
浏览您要使用的
commandId
。然后,在您的
WorkbenchWindowAdvisor.preWindowOpen()
方法中,设置以下内容:configurer.setShowCoolBar(true);
configurer.setShowPerspectiveBar(false);
这应该有效。我希望:)。
I think you might have set up your toolbar incorrectly. I've tried something similar just the other day, and used the wrong extension hierarchy, so the toolbar didn't work at all...
To add a custom toolbar to your RCP, do the following:
In your
plugin.xml
, go to the Extensions page. Right-click the extensionorg.eclipse.ui.menus
, choose New, choose menuContribution.In the form, set the field
locationURI
to "toolbar:org.eclipse.ui.main.toolbar" (without the quotes).Right-click on the "menuContribution" you have just edited, choose New, choose toolbar.
(Edit toolbar to suit your needs.)
Right-click the new toolbar extension, choose New, choose command.
Browse for the
commandId
you want to use.Then, in your
WorkbenchWindowAdvisor.preWindowOpen()
method, set the following:configurer.setShowCoolBar(true);
configurer.setShowPerspectiveBar(false);
This should work. I hope :).