Skip to content

How to put a dynamic drop-down list in Eclipse Kepler toolbar?

I’m working on an Eclipse plug-in.

With Indigo, a drop-down list in the toolbar like the one below works perfectly.

Drop-down list in the toolbar, the currently selected item is shown when the list isn’t open

It is built like this (where the MyList instance is dynamically constructed):

  (menuContribution) locationURI : toolbar:org.eclipse.ui.main.toolbar
    Functions (menu) id : xxxx
      (dynamic) id : yyyyyyy
        class MyList extends ContributionItem

However, this doesn’t work on Kepler, and it’s difficult to understand why. While I can write a dynamic drop-down list which work in main menu (, my list with the same code doesn’t appear if locate it in toolbar (toolbar:org.eclipse.ui.main.toolbar?additions).

How can I create a drop-down list like the one in the screenshot above in Eclipse Kepler’s toolbar, and handle events when items are clicked?


This seems to be a compatibility issue in Eclipse 4.x. I can already reproduce the problem in a very simple example. I reported this as [a bug] you can vote on this bug if you like.

EDIT: Eclipse committer Paul Webster confirms that this doesn’t work yet. It may be possible to work around this by using instead of and extending WorkbenchWindowControlContribution instead of ContributionItem.

EDIT: SlowStrider’s bug (427475) was closed as duplicate of bug 392457; so if you want to vote on this issue, vote here: The older bug (392457) is fairly old and has only one vote. (M.)