| [news.eclipse.tools.emf] Re: EMF newbie question |
Mauro,
Comments below.
Thanks.That sounds like what would happen if you don't use containment="true"
I have evidently been unclear.
I already discovered the trick of leaving out the containment="true" attribute.
Problem is:
If I do that the generated editor will create a temporary IProduct instance and will refuse to save it (because it has to be contained somewhere).
You have to make containment false and then you can choose from instances contained already elsewhere in the model (or in another resource you load into the editor).
How do I convince EMF to generate an editor that will not generate a new instance, but will allow me to select an existing IProduct contained in another class (instance of IFirm)?
The library example illustrates this where the books and writers are contained by the library but can refer to each other.
Can this be done?
I suppose the answer is "yes", because it looks like a very common operation, but I found no references to it.
Thanks for the pointer. I'm printing it now :)
Regards Mauro
Ed Merks wrote:
Mauro,
Comments below.
Mauro Condarelli wrote:Unless you add containment="true" you should end up with a non-containment reference. Note that you can always create an Ecore model and generate the code to see what @model annotations come out for that. I'd also suggest you look at the nice EMF refcard. http://refcardz.dzone.com/refcardz/essential-emfHi Everybody, I am a complete newbie to EMF and thus, please, bear with me :)
I am trying to setup my first (after tutorials) real EMF project.
I am using annotated java to define my model (as per tutorials, again).
My current problem is: how to fill-up references (contained="false") as references to a "real" container (something similar to enums, but with a List of real classes).
I have a series of Interfaces: IProduct: name, description, price, ... IOrder: reference to IProduct, quantity, deliveryDate, ... ICustomer: name, address, ..., List<IOrder> IFirm: name, address, ..., List<IProduct>, List<ICustomer>
I am simplifying, of course.
My problem is the "reference to IProduct" should not be owned by IOrder, but a reference to some IProduct already defined and owned by IFirm.
This would be a FOREIGN KEY in SQL.
I would expect an editor showing a (dynamically filled) list (or combo) but I have been unable to achieve this.
Can someone point me in the right direction? Thanks in advance.