Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Recursive Diagram Editors(Handling recursive heirarchy for objects by reference)
Recursive Diagram Editors [message #806334] Fri, 24 February 2012 21:04 Go to next message
Che Bumagat is currently offline Che BumagatFriend
Messages: 32
Registered: February 2012
Member
Hello GMF experts!

I'm new to GMF and I have a question on creating a diagram editor with the following model.

For example:

1. Diagram Root -> contains Record and RecordGroup
2. A Record has Elements.
3. A RecordGroup has Elements.
4. An Element(abstract) can be a DataElement or a GroupElement.
5. In my ecore, the DataElement is the "leaf" whereas the GroupElement has reference to the RecordGroup but the relationship is not a containment (i.e. containment=false).

GOAL:
My goal is to create a graphical editor that represents the Record in a box that has elements in separate boxes (can be a DataElement or GroupElement). For DataElement, since this is a leaf, I don't have problems. But if it is a GroupElement, I must be able to put another box inside which represents the RecordGroup which in turn can contain Elements and so on...

In my gmfmap file, the top node is Record and I have 2 ChildReferences (DataElement & GroupElement) I added another ChildReference to GroupElement pointing to RecordGroup but GMF won't let me and returns this error.

"... 'Containment Feature' must be owned by 'Domain Meta Element' or its super type of this reference parent Node Mapping mapping.gmfmap /<some package..>/model..."

Is there a way to get around this problem? Or is it really the limitation of GMF to only have a recursive heirarchy using objects having containment references in a model.

Appreciate the help! Smile
Re: Recursive Diagram Editors [message #808326 is a reply to message #806334] Mon, 27 February 2012 16:59 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 373
Registered: July 2009
Senior Member
Hello,

I recently answered in details why GMF asks for matching containment in this thread.

I guess that the same 3 (actually 2 for right now) alternatives are applicable to your use case - in brief, you may either ignore the warning and fix the compilation problems, or implement the derive references that follows graphical containment and use those derived refs for GMF-map input model.

Hope that helps,
Regards,
Michael "Borlander" Golubev
at Montages Think Tank, Prague, Czech Republic
Montages AG, Z├╝rich, Switzerland
Re: Recursive Diagram Editors [message #808416 is a reply to message #808326] Mon, 27 February 2012 19:10 Go to previous messageGo to next message
Che Bumagat is currently offline Che BumagatFriend
Messages: 32
Registered: February 2012
Member
Thanks Michael for the response! Smile

I'm thinking to go with alternative #1... but also I'm interesed to know how to do alternative #2.

Do you have an refernces/examples on how to do alternative #2?

Sorry again, as I'm quite new to all of this.

Thanks!
Re: Recursive Diagram Editors [message #808489 is a reply to message #808416] Mon, 27 February 2012 21:02 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 373
Registered: July 2009
Senior Member
Well, what I meant as an alternative 2 is just:

a) Answer the question "for given GroupElement how can I find the only corresponding RecordGroup which actually contains the Element's that shuld be shown at the diagram inside the GroupElement' node"
b) Add the
derived ref Element[*] diagramElements;
into the class GroupElement
c) In the EMF-generated code implement your answer for a) into the GroupElementImpl#getDiagramElements().
Note that if your logic is just "choose or create some RecordGroup and use its elements" than you may just return the results of the RecordGroup#getElements by reference, it will ensure that adding some element into this list will put the Element into some correct place.
d) use this new derived feature for diagram definition
As I have already mentioned, you will have the warning about non-containment on step d) anyway, because we can't define derived containments in the EMF.

Regards,
Michael


Re: Recursive Diagram Editors [message #808518 is a reply to message #808489] Mon, 27 February 2012 21:46 Go to previous message
Che Bumagat is currently offline Che BumagatFriend
Messages: 32
Registered: February 2012
Member
Ok, I will try that! Thanks again!
Previous Topic:Rotate label
Next Topic:How to generate a description for a node?
Goto Forum:
  


Current Time: Sun Dec 21 10:09:10 GMT 2014

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

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