Skip to main content



      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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Sun Jul 06 09:46:08 EDT 2025

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

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

Back to the top