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