| [news.eclipse.modeling.gmf] Re: Shortcut for 1:1:n containment reference chains in NodeMapping/ChildReference |
Hello Alex,
first, let me thank you for your valuable help.
shouldThis is a right solution for now with only addition â?? this referencemodel so that i can ask A for instances of C. (containment, derived, transient references from A->C) - Remember: A->B is 1:1 containment
not be containment and GMF should allow you to specify non-containmentreference
as containment one in ChildReference (you should be able to igronre warning on map->gen transformation and generate code then).I'll soon have a look at the GMF sources to enable selection of non-containment references. As I can't imagine any other expedient constraint (than being containment) on the selectable references, I'll hand it over to the toolsmith to care for the sanity of his/her selection.
implementedMight it eventually be possible to extend GMF to support this? If so,I think, generic support of this situation is rather complex, so I doubt support this kind of â??complex diagram structure modellingâ?? will be
in GMF in near future. As you correctly found there is a workaround for this problem â?? you can use EMFâ??s derived features + java to implement all the logic there so for GMF this will be still a parent domain model element(indirectly)
containing child one.. Nevertheless for now you can try modifying GMF templates (using customtemplates
for this diagram editor generation) to handle this situation at least to some extend. Once youâ??ll find a solution you can simply raise a bugzilla request with appropriate patch attached to contribute this functionality into the project.Ok, so I'll rather create a plugin extending EMF to be able to create these "shortcut" references semi-automatically. I agree with you this being the better way of solving my issues.
First of all you have to modify templates generating CreateCommand toproperly
create intermediate element + properly assign child element to the chain of containment feature. In this case an entry point will bexpt/diagram/commands/CreateNodeCommand.xpt
template.The child element assignment is no problem at all, I use Feature Seq Initializers for that which work well.
Then youâ??ll probably face some problems with update logic. This part will not be so simple (update is quite compex place in GMF) and in this case you have to start with xpt/diagram/updater/DiagramUpdater.xpt template.So far i didn't see any problems with that. Since I delegate all accessor methods completely to the target class (from A->B->C): A.getB().getC().getSomeCollection().add(...), C's accessor methods shold fire notifications properly, do they?
I can not remember any other templates to be involved into this task, so good luck and ping me if you get any more questions.
Thanks a lot, Alex. BTW: Working with GMF is great fun!
Cheers
Christian