Eclipse RCP Can't Contribute to Main Toolbar

那年仲夏 提交于 2019-12-11 12:42:48

问题


My RCP app has the coolbar visible by setting configurer.setShowCoolBar(true) in WorkbenchWindowAdvisor#preWindowOpen. But when I contribute a toolbar to the main toolbar, it never shows up. Here's my contribution code:

<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>

And the ContributionItem class:

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
    }
    ...
}

I'm using this code for adding a custom perspective switcher. It's rather old, but I see examples everywhere on the Internet adding a toolbar like this to the main toolbar, so I'm missing something elsewher, I assume


回答1:


I think that is bug 392457: <toolbar><dynamic></toolbar> doesn't work at the moment. You can work around it by using a <control> and managing the contents yourself.



来源:https://stackoverflow.com/questions/35803734/eclipse-rcp-cant-contribute-to-main-toolbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!