Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Setting constraints for a parent node in .gmfmap to contain a fixed no. of children
Setting constraints for a parent node in .gmfmap to contain a fixed no. of children [message #124116] Fri, 04 May 2007 07:14 Go to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi friends,

How can we set node constraints for a parent node in .gmfmap to contain
only a fixed number of children's.

Please help with any useful ideas or links.

I ma posting this question here as the the newsgroup for OCL is
currently not active.Will it be reopened...???

Thanks and regards biju
Re: Setting constraints for a parent node in .gmfmap to contain a fixedno. of children [message #124129 is a reply to message #124116] Fri, 04 May 2007 07:28 Go to previous messageGo to next message
Eclipse UserFriend
Hello biju,

> How can we set node constraints for a parent node in .gmfmap to
> contain only a fixed number of children's.
Try adding constraint to the child node element like: parent.children.size()
< 10

-----------------
Alex Shatalin
Re: Setting constraints for a parent node in .gmfmap to contain a fixedno. of children [message #124154 is a reply to message #124129] Fri, 04 May 2007 08:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi Alex Shatalin,

Thanks for your reply,

I tried it ,but I am not able to access the parent by using 'parent.' ,
so how can I access the parent. Please help with any sample code
snippets if any.

Thanks and Regards biju
Alex Shatalin wrote:
> Hello biju,
>
>> How can we set node constraints for a parent node in .gmfmap to
>> contain only a fixed number of children's.
> Try adding constraint to the child node element like:
> parent.children.size() < 10
>
> -----------------
> Alex Shatalin
>
>
Re: Setting constraints for a parent node in .gmfmap to contain afixedno. of children [message #124163 is a reply to message #124154] Fri, 04 May 2007 08:16 Go to previous messageGo to next message
Eclipse UserFriend
Hello biju,

To be able to access parent you have to specify corresponding reference in
your domain model. This reference should be "opposite" to the containment
featuer from parent to child. In this case you'll be able to use it.

-----------------
Alex Shatalin
Re: Setting constraints for a parent node in .gmfmap to contain afixedno. of children [message #124175 is a reply to message #124163] Fri, 04 May 2007 08:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi Alex Shatalin,

Thanks again for your reply,

I was trying to update the model as you suggested. I tried to set the
reference of the parent to child's when they are added to the parent.
But as the generated code does not show the addChildren function by
default, how can I set this reference.

Is there any way to show the addChildren function of the parent in
generated code.

Thanks and Regards biju
Alex Shatalin wrote:
> Hello biju,
>
> To be able to access parent you have to specify corresponding reference
> in your domain model. This reference should be "opposite" to the
> containment featuer from parent to child. In this case you'll be able to
> use it.
>
> -----------------
> Alex Shatalin
>
>
Re: Setting constraints for a parent node in .gmfmap to contain afixedno.of children [message #124373 is a reply to message #124175] Mon, 07 May 2007 06:00 Go to previous messageGo to next message
Eclipse UserFriend
Hello biju,

Once more, starting with the meta-model:

Parent
- children (containmentReference)
Child
- parent (non-containmentReference)

If you set "eOpposite" property of "parent" feature to point to the "children"
then the rest will be generated for you by EMF (if you create new Child and
add it into children EList, then "parent" property of this Child will be
automatically initialized).

So, suggested you to create the MM like this and then create .gmfmap file
for it (ChildReference.containmentFeature == “children”). As a result “parent”
property will be automatically initialized on creating new Child.

BTW, I found that my solution with the OCL constraint will not work for you.
The problem is: OCL constraint will be checked only on diagram initialization,
but not while creating this element.. Furtunately there is a simple way to
handle your situation: you can specify “UpperBound” property for the “children
feature in .ecore file. This property should constraint a number of possible
children and this property should be checked by generated code. Sorry for
pointing you to the wrong solution from the very beginning.

-----------------
Alex Shatalin
Re: Setting constraints for a parent node in .gmfmap to contain afixedno.of children [message #124610 is a reply to message #124373] Mon, 07 May 2007 09:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: biju_gopinathan.rediffmail.com

Hi Alex Shatalin,

Thanks for your help,

> If you set "eOpposite" property of "parent" feature to point to the
> "children" then the rest will be generated for you by EMF

I tried to set the "eOpposite" property of "parent" feature in the
property view, in the '.ecore' file, but as I was not able to set it as
it just show an empty drop down list.

How could I set this "eOpposite" property, and should I do it in.ecore
file itself.


Thanks and Regards biju
Re: Setting constraints for a parent node in .gmfmap to contain afixedno.ofchildren [message #124633 is a reply to message #124610] Mon, 07 May 2007 09:43 Go to previous message
Eclipse UserFriend
Hello biju,

In my case I can set eOpposite property of the EReference if this EReference
has correct type (EClass containing desired opposit reference).

-----------------
Alex Shatalin
Previous Topic:Placing Containments inside an element
Next Topic:Run application programmatically
Goto Forum:
  


Current Time: Thu Sep 18 16:53:20 EDT 2025

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

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

Back to the top