Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF.Edit] Custom InitializeCopyCommand
[EMF.Edit] Custom InitializeCopyCommand [message #421940] Mon, 18 August 2008 20:51 Go to next message
Matthias Treitler is currently offline Matthias TreitlerFriend
Messages: 117
Registered: July 2009
Senior Member
Hi!

I have the following use case: I want to make a copy from an EMF object
instance and change some simple attributes during the copy process. The
JavaDoc says something about overriding the InitializeCopyCommand.
OK, after some code reading I have found out that I have to return my
custom InitializeCopyCommand by overriding createInitializeCopyCommand()
in the appropriate XXXItemProvider. This does work well, but one attribute
of the copied object depends of some user input and so this approach is
useless for me because the XXXItemProviders can contain only static data.

Do I have any chance to set a custom InitializeCopyCommand during copy
command creation in my code?! I have not found any API... . Are there
other ways / best practices to handle such an use case?!

(The idea behind the InitializeCopyCommand is not bad, because otherwise I
would have to execute two commands on the command stack, one for simply
coping the object (CopyCommand) and several SetCommands wrapped into a
CompoundCommand to "initialize" the copy.)

Best regards,
Matthias
Re: [EMF.Edit] Custom InitializeCopyCommand [message #421942 is a reply to message #421940] Mon, 18 August 2008 21:35 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Matthias,

Comments below.

Matthias wrote:
> Hi!
>
> I have the following use case: I want to make a copy from an EMF
> object instance and change some simple attributes during the copy
> process. The JavaDoc says something about overriding the
> InitializeCopyCommand.
> OK, after some code reading I have found out that I have to return my
> custom InitializeCopyCommand by overriding
> createInitializeCopyCommand() in the appropriate XXXItemProvider. This
> does work well, but one attribute of the copied object depends of some
> user input and so this approach is useless for me because the
> XXXItemProviders can contain only static data.
>
> Do I have any chance to set a custom InitializeCopyCommand during copy
> command creation in my code?! I have not found any API... . Are there
> other ways / best practices to handle such an use case?!
If user input is required you'd normally gather that all up front via an
action that brings up a modal dialog and then you have all the data you
need. At that point you might just specialize the EcoreUtil.Copier to
create the copy; copying doesn't need to be undoable other than the part
where you put in on the clipboard...
>
> (The idea behind the InitializeCopyCommand is not bad, because
> otherwise I would have to execute two commands on the command stack,
> one for simply coping the object (CopyCommand) and several SetCommands
> wrapped into a CompoundCommand to "initialize" the copy.)
> Best regards,
> Matthias
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:ModelWizard
Next Topic:EMF XSD Developers: Public Service Announcement about Validation
Goto Forum:
  


Current Time: Sat Apr 27 00:41:31 GMT 2024

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

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

Back to the top