Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [EMF: Answered] How to create a container of references
[EMF: Answered] How to create a container of references [message #638313] Wed, 10 November 2010 19:33 Go to next message
Glenview Jeff is currently offline Glenview JeffFriend
Messages: 79
Registered: September 2010
Member
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
- name

- 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 : [1] WidgetContainer Containment = true
- myReferenceContainer : [1] 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.

Jeff

[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 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080102040403040907090500
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Jeff,

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
Editor.

Questions about modelisation would be better off on the
eclipse.technology.emf newsgroup/forum.

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
Properties View"
In this properties view :
- change the "name" field to whatever you want this reference named (say
"widgets")
- 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.

Laurent Goubet
Obeo

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.
>
> Jeff


--------------080102040403040907090500
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------080102040403040907090500--
Previous Topic:[Xpand] Newline style of output files
Next Topic:[acceleo]Accessing UML elements in SysML Model
Goto Forum:
  


Current Time: Fri Apr 26 13:41:58 GMT 2024

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

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

Back to the top