| [news.eclipse.tools.emf] Re: Any documentation with delegating ELists |
|
Randall,
The Bar objects have to behave as if they are already in the list and
if a relation is bidirectional, both ends have to behave as if the results
are already there on demand. Most definitely there can be no calls
to add or set to make this happen. Since the Bar object is new, you
can call InternalEObject.eInverseAdd to set only the one half of the bidirectional
relation (or if Foo is the container for Bar, you could call InternalEObject.eBasicSetContainer
for directly). If the relation is not a containment, you could add
a proxy for Foo to Bar and it will resolve later.
Randall Hauch wrote: Thanks, Frank and Ed. I think I've got part of it working, but I'm running into a problem that I can't seem to get my arms around. Lets say my metamodel has two metaclasses, Foo and Bar, and Foo has a bi-directional containment relationship to Bar. The generated FooImpl class uses a DelegatingEList in place of it's normal EList. I then have my own Resource implementation. Here's the sequence that's getting me in trouble. A client calls Resource.getContents() and gets the root-level Foo instance. At this point, the Foo object hasn't created its DelegatingEList. The client navigates to the Foo instance, and then calls it's "getBar" method - which instantiates the DelegatingEList - and then "size()" on the returned list. At this point, my DelegatingEList goes back to my Resource to ask it for the Bar objects that are in this Foo object. How do I create/materialize the Bar objects and add them to the List? The feature is bi-directional, so if my Resource calls "setFoo(...)" on the Bar object, the implementation will turn around and as for the List - but this is what I'm trying to materialize, and I get into a loop. On the other hand, if I add the Bar objects to the List (which is still my working copy and not yet returned to the Foo object's DelegatingEList), this list isn't bi-directional and won't set the Foo reference on the Bar objects. Am I missing something? Randall"Frank Budinsky" <frankb@xxxxxxxxxx> wrote in message news:3F574820.1C867514@xxxxxxxxxx...Randall, |