Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Compartment without containment
Compartment without containment [message #62454] Sat, 14 October 2006 14:43 Go to next message
Jinchao (Joseph) is currently offline Jinchao (Joseph)Friend
Messages: 12
Registered: July 2009
Junior Member
Hello,

The GMF toturial explains the difference between containment and children
references. As my application needs a compartment holding referenced
objects, I set the children feature in the gmfmap and leave the containment
feature blank. However, when creating the generator model a GMF message
indicates a compartment has to use containmentship. Is there a way to go
around this restriction?

Also, is it possible to have two different type of referenced objects in the
same compartment?

Thanks,
Jinchao
Re: Compartment without containment [message #62572 is a reply to message #62454] Sun, 15 October 2006 06:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: greenl.mot.com

Jinchao,

For your second question, I think you can create multiple Child References
with each of them has a Node Mapping for different types, and set the
Compartment of all Child Reference to the same compartment mapping.

"Jinchao Huang" <jchuang@ca.ibm.com> wrote in message
news:egqt2n$vre$1@utils.eclipse.org...
> Hello,
>
> The GMF toturial explains the difference between containment and children
> references. As my application needs a compartment holding referenced
> objects, I set the children feature in the gmfmap and leave the
> containment feature blank. However, when creating the generator model a
> GMF message indicates a compartment has to use containmentship. Is there a
> way to go around this restriction?
>
> Also, is it possible to have two different type of referenced objects in
> the same compartment?
>
> Thanks,
> Jinchao
>
>
>
Re: Compartment without containment [message #63235 is a reply to message #62454] Mon, 16 October 2006 11:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jinchao,

For your first question: You can simply ignore the validator messages, generate
code and then modify it by hands. You should only realize that you HAVE to
put created object somewhere to persist it in the model. AFAIK, you can put
it into some other object in your model (this is why containment references
property was invented) or directly into the resource. I suggest you to review
your model and clarify where corresponding objects should be contained. Usually
there should be another model object keeping all of them.

-----------------
Alex Shatalin
Re: Compartment without containment [message #63255 is a reply to message #62454] Mon, 16 October 2006 11:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jinchao,

For your first question: You can simply ignore the validator messages, generate
code and then modify it by hands. You should only realize that you HAVE to
put created object somewhere to persist it in the model. AFAIK, you can put
it into some other object in your model (this is why containment references
property was invented) or directly into the resource. I suggest you to review
your model and clarify where corresponding objects should be contained. Usually
there should be another model object keeping all of them.

-----------------
Alex Shatalin
Re: Compartment without containment [message #63278 is a reply to message #62454] Mon, 16 October 2006 11:57 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jinchao,

For your first question: You can simply ignore the validator messages, generate
code and then modify it by hands. You should only realize that you HAVE to
put created object somewhere to persist it in the model. AFAIK, you can put
it into some other object in your model (this is why containment references
property was invented) or directly into the resource. I suggest you to review
your model and clarify where corresponding objects should be contained. Usually
there should be another model object keeping all of them.

-----------------
Alex Shatalin
Re: Compartment without containment [message #64240 is a reply to message #63235] Tue, 17 October 2006 14:11 Go to previous messageGo to next message
Jinchao (Joseph) is currently offline Jinchao (Joseph)Friend
Messages: 12
Registered: July 2009
Junior Member
Hi Alex,

Thanks for responding to the question. I appreciate it very much.

My problem is that the GMF message is an error message, and the Next button
on the genration wizard is disabled.

In my ecore model the object to be displayed is owned by another model
object (with the containment set to true). To by-pass the error message, I
modified the ecore model so that the object to be displayed is owned by both
that owning object and the object that has the compartment. As a result, all
the objects created inside the compartment are persisted with the object
that has the compartment, not with the original owning object. I don't know
how to modify the generated code to switch the persistence to the original
owning object and create references inside the compartment object.

Thanks,
Jinchao

"Alex Shatalin" <vano@borland.com> wrote in message
news:egvs3s$fst$1@utils.eclipse.org...
> Hello Jinchao,
>
> For your first question: You can simply ignore the validator messages,
> generate code and then modify it by hands. You should only realize that
> you HAVE to put created object somewhere to persist it in the model.
> AFAIK, you can put it into some other object in your model (this is why
> containment references property was invented) or directly into the
> resource. I suggest you to review your model and clarify where
> corresponding objects should be contained. Usually there should be another
> model object keeping all of them.
>
> -----------------
> Alex Shatalin
>
>
Re: Compartment without containment [message #64341 is a reply to message #64240] Tue, 17 October 2006 14:45 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jinchao,

So, in your meta-model you have following metaclasses: Parent, Child, ChildOwner.
Parent visually represented on diagram as a node with compartment, Child
should be nested inside this compartment, ChildOwner should actually contains
Child instances.

Try setting containment reference from ChildOwner object to Child as a containment
feature for ChildNodeReference pointing to the NodeMapping of Child. This
should be allowed in .gmfmap editor. Generated code will handle creation
of new Child1 inside Parent1 by traversing parent hierarchy starting from
Parent1 till first instance of ChildOwner (ChildOwner1) and then putting
newly created Child1 into ChildOwner1.

If in your meta-model corresponding ChildOwner is not one of the parents
of Parent metaclass then you should customize generated code - generated
Parent<CompartmentName>ItemSemanticEditPolicy.CreateChild_???Command. If
you put a breakpoint into getElementToEdit() method of this class you can
easily realize what’s happening on new element creation and patch generated
code to support custom behavior.

-----------------
Alex Shatalin
Previous Topic:Problem with the Copy/Paste actions in the GMFGraph model
Next Topic:Problems when using "Affixed Parent Side" property
Goto Forum:
  


Current Time: Thu Dec 26 09:52:58 GMT 2024

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

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

Back to the top