how to add context menu through java
I want to add a context(Right Click开发者_StackOverflow like open) menu in Eclipse plugin development through Java.I am able to do it through Plugin.xml but i want to add through Java.What is the way to do it?
I usually prefer to use either the class
attribute of the menuContribution
or alternatively the dynamic
element... Using these, means you will have all you contributions in just one place...
If you really want to use Java, have a look at the interface of MenuManager
. You simply add your context menu as always and the add the menu items using add(IContributionItem)
(and possibly add(Action)
).
There are a long list of IContributionItem
implementations to get inspired from. Some of the more interesting are:
CommandContributionItem
- used to add a command as declared with thecommands
extension pointControlContribution
- as a way to add anyControl
to a toolbarCompoundContributionItem
- a way to compute the contributions late
精彩评论