Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Move Eobject from one container to another container in EMF(Move Eobject from one container to another container in EMF)
Move Eobject from one container to another container in EMF [message #1853217] Thu, 23 June 2022 09:45 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Move Eobject from one container to another container in EMF [message #1853219 is a reply to message #1853218] Thu, 23 June 2022 10:31 Go to previous message
Eclipse UserFriend
@Elie Richa. Thank you.
Previous Topic:Xtext 2.26 based Maven build failing since 2022-06-15
Next Topic:Limitations of Xtext in a Web environment
Goto Forum:
  


Current Time: Wed Feb 12 21:39:23 GMT 2025

Powered by FUDForum. Page generated in 0.04338 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top