Adding popup menu submenu similar to New Child [message #867606] |
Tue, 01 May 2012 11:35 |
Mikal Hitsøy Henriksen Messages: 3 Registered: May 2012 |
Junior Member |
|
|
Hey, I'm extending another EMF-based plugin (ePNK if anyone's interested, can't link because of new account), and I want to extend the right-click menu in the tree editor with a dynamic sub-menu similar to the New Child and New Sibling menus. It will be called something like New Annotation, and it is supposed to contain entries for adding child entities with different pre-set attributes, with the available attributes depending on the selected entity, and also depending on sets of annotations the user has loaded. I know roughly how to generate which entries to make available in the submenu, but I can't figure out the right way to actually contribute it to the popup menu.
I've successfully used the org.eclipse.ui.popupMenus extension point to add individual static commands to a static submenu, but I don't see how this can be made to populate it dynamically. I can't add all possible entries, since the user is able to define new annotations.
If I was providing my own editor I could modify contributeToMenu in my EditingDomainActionBarContributor, but since I'm extending the ePNK editor I can't override its contributeToMenu, or at least I don't know how. Or somehow hook into the menu it contributes to. I believe this is the right area to look for the solution, though.
Any suggestions? Thanks
|
|
|
|
Re: Adding popup menu submenu similar to New Child [message #867910 is a reply to message #867606] |
Tue, 01 May 2012 14:47 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Mikal,
Comments below.
On 01/05/2012 1:35 PM, Mikal Hitsøy Henriksen wrote:
> Hey, I'm extending another EMF-based plugin (ePNK if anyone's
> interested, can't link because of new account), and I want to extend
> the right-click menu in the tree editor with a dynamic sub-menu
> similar to the New Child and New Sibling menus. It will be called
> something like New Annotation, and it is supposed to contain entries
> for adding child entities with different pre-set attributes, with the
> available attributes depending on the selected entity, and also
> depending on sets of annotations the user has loaded. I know roughly
> how to generate which entries to make available in the submenu, but I
> can't figure out the right way to actually contribute it to the popup
> menu.
It's not an EMF question. You can look at what we've done with JFace as
an example.
>
> I've successfully used the org.eclipse.ui.popupMenus extension point
> to add individual static commands to a static submenu, but I don't see
> how this can be made to populate it dynamically. I can't add all
> possible entries, since the user is able to define new annotations.
Look at how we use the action bar contributor.
>
> If I was providing my own editor I could modify contributeToMenu in my
> EditingDomainActionBarContributor, but since I'm extending the ePNK
> editor I can't override its contributeToMenu, or at least I don't know
> how.
If their editor isn't extensible, I'm not sure there's a way.
> Or somehow hook into the menu it contributes to. I believe this is the
> right area to look for the solution, though.
> Any suggestions? Thanks
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: Adding popup menu submenu similar to New Child [message #1088796 is a reply to message #868461] |
Sat, 17 August 2013 17:32 |
Phil H Messages: 267 Registered: November 2012 |
Senior Member |
|
|
After a lot of searching I found this thread which was really helpful!!
Due to Mikal hints, I was able to create my own menuContribution through the org.eclipse.ui.menus extension point as youc an see in the image (import is the one I added).
I'm wondering now how I can place it on a different section (maybe before Validate). Using ?before/after=additions is the only one which works, so I reckon additions (like Wizards, Run as..) is contributed by Eclipse and the above (undo, cut, copy) is contributed by emf?
Edit: I've seen that you can call the super constructor of the generated ActionBarContributor with a style bit. org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor.menuAboutToShow(IMenuManager menuManager) seems to be the method where the order is determined. Is there a way to alter this and maybe remove additions?
Using ?after=redoAction for example didn't work which was wondering me.
Furthermore I haven't found a way to add my own menu item to an existing one (e.g. as child menu item for New Child). Is this possible. Using the Spy tool hasn't give me a hint.
Cheers,
Phil
[Updated on: Sat, 17 August 2013 18:01] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03371 seconds