Compartment without containment [message #62454] |
Sat, 14 October 2006 10:43  |
Eclipse User |
|
|
|
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 #64240 is a reply to message #63235] |
Tue, 17 October 2006 10:11   |
Eclipse User |
|
|
|
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 10:45  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04673 seconds