|Re: Copying cross references [message #1407306 is a reply to message #1407244]
||Tue, 12 August 2014 09:49
| Ed Merks
Registered: July 2009
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
I don't think you should change the copying behavior. Perhaps it's
reasonable to specialize the drag and drop command itself
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
Collection<?>, int) be aware that anything you do that has a side-effect
better be deferred until the overall command is actual executed.
> Samuel Leisering
Powered by FUDForum
. Page generated in 0.02444 seconds