|How to add child nodes using the reflective API of EMF? [message #630719]
||Mon, 04 October 2010 16:51
| Adrian Aichner
Registered: March 2010
http:// www.eclipse.org/forums/index.php?t=msg&th=197805&sta rt=0&S=9d4b40b4b637cfad75d0340c23461ca4
for the reply I got and progress I made.
[I had originally posted this over at Model->UML but Ecore Tools seems to be the right place to ask.]
I am able to add nodes to an EMF model generated from XSD:
EPackage ep = poClass.getEPackage();
EClass ctNew = (EClass) ep.getEClassifier("ChangeType");
EObject ctObject = ep.getEFactoryInstance().create(ctNew);
ctObject.eSet(ctObject.eClass().getEStructuralFeature("comment "), "...");
I am also able to add a node to a single-valued feature:
EClass cltNew = (EClass) ep.getEClassifier("ChangeLogType");
clt = ep.getEFactoryInstance().create(cltNew);
I can also obtain the list of change entries under the many-values change node:
EList<EObject> changes = clt.eClass().getEStructuralFeature("change").eContents();
Here is my problem:
Caused by: java.lang.UnsupportedOperationException
at org.eclipse.emf.ecore.util.EContentsEList$FeatureIteratorImp l.add(EContentsEList.java:779)
at java.util.AbstractSequentialList.add(Unknown Source)
at java.util.AbstractList.add(Unknown Source)
which I had planned to use as follows:
Is there a way to add child nodes using the reflective API of EMF?
I need to avoid using specific types of the generated model in this section of code, since this code should be usable by multiple separate generated models.
Thanks in advance for any advice.
[Updated on: Wed, 06 October 2010 13:25]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.06163 seconds