|[EMF: Answered] How to create a container of references [message #638313]
||Wed, 10 November 2010 19:33
| Glenview Jeff
Registered: September 2010
I'm new to MDSD/EMF but am making great progress thanks to Eclipse's support.|
I created a toy model as answered yesterday as awynne suggested, and I'm very close. I'm only using EMF and its generated tree editor.
Here's a summary of my EMF meta-model:
- EClass: Widget
- EClass: WidgetReference
- aWidgetReference : Widget [0..1] Containment = false
- EClass: WidgetContainer
- myWidgets : Widget [0..*] Containment = true
- EClass: ReferenceContainer
- myReferences : WidgetReference [0..*] Containment = true
- EClass: TopLevelClass
- myWidgetContainer :  WidgetContainer Containment = true
- myReferenceContainer :  ReferenceContainer Containment = true
What's happening now is that in the generated tree editor for the model, I create everything starting from the TopLevelClass. I can successfully create multiple widgets in the WidgetContainer, and I can create a single WidgetReference in the ReferenceContainer and associate it with a specific Widget.
In case anyone runs into this, there is a bug in the generated EMF editor code:
When I try to add more than one WidgetReference to the ReferenceContainer, the tree editor only shows the first WidgetReference under the ReferenceContainer. If I click on the WidgetReferences item in the tree, it does show multiple WidgetReferences in the properties view. It just won't let me see them in the tree, and therefore won't let me select them to change their reference to associate it to an actual widget.
The workaround to this is to create as many references as you need, save and close the model, and then re-open it. Upon re-opening it, all of the references will be shown.
[Updated on: Fri, 12 November 2010 21:20]
Report message to a moderator
|Re: [Accelo and/or EMF] How can I create a reference to existing model objects? [message #639148 is a reply to message #638313]
||Mon, 15 November 2010 12:12
|| Laurent Goubet
Registered: July 2009
This is a multi-part message in MIME format.|
Content-Type: text/plain; charset=UTF-8; format=flowed
When you are talking about how to model things, you are either using EMF
or one of the graphical modelers (papyrus, topcased...). The "Sample
Ecore Model Editor" comes directly shipped with EMF.
Acceleo has no "ecore" editor. The only editor it ships is the Template
Questions about modelisation would be better off on the
As for the question itself, for a model element to "contain" other
elements, you have to create a "containment" reference.
- create EClass named "Window"
- create EClass named "Widget"
- create new EReference on "Window", right click on it > "Show
In this properties view :
- change the "name" field to whatever you want this reference named (say
- change the "containment" field to "true"
- change the "upperBound" field to "-1" if you wish for the Window to
contain 0..* widgets rather than 0..1.
On 10/11/2010 20:33, glenviewjeff wrote:
> I'm new to MDSD/EMF/Acceleo but am making great progress thanks to
> Acceleo and the rest of Eclipse's support.
> I can't figure out how to model references to existing instances of
> model objects. There is a certain collection of instantiated model
> objects, say "widgets," and I want another model object to contain
> references to a subset of these widget instances.
> I don't yet know where to look for answers because it's not clear to me
> which Eclipse modeling components are involved. When I edit the ecore
> file which contains the meta-model of my system, I use the "Sample Ecore
> Model Editor" which presents the model in a tree view. When I edit the
> model of my system, I use the editor that Acceleo created.
> Thanks for any help/guidance.
Content-Type: text/x-vcard; charset=utf-8;
Powered by FUDForum
. Page generated in 0.02425 seconds