gpt4 book ai didi

eclipse - RCP 自定义透视栏

转载 作者:行者123 更新时间:2023-12-01 05:37:51 24 4
gpt4 key购买 nike

我必须在 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.setShowPerspectiveBarfalse ,但整个工具栏消失了。
如何只隐藏这个透视菜单,只显示 MyButtonAnotherContribution ?

最佳答案

我认为您可能错误地设置了工具栏。前几天我尝试过类似的东西,并使用了错误的扩展层次结构,所以工具栏根本不起作用......

要将自定义工具栏添加到 RCP,请执行以下操作:

  • 在您的 plugin.xml ,转到“扩展”页面。右键单击扩展 org.eclipse.ui.menus ,选择新建,选择菜单贡献。
  • 在表单中,设置字段 locationURI到“工具栏:org.eclipse.ui.main.toolbar”(不带引号)。
  • 右键单击您刚刚编辑的“menuContribution”,选择“新建”,选择“工具栏”。
  • (编辑工具栏以满足您的需要。)
  • 右键单击新的工具栏扩展,选择新建,选择命令。
  • 浏览 commandId你想用。
  • 然后,在您的 WorkbenchWindowAdvisor.preWindowOpen()方法,设置如下:
    configurer.setShowCoolBar(true);configurer.setShowPerspectiveBar(false);

  • 这应该有效。我希望 :)。

    关于eclipse - RCP 自定义透视栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7677883/

    24 4 0