[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: Referencing model elements (generated editor vs. editor on the fly)

Hi Michael,

I gave this a try and everything worked fine on my machine. This is what I've done:

1. Defined a model A with a package A and a class CA in it
2. Generated the code (model, edit, and editor) for A
3. Launched a runtime workspace

-- from now on, everything is happening on the runtime workspace ---

4. Defined a model B with a package B and a class CB that has a containment reference that can hold instances of CA (to do that I did a "Load Resource" in the Ecore editor and pressed the button "Browse Registered Packages..." and selected A.
5. Created an instance of CB (ob) from the Ecore editor (by right clicking on the class B and using the "Creating Dynamic Instance..." menu item)


6. Created an instance of CA (oa) using the generated wizard (which end up opening the generated editor)

7. Loaded the resource containing ob in the oa's editor

8. Set ob as the container of oa by right-clicking ob and going through the "New Child" menu

I am not a specialist on EMF.Edit but if I had to point you to a direction, I would suggest checking if the constructor of the generated editor (or the method initializeEditingDomain() ) executes this line:

adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());

It "enables" the editor to manipulate instances of EObject through reflection.

Cheers,
Marcelo

Michael Gebhart wrote:
Hi,

I have the following problem: I have two meta models (ecore models) A and B. The metamodel B references elements of the metamodel A.

Now I wanna create instances. For metamodel A I generate the EMF editor. For metamodel no editor is needed (the instance of the metamodel is created in another way).

Ok, now I create an instance of the metamodel A with the generated EMF editor. After that I load the created instance of the metamodel B in the resource set. So now both, an instance of metamodel A (A_I) and metamodel B (B_I) are visible within the editor. As I mentioned the metamodel B references elements of the metamodel A. I wanna set some elements in B_I to use elements of A_I, but this is not possible. The elements of A_I are not available in B_I.

Is it because A_I is used with a generated EMF editor and B_I isn't? Because if I generate an EMF editor for B too I can choose the elements.

And if I use no generated editor for both it is working too. Obviously there is a mismatch of the metamodel package if I use a generated editor and a editor on the fly.

Any idea how I can fix this issue?

Greetings

Michael