2016-03-04 62 views
1

我的RCP应用程序通过在WorkbenchWindowAdvisor#preWindowOpen中设置configurer.setShowCoolBar(true)可以看到冷却栏。但是,当我向主工具栏提供工具栏时,它永远不会显示出来。这里是我的贡献代码:Eclipse 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添加了一个定制透视图切换。这是比较旧,但我到处在网上看到添加这样的工具栏主工具栏上的例子,所以我失去了一些东西elsewher,我认为

回答

3

我认为这是bug 392457<toolbar><dynamic></toolbar>不会在此刻工作。您可以通过使用<control>并自行管理内容来解决此问题。

+0

谢谢。我根据bug中的解决方法实施了它。它工作除了我不能让工具栏显示更新。在WorkbecnhWindowControlContribution的fill方法中,我在createControl中创建的父级上创建一个工具栏。当应用程序加载时,我会成功填充工具栏。但后来,当我想将一个项目添加到工具栏中时,我调用了填充,我发现它添加了该项目,但是在我重新启动应用程序之前,工具栏不会显示新项目。我试图在工具栏及其父母上调用更新和布局。在WorkbecnhWindow上也称为updateActionBars。我怎样才能让工具栏更新? – MidnightJava