Menu contribution for popupsubmenu? - eclipse

In eclipse plugin development i could add files in toolbar, menu and popupmenu by using menu contribution.
In my project I want to add a set of files in the popupsubmenu,
eg : Like the following
Project Explorer -> Right Click -> New -> Annotation, Class, Enum ....
I want to add my files abc,def and xyz.. under the new menu item
What is the locationuri for popupsubmenu ?
Help me on this
Thanks in advance
Regards
Mathan

For the first part, see "How to add items in popup menu?" (from justinmreina) for more on adding an entry to a menu.
Note the second part of this answer is for package explorer.
For project explorer, the location uri would be:
menu:common.new.menu?after=new
(Example, but for package explorer)
Something like (if you follow this thread):
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:new?after=myGroup1">
<command
commandId="com.mycpy.myproject.ui.pluginXX.commands.openNewWizard"
disabledIcon="icons/disabled/new.gif"
icon="icons/enabled/new.gif"
id="com.mycpy.myproject.ui.pluginXX.menus.openNewWizard"
label="PluginXX"
tooltip="PluginXX"
mnemonic="XX">
</command>
</menuContribution>
</extension>
I would use as locationuri:
menu:new?after=additions
(no need to define a custom group here)
See also Wiki "Menu Contributions"

Related

How to create a context menu before Eclipse Import menu item in Eclipse Plugin development

I want to add a new menu just before Eclipse Import... menu. I am able to create a context menu item, but I want to place it before Import.... I provide below the code snippet from plugin.xml.
<menuContribution
locationURI="popup:org.eclipse.ui.popup.any">
<menu
icon="icons/someIcon.png"
id="com.sample.app.sampleMenu"
label="PathXplorer">
<command
commandId="com.sample.app.commands.actionid"
icon="icons/someIcon.png"
id="ccom.sample.app.menus.action1Id"
label="Some Good Label">
</command>
</menu>
</menuContribution>
For more clarity, you can see below the image. My menu will be Sample Action Menu which should be visible before import. Please help me to resolve.
The id of the Import menu item seems to be import so your can specify you menu contribution position using the relative position in the locationURI:
locationURI="popup:org.eclipse.ui.popup.any?before=import">

Add menu item for Import/Export context menu in Eclipse

I'm trying to add a submenu to Import and Export items in Project-Explorer's context menu. But, I can't find the menuid/locationURI of those items on the menu.
Can someone please help me to add items to these Import/Export menu items in Eclipse. I'm using Oxygen version. I tried the below segment, but it adds the item under the import/export items.
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=addition">
<command
commandId="myplugin.command.mycommand"
icon="icons/etool16/mycommand.png"
label="Run mycommand"
mnemonic="M1+P"
tooltip="Do something with this project">
</command>
</menuContribution>
</extension>
You don't add your own actions because they're not menus. Instead, Import and Export Wizards have their own extension points so that you can start them via the main Import/Export wizards.
I'm a bit confused how you have an Import menu in your context menu.

Open another editor from the eclipse search view

I have a file which can be edited using two different editors.
In eclipses' project explorer you can open a file in a different editor from the context menu.
How can I open a search result (shown in the Search view) in a different editor?
As I am developing an own plug-in, a way to extend the Search view's context menu would be a valid solution as well.
I don' think there is a way to get the search view to use a different editor.
You can contribute to the search view using the org.eclipse.ui.menus extension point. The view id is org.eclipse.search.ui.views.SearchView so something like:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="popup:org.eclipse.search.ui.views.SearchView">
<command
commandId="my.command.id"
label="Test Search View Contrib"
style="push">
</command>
</menuContribution>

Eclipse plug-in: why doesn't my menu contribution show up after using a shortcut?

I wanted to add a menu item to the Source popup, and I got it working with the following plugin.xml fragment:
<menuContribution allPopups="true" locationURI="popup:org.eclipse.jdt.ui.source.menu">
<command
commandId="pl.axit.eclipse.bundle.commands.convertToBundle"
id="pl.axit.eclipse.bundle.menus.convertToBundle"
label="Extract bundle" >
</command>
</menuContribution>
And it works after I click the right mouse button and then select Source I can see my Extract bundle item. Great.
But... when I open the Source menu with a shortcut (alt+shift+s) then my Extract Bundle isn't there! Any idea why and how to make it appear after using the shortcut?

How to add a submenu entry to Eclipse Package Explorer context menu item using org.eclipse.ui.menus?

I am trying to add a submenu entry to an item from the context menu of the Eclipse Package Explorer.
The menu entry is already defined via org.eclipse.ui.popupMenus in another plugin, not in the one that I am working at. (That plugin is added to the dependencies list of my plugin). There are also items added in its submenu, but also using org.eclipse.ui.popupMenus, and I am trying to do this via org.eclipse.ui.menus.
To begin with, I did the following:
I added org.eclipse.ui.commands and org.eclipse.ui.menus extensions.
I defined a command , respectively a menuContribution like this:
This adds the item in any context menu... So I would have to replace "org.eclipse.ui.popup.any?after=additions" from the locationURI with the id of the submenu I want my item to appear in.
My problem is: how to determine a correct locationURI?
I used the menu spy (ALT+SHIFT+F2) and inspected the submenu I want to contribute to, and I received the following URI:
menu:YYY?after=ZZZ, where:
YYY is the id of the menu that is already defined and to which I want to add the submenu item
ZZZ is the id of the action from the submenu, that I clicked upon (using the spy)
I tryied the following, but the submenu item does not appear:
menu:YYY[?after=additions]
popup:YYY[?after=additions]
Please help :)
I managed to make it work by defining a new menu contribution and a menu having the same id and label as the menu already defined. The final solution looks like this:
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<menu
id="YYY"
label="%YYYs_label">
</menu>
</menuContribution>
<menuContribution
locationURI="popup:YYY?after=additions">
<command
commandId="example.MyCommandHandlerID"
icon="icons/somePhoto.gif"
label="MyLabel"
style="push">
</command>
</menuContribution>
</extension>