Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Defining a dynamic context submenu
Defining a dynamic context submenu [message #1661217] Mon, 09 March 2015 14:30 Go to next message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Member
Hi everyone, another question about context menus.

I would like to define a context menu item enabling to display a submenu whose contents are populated dynamically, typically to easily create dynamic menus such as in the "Create child" and "Create sibling" menu items in the EMF-generated editor's context menu.

It is possible to define such dynamic menu items with Sirius ?

Thanks in advance,

François
Re: Defining a dynamic context submenu [message #1661256 is a reply to message #1661217] Mon, 09 March 2015 14:52 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

Among the tools available in Sirius, create a new "Popop menu". Set the
name of your parent context menu as the ID or Label of this tool.
Then create an operation action for each submenu action you need. In the
precondition field, write a boolean expression that should be true if
you want to display this contextual action for the selected element.

Regards,
Steve

Le 09/03/2015 15:30, Francois Cabrol a écrit :
> Hi everyone, another question about context menus.
>
> I would like to define a context menu item enabling to display a
> submenu whose contents are populated dynamically, typically to easily
> create dynamic menus such as in the "Create child" and "Create sibling"
> menu items in the EMF-generated editor's context menu.
>
> It is possible to define such dynamic menu items with Sirius ?
>
> Thanks in advance,
>
> François


--
Steve Monnier - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Defining a dynamic context submenu [message #1661293 is a reply to message #1661256] Mon, 09 March 2015 15:12 Go to previous messageGo to next message
Francois Cabrol is currently offline Francois CabrolFriend
Messages: 32
Registered: January 2015
Member
Thank you very much, this approach should work with the examples I mentioned.

I also would like to know if there is a way to handle a dynamic menu in case its contents can only be known at runtime, for example if the menu items depend on the contents of the edited model.

François
Re: Defining a dynamic context submenu [message #1661396 is a reply to message #1661293] Mon, 09 March 2015 16:06 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
I might be missing a point, but I guess this only add some condition on
your expression, like checking the number of children (eContents()->size
< x) or if a certain feature starts with a certain prefix
(featureName.startsWith("prefix")). If the expression is too complex you
can use a java service.

Regards,
Steve

Le 09/03/2015 16:12, Francois Cabrol a écrit :
> Thank you very much, this approach should work with the examples I
> mentioned.
>
> I also would like to know if there is a way to handle a dynamic menu
> in case its contents can only be known at runtime, for example if the
> menu items depend on the contents of the edited model.
>
> François


--
Steve Monnier - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Defining a dynamic context submenu [message #1665060 is a reply to message #1661293] Wed, 11 March 2015 04:33 Go to previous message
khanh tran is currently offline khanh tranFriend
Messages: 8
Registered: November 2014
Junior Member
hello,

You can contribute your popup menu programmatically by using org.eclipse.ui.menus.

Using this ID: popup:org.eclipse.gmf.runtime.diagram.ui.DiagramEditorContextMenu for locationURI property of menuContribution
Previous Topic:Label Position of BorderItems
Next Topic:Deploy DSL
Goto Forum:
  


Current Time: Fri Apr 19 07:52:45 GMT 2024

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

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

Back to the top