Home » Modeling » EMF » How to extends the copy/paste command ?(emf, copy, paste, extend)
|
Re: How to extends the copy/paste command ? [message #1700714 is a reply to message #1700600] |
Mon, 06 July 2015 15:26 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Vincent,
Comments below.
On 04/07/2015 5:17 PM, Vincent De Bry wrote:
> Hi,
>
> I'd like to add a post-processing to the creation of an element done
> with Copy/Paste or Drag/Drop in an EMF editor. More precisally, , I'd
> like to modify an attribute of the copied element so that it differs
> from the original element (Basically an attribute "name" so that name
> "X" would be set as "Copy_of_X" if copied under the same parent).
>
> I took a look at the class initializeCopyCommand, but it is called
> upon selection of an element, and at this time, I still don't know
> where it will be copied...
What you've describe above doesn't require you to know where it is
copied to does it? All the commands are created upon selection, and at
this point your specialized initialization of the copy can do what you
want. If/when the user hits Ctrl-C, the command will be executed to put
your specially initialized copy in the clipboard...
>
> Can someone give me any good advise to achieve this ?
>
> Thanks.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: How to extends the copy/paste command ? [message #1700751 is a reply to message #1700748] |
Mon, 06 July 2015 19:20 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Vincent,
I see, you want to make sure the name is unique at the target. Only the
AddCommand really knows where the object is being added, so you'd need
to specialize it. Of course there are many cases to consider, i.e.,
just moving the object with drag and drop, or with cut and paste is
similar, but not so much copying involved, i.e., the object is removed
from the original location in those cases. So yes, you can specialize
the add command creation, and use that hook to modify the object being
added. You'd want to be careful to do the modification also via a
command so that an undo will always work properly, i.e., in the case of
a move drag and drop, move it back and set the name back to the
original. CompoundCommand is of course useful for composing such logic.
On 06/07/2015 9:02 PM, Vincent De Bry wrote:
> Hi Ed, Thanks for answering.
>
> Yes, I need to know where the copy will be created: imagine I have the
> model below:
>
> A1
> --- B
> A2
>
> I want to copy B;
> If the copy has to be created ander A1: I want to have:
>
> A1
> --- B
> --- Copy_of_B
> A2
>
> If the copy has to be created ander A2: I want to have:
>
> A1
> --- B
> A2
> --- B
>
> Actually, as a copy of file in the windows explorer.
>
> So I need to post process the creation, and not only consier the
> command created upon selection.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: How to extends the copy/paste command ? [message #1700865 is a reply to message #1700846] |
Tue, 07 July 2015 17:51 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Vincent,
You can specialize
org.eclipse.emf.edit.provider.ItemProviderAdapter.createAddCommand(EditingDomain,
EObject, EStructuralFeature, Collection<?>, int). Note that the method
can return any type of command, though it must of course have the
effective of doing an add.
On 07/07/2015 4:42 PM, Vincent De Bry wrote:
> Ed,
>
> AddCommand is referenced by many classes. Where/how should I reference
> the extension I will do so it will be called by after every kinds of
> copy (Paste, cut, Drag&Drop...) ?
>
> Thanks.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Goto Forum:
Current Time: Thu Sep 19 09:15:33 GMT 2024
Powered by FUDForum. Page generated in 0.05958 seconds
|