Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Copying cross references
Copying cross references [message #1407244] Tue, 12 August 2014 07:18 Go to next message
Samuel Leisering is currently offline Samuel LeiseringFriend
Messages: 34
Registered: July 2014
Member
I tried to copy one of my model objects using the default Drag and Drop mechanism in a TreeViewer. The object contained a crossreference to another object (and an opposite-reference). After copying the reference is lost. Is this the desired behaviour? I think it would make sense that the reference is kept, and the newly created object is added to the opposite reference. If it is the intended behaviour, how can I change the default copy mechanism?

Greetings
Samuel Leisering
Re: Copying cross references [message #1407306 is a reply to message #1407244] Tue, 12 August 2014 09:49 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Samuel,

Comments below.

On 12/08/2014 9:18 AM, Samuel Leisering wrote:
> I tried to copy one of my model objects using the default Drag and
> Drop mechanism in a TreeViewer. The object contained a crossreference
> to another object (and an opposite-reference). After copying the
> reference is lost.
Yes, making a copy always produces a new object and no existing objects
are modified as a side-effect.
> Is this the desired behaviour?
It's certainly the intended behavior.
> I think it would make sense that the reference is kept, and the newly
> created object is added to the opposite reference.
Assuming it's multi-valued, but keep in mind that drag and drop is much
like copy and paste, but in the case of copy and paste, there's no
guarantee that the copied object will ever be pasted, so certainly one
would definitely not want merely producing a copy to modify existing
objects as a side effect.
> If it is the intended behaviour, how can I change the default copy
> mechanism?
I don't think you should change the copying behavior. Perhaps it's
reasonable to specialize the drag and drop command itself
(org.eclipse.emf.edit.provider.ItemProviderAdapter.createDragAndDropCommand(EditingDomain,
Object, float, int, int, Collection<?>)), but copying (which you can
specialize by specializing the item providers copy commands) should
never have a side-effect. And even specializing drag and drop, you'll
have to be very careful, because the command may not be executed if the
user aborts the drop or moves the mouse to drop somewhere else and the
already-created command is abandoned. So if you specialize
org.eclipse.emf.edit.command.DragAndDropCommand.prepareDropCopyOn() and
org.eclipse.emf.edit.command.DragAndDropCommand.prepareDropCopyInsert(Object,
Collection<?>, int) be aware that anything you do that has a side-effect
better be deferred until the overall command is actual executed.
>
> Greetings
> Samuel Leisering


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Executing QVTo in java
Next Topic:EMF Proxy Resolving
Goto Forum:
  


Current Time: Sat Apr 20 03:51:23 GMT 2024

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

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

Back to the top