Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[egit-dev] Submenu in Team context menu?

Hi all,
 
I have spent a couple of hours trying to add a submenu to the Team context menu, but to no avail. Perhaps someone can help (or confirm that it is in fact impossible to do).
 
What I tried was the following:
 
1. First approach: adding a “menu” element
I added a “menu” element to the popupMenu extension like this:
 
   <extension point="org.eclipse.ui.popupMenus">
      <objectContribution id="org.eclipse.egit.ui.projectContributions"
            objectClass="org.eclipse.core.resources.IProject"
            adaptable="true">
         <filter name="projectPersistentProperty"
               value="org.eclipse.team.core.repository=org.eclipse.egit.core.GitProvider">
         </filter>
         <menu
               id="org.eclipse.egit.ui.transportSubMenu"
               label="GitSubMenu"
               path="test">
            <groupMarker
                  name="group1">
            </groupMarker>
         </menu>
         ...
 
This works fine (and I also can add actions to that submenu), except that the submenu appears in the toplevel context menu and not in the Team sub-menu.
Obviously, the "path" attribute must be set properly, but using "team.main/group1", "menu:team.main" or some other combinations resulted in an Error when opening the context menu saying something like
 
Plugin 'org.eclipse.egit.ui' invalid Menu Extension (Path 'team.main' is invalid): org.eclipse.egit.ui.transportSubMenu
 
The trouble seems to be that the menu manager that tries to add the contribution can not find the "team.main" submenu (which is probably because the team.main submenu is itself implemented using the "objectContribution" extension).
 
2. Second approach: Adding an "action" element and trying to dynamically instantiate a sub-menu
This is possible by letting the implementation class implement IActionDelegate2, as this provides the "run"-event into the run() method as parameter. The event provides the current MenuItem and location, so it is possible to create a context menu at the right location.
 
The plugin.xml snippet looks like this:
 
         <action
               class="org.eclipse.egit.ui.internal.actions.TransportSubMenu"
               id="org.eclipse.egit.ui.action1"
               label="Advanced"
               menubarPath="team.main/group1"
               style="push">
         </action>
 
 
There are two problems, though: when the new "Advanced" action is clicked, the context menu is closed and the generated sub-menu is opened; instead, the generated sub-menu should be cascaded under the "Advanced" menu.
So I changed the "style" from "push" to "pulldown". This renders the "Advanced" item correctly, but unfortunately, now the run() method is never called, so I get no chance to contribute the sub-menu programmatically... And I didn't find a way to add it statically in plugin.xml, either...
 
Am I simply missing the point where/when to implement creation of the submenu or is this not supported?
 
Thanks for any help,
Mathias
 

Back to the top