[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: EMF newbie question

Thanks.
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).


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)?

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:
Hi 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.
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-emf

Can someone point me in the right direction? Thanks in advance.