Reputation: 1643
I have a problem with the context menu in Eclipse Juno. I have a class extending the ContributionItem
class. This creates menu items. Each menu item has an index. But I don't know, what value have the index to contain and how should it behave. I suppose, that it should insert items on the position. E.g. I have contribution URI:
popup:org.eclipse.jdt.ui.PackageExplorer?before=common.new.menu
Then is my fill(Menu menu, int index)
method invoked with 0 as index, because common.new.menu
is the first item. But always the New menu item (which is the firs one in the pop-up menu) disappears and when I'm right-clicking second time, the pop-up menu gets shrunk and contains separators and few items (including my items) only. I'm totally lost...
Note: When a resource has been clicked, the fill()
method is always called twice.
Upvotes: 2
Views: 81
Reputation: 1643
Heureka! Googling for a long time have I found it. Somebody noted in one discusion, that there is also important to override the isDynamic()
method defined in ContributionItem
class. The default implementation always returns false. In Indigo it usually does not matter, but Juno is a bit stricter. In own contribution item is necessary to override the isDynamic()
method to make it returning always true.
Upvotes: 2