Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » EMF Adding to a collection with reflective API.
EMF Adding to a collection with reflective API. [message #756172] Fri, 11 November 2011 06:13
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 867
Registered: July 2009
Senior Member
Hi,

Is there a way to add objects to a many EReference without using copy?
When doing this, my objects are not added to the containment.


EList<EObject> manyReferenceCollection = (EList<EObject>)
target.eGet(eReference);

manyReferenceCollection.add(objectToSet);

target.eSet(eReference, manyReferenceCollection);


When creating a copy first , it works but my objects are copies, not the
original objects.

EList<EObject> manyReferenceCollection = (EList<EObject>)
target.eGet(eReference);


Collection<EObject> copyAll =
EcoreUtil.copyAll(manyReferenceCollection);

copyAll.add(objectToSet);

target.eSet(eReference, copyAll);


I need the orginal objects to be set back into the reference, as
elsewhere I keep an index of these objects. The index breaks if a copy
of the original list is stored back in the reference.

Thank You
Christophe
Previous Topic:Refresh issue with tableviewer
Next Topic:ComboViewer dropdown list not updated with new data
Goto Forum:
  


Current Time: Thu Apr 24 01:59:38 EDT 2014

Powered by FUDForum. Page generated in 0.01538 seconds