In eclipse plugin development, I want to add one item (eg: Mystyle ) in popup menu.
For an instance,
Project Explorer --> Right Click --> New --> MyStyle
How can I achieve this in eclipse plugin development?
Regards Mathan
In eclipse plugin development, I want to add one item (eg: Mystyle ) in popup menu.
For an instance,
Project Explorer --> Right Click --> New --> MyStyle
How can I achieve this in eclipse plugin development?
Regards Mathan
Something like this should do it (following this thread):
See Menucontribution
See also
,org.eclipse.ui.popupMenus
org.eclipse.ui.menus
-extension point with amenuContribution
that has itslocationURI
-attribute pointing topopup:org.eclipse.ui.popup.any?after=additions
.Warning, as Prashant Bhate mentions in the comment, that package
org.eclipse.ui.popupMenus
is deprecated.See question Missing link between
objectContribution
and command for more.it took me awhile to solve this exact problem just now, so I'll put up answer to OP's question (add to File->New menu).
Where to Contribute (common.new.menu)
thanks to this post, I discovered that you want to contribute to popup:common.new.menu?after=new. why, you ask? heck if I know; but it works.
Result
(When C/C++ is active perspective)
(When 'not' C/C++ as active perspective)
Here is my example plugin:
I added an important part here, the 'visibleWhen' parameter. This only shows New Root Command From Justin when in the C/C++ perspective. It turns out to be tricky to figure that out, thus my inclusion in example. Here are useful resources I dug up while researching that:
I dug up the name of the C Perspective org.eclipse.cdt.ui.CPerspective by painfully digging through the plugin.xml of the org.eclipse.cdt.ui plugin.
now if anyone could tell me how to easily look these uri/resources/properties up in the future... omg.