Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Adding item to existing References or Declarations context menu
Adding item to existing References or Declarations context menu [message #1578772] Thu, 22 January 2015 16:03 Go to next message
Simon Laffoy is currently offline Simon LaffoyFriend
Messages: 19
Registered: January 2015
Junior Member
I am interested in adding a new item to both the References and Declarations context menus. I am trying to use the Menu Contributions org.eclispe.ui.menus extension point, but I am struggling to find the actual locationURI. Might anyone know this, or have some lead?

Thanks
Re: Adding item to existing References or Declarations context menu [message #1580686 is a reply to message #1578772] Fri, 23 January 2015 16:55 Go to previous message
Simon Laffoy is currently offline Simon LaffoyFriend
Messages: 19
Registered: January 2015
Junior Member
OK, I found a solution to a related but different problem. I found a way, using information in this post www.nihamkin.com/2013/02/16/how-to-add-items-into-eclipse-s-refactor-menu/, to add items to the References and Declarations sub menus of the Search menu in the menu bar, although not the context menu.

Additionally this solution to that problem is quite ugly, and I'm not sure how it would handle a different plugin also making the same change. Anyway, here it is:

In the plug in for the project you need to add a new extension with an actionset. Within the actionset you must list the top level menu, in this case "Search", and within this menu you must add each of the groupMarkers and separators that actually appear in this menu item usually.

Next you add a new menu corresponding to the sub menu of the Search menu that we wish to add our new action to. In this case References. We must also include the path for the References menu which includes the name of the groupMarkers or seperator that it appears in. This groupMarkers or separator must be one of the groupMarkers or separators that we listed as appearing in the top level menu.

As with the search menu, for the References menu we must add the list of groupMarkers or separators that exist within References usually. In this case there is one separator called group1.

Finally we can add a new action corresponding to the action that we would like performed, which includes the menu bar path composed of the location of the top level menu (Search), and the list of separators we must descend to get to the desired location.


<extension
point="org.eclipse.ui.actionSets">

<actionSet
description="Index Declaration Actions"
id="Index Reference Action"
label="IndexReferences"
visible="true">

<menu
label="Search"
id="org.eclipse.search.menu">

<groupMarker name="internalDialogGroup"/>
<groupMarker name="dialogGroup"/>
<separator name="fileSearchContextMenuActionsGroup"/>
<separator name="contextMenuActionsGroup"/>
<separator name="occurencesActionsGroup"/>
<separator name="extraSearchGroup"/>

</menu>

<menu
label="References"
path="org.eclipse.search.menu/contextMenuActionsGroup"
id="referencesSubMenu">

<separator
name="group1">
</separator>

</menu>

<action
class="org.example.com.ExamplesMenuContributions"
enablesFor="*"
id="org.example.com.actions.ShortestBranchAction"
label="IndexReferences"
menubarPath="org.eclipse.search.menu/referencesSubMenu/group1"
style="push">
</action>

</actionSet>
</extension>


Anyway, I don't suppose anyone knows if something like this can be extended to the context menu?

[Updated on: Fri, 23 January 2015 19:53]

Report message to a moderator

Previous Topic:[Help] working on an apache project (spark, avro)
Next Topic:Eclipse not starting
Goto Forum:
  


Current Time: Fri Apr 26 22:22:32 GMT 2024

Powered by FUDForum. Page generated in 0.03030 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top