RCP自定义透视栏

时间:2011-10-06 17:02:55

标签: eclipse eclipse-plugin eclipse-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使用MyButtonAnotherContribution和我不想要的透视菜单显示工具栏。我尝试将IWorkbenchWindowConfigurer.setShowPerspectiveBar设置为false但整个工具栏都会消失。 如何仅隐藏此透视图菜单,仅显示MyButtonAnotherContribution

1 个答案:

答案 0 :(得分: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);

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

相关问题