Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF Command for parent child(Is there a command for moving a child to a new parent)
EMF Command for parent child [message #900022] Fri, 03 August 2012 13:36 Go to next message
Tom Bauwens is currently offline Tom BauwensFriend
Messages: 10
Registered: May 2012
Junior Member
Hi,

Is there an emf command that I can use to move a child from a parent object (eContainer) to another parent?

I can easily do this directly on the model: parent.eList.remove() and then newParent.eList.add(), but I was told not to directly edit the model in this way. Instead, I should always use emf commands.

Thanks for your help.
Re: EMF Command for parent child [message #900053 is a reply to message #900022] Fri, 03 August 2012 17:01 Go to previous messageGo to next message
Tim Schaefer is currently offline Tim SchaeferFriend
Messages: 49
Registered: June 2011
Location: Marburg, Germany
Member
Hi,

you can use AddCommand. You only need to add the object to the new parent, it will automatically be removed from its old parent's container list.

Regards,
Tim
Re: EMF Command for parent child [message #900061 is a reply to message #900053] Fri, 03 August 2012 17:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Tim,

It will be automatically removed, because the model does that, but if
you undo, it won't be put back because the AddCommand doesn't know about
the removal. So you have to compose a RemoveCommand and an AddCommand.

On 03/08/2012 7:01 PM, Tim Schaefer wrote:
> Hi,
>
> you can use AddCommand. You only need to add the object to the new
> parent, it will automatically be removed from its old parent's
> container list.
>
> Regards,
> Tim


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: EMF Command for parent child [message #900067 is a reply to message #900061] Fri, 03 August 2012 19:19 Go to previous messageGo to next message
Tim Schaefer is currently offline Tim SchaeferFriend
Messages: 49
Registered: June 2011
Location: Marburg, Germany
Member
Oh, right, sorry. Fore some reason I thought AddCommand would remember the old container.
Re: EMF Command for parent child [message #900111 is a reply to message #900067] Sat, 04 August 2012 06:39 Go to previous message
Tom Bauwens is currently offline Tom BauwensFriend
Messages: 10
Registered: May 2012
Junior Member
Hi guys,

Thanks a lot for your answers.
I have put the RemoveCommand and the AddCommand inside a CompoundCommand such that they are executed together when doing undo/redo. Works like a charm Smile

Grtz,
Tom
Previous Topic:saving references in dynamically created emf
Next Topic:[CDO] Collaborative work on UML models
Goto Forum:
  


Current Time: Thu Apr 18 08:04:09 GMT 2024

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

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

Back to the top