Move Eobject from one container to another container in EMF [message #1853217] |
Thu, 23 June 2022 09:45  |
Eclipse User |
|
|
|
Hello there,
I need to move eobjects from one container to another container is there any api to do this in EMF.
I was able to get all eobjects and filter according to my use case.
I have a Eobjects which has Ereference i need to move eobject to that Ereference.
val eAllModels = resourceSet.resources.flatMap[contents].filter(Model).toList
val eAllInstances = eAllModels.flatMap[it.eAllContents.toIterable].filter(Instance).toList
Example structure:
Channel A{
pdu_triggering abc: Pdu.B (references)
}
Pdu B{
}
After moving Eobject :
Channel A{
}
Pdu B{
pdu_triggering abc{
channel: A
}
}
Any idea and inputs will be highly appreciated.
Thanks
|
|
|
Re: Move Eobject from one container to another container in EMF [message #1853218 is a reply to message #1853217] |
Thu, 23 June 2022 09:56   |
Eclipse User |
|
|
|
In EMF you only need to move the root of a tree of objects in order to move the entire tree.
So in your example it is enough to move "pdu_triggering abc" from "Channel A" to "Pdu B", and all child objects will be moved as well. No need to iterate through children objects.
And BTW the operation of "move" in EMF is simply setting the object to the new containment reference, or adding it to the new containment EList. EMF automatically takes care of removing the object from its previous container.
I hope this helps.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04338 seconds