|
Re: [EMF.Edit] Custom InitializeCopyCommand [message #421942 is a reply to message #421940] |
Mon, 18 August 2008 21:35 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.03475 seconds