【问题标题】:Eclipse RCP Can't Contribute to Main ToolbarEclipse RCP 无法对主工具栏做出贡献
【发布时间】:2016-03-04 18:45:58
【问题描述】:

通过在 WorkbenchWindowAdvisor#preWindowOpen 中设置 configurer.setShowCoolBar(true),我的 RCP 应用程序可以看到酷栏。但是当我向主工具栏贡献一个工具栏时,它永远不会出现。这是我的贡献代码:

<extension point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="true"
            locationURI="toolbar:org.eclipse.ui.main.toolbar">
         <toolbar id="toolbar.perspectivesDynamic">
            <dynamic
                  class="my.package.PerspectiveSwitcherToolbar"
                  id="perspectiveSwitcherToolbar">
            </dynamic>
         </toolbar>
      </menuContribution>
</extension>

还有ContributionItem 类:

public class PerspectiveSwitcherToolbar extends ContributionItem {
    ...

    @Override
    public void fill(final ToolBar parent, int index) {
        //Does not get called
    }

    @Override
    public void fill(CoolBar parent, int index) {
        //Does not get called
    }
    ...
}

我正在使用this code 添加自定义透视切换器。它相当旧,但我在互联网上到处都能看到将这样的工具栏添加到主工具栏的示例,所以我想念别的东西

【问题讨论】:

    标签: eclipse-rcp toolbar perspective


    【解决方案1】:

    我认为 bug 392457: &lt;toolbar&gt;&lt;dynamic&gt;&lt;/toolbar&gt; 目前不起作用。您可以通过使用 &lt;control&gt; 并自行管理内容来解决此问题。

    【讨论】:

    • 谢谢。我根据错误中的解决方法实现了它。它可以工作,但我无法让工具栏显示更新。在 WorkbecnhWindowControlContribution 的填充方法中,我在 createControl 中创建的父级上创建了一个 Toolbar。当应用程序加载时,我成功填充了工具栏。但是后来当我想将一个项目添加到我调用填充的工具栏时,我看到它添加了该项目,但在我重新启动应用程序之前,工具栏不会显示新项目。我尝试在工具栏及其父级上调用更新和布局。在 WorkbecnhWindow 上也称为 updateActionBars。如何让工具栏更新?
    猜你喜欢
    • 2011-02-18
    • 2012-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-04
    • 2011-06-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多