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
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 30
Registered: May 2020
Member
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
Elie Richa is currently offline Elie RichaFriend
Messages: 57
Registered: February 2016
Member
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.


Elie Richa, Ph.D
Software Engineer, AdaCore
https://www.adacore.com
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
Nagaraj Kandoor is currently offline Nagaraj KandoorFriend
Messages: 30
Registered: May 2020
Member
@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: Thu Jun 30 23:23:41 GMT 2022

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

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

Back to the top