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 09:36 Go to next message
Tom Bauwens is currently offline Tom Bauwens
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 13:01 Go to previous messageGo to next message
Tim Schaefer is currently offline Tim Schaefer
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 13:59 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25942
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
Re: EMF Command for parent child [message #900067 is a reply to message #900061] Fri, 03 August 2012 15:19 Go to previous messageGo to next message
Tim Schaefer is currently offline Tim Schaefer
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 02:39 Go to previous message
Tom Bauwens is currently offline Tom Bauwens
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: Tue Jul 29 23:14:57 EDT 2014

Powered by FUDForum. Page generated in 0.01640 seconds