Advanced Drag & Drop [message #499266] |
Fri, 20 November 2009 15:49 |
Mario Winterer Messages: 136 Registered: July 2009 |
Senior Member |
|
|
Hi!
Although EMF's item provider are highly extensible and provide an
excellent way to customize Drag & Drop / Cut/Copy/Paste as well as all
other model editing purposes, I'm somehow stuck with realizing our DnD
requirements:
We're showing a tree like structure in a view that acts as template. By
dropping nodes from this (read-only) template into the editor, the user
should be able to create his custom tree.
Let's assume the user drags a node from the source tree and drops it
onto a container node of the target editor. As a result, the entire node
branch (from source root to the source node that has been dropped)
should be rebuilt and appear in the target editor. So we have to copy
all missing nodes between the drop target and the orginal drag source
node too.
I thought overriding NodeItemProvider.createAddCommand should do the
trick, but my custom add command gets the copies of the original source
nodes only, which do not have a container any more - so I cannot rebuild
the node branch:
Inside DragAndDropCommand.prepareDropCopyOn():
dragCommand = CopyCommand.create(domain, collection);
....
dragCommand.execute();
isDragCommandExecuted = true;
dropCommand = AddCommand.create(domain, owner, null,
dragCommand.getResult()); // the copies do not have a container any more...
All I need inside my AddCommand is a reference to the original source
node so I can copy its containers too...
Do I have to write my own DragAndDropCommand or is there a more elegant
solution to this problem?
Mario
|
|
|
Re: Advanced Drag & Drop [message #499271 is a reply to message #499266] |
Fri, 20 November 2009 16:07 |
Ed Merks Messages: 33148 Registered: July 2009 |
Senior Member |
|
|
Mario,
Comments below.
Mario Winterer wrote:
> Hi!
>
> Although EMF's item provider are highly extensible and provide an
> excellent way to customize Drag & Drop / Cut/Copy/Paste as well as all
> other model editing purposes, I'm somehow stuck with realizing our DnD
> requirements:
>
> We're showing a tree like structure in a view that acts as template.
> By dropping nodes from this (read-only) template into the editor, the
> user should be able to create his custom tree.
> Let's assume the user drags a node from the source tree and drops it
> onto a container node of the target editor. As a result, the entire
> node branch (from source root to the source node that has been
> dropped) should be rebuilt and appear in the target editor. So we have
> to copy all missing nodes between the drop target and the orginal drag
> source node too.
>
> I thought overriding NodeItemProvider.createAddCommand should do the
> trick, but my custom add command gets the copies of the original
> source nodes only, which do not have a container any more - so I
> cannot rebuild the node branch:
>
> Inside DragAndDropCommand.prepareDropCopyOn():
>
> dragCommand = CopyCommand.create(domain, collection);
> ...
> dragCommand.execute();
> isDragCommandExecuted = true;
> dropCommand = AddCommand.create(domain, owner, null,
> dragCommand.getResult()); // the copies do not have a container any
> more...
>
>
> All I need inside my AddCommand is a reference to the original source
> node so I can copy its containers too...
>
> Do I have to write my own DragAndDropCommand or is there a more
> elegant solution to this problem?
It sounds like you'd need to specialize createDragAndDropCommand to
create a specialized DragAndDropCommand where you do something a little
different in prepareDropCopyOn.
>
> Mario
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Advanced Drag & Drop [message #499283 is a reply to message #499271] |
Fri, 20 November 2009 16:42 |
Mario Winterer Messages: 136 Registered: July 2009 |
Senior Member |
|
|
Ed Merks schrieb:
> Mario,
>
> Comments below.
>
>
> Mario Winterer wrote:
>> Hi!
>>
>> Although EMF's item provider are highly extensible and provide an
>> excellent way to customize Drag & Drop / Cut/Copy/Paste as well as all
>> other model editing purposes, I'm somehow stuck with realizing our DnD
>> requirements:
>>
>> We're showing a tree like structure in a view that acts as template.
>> By dropping nodes from this (read-only) template into the editor, the
>> user should be able to create his custom tree.
>> Let's assume the user drags a node from the source tree and drops it
>> onto a container node of the target editor. As a result, the entire
>> node branch (from source root to the source node that has been
>> dropped) should be rebuilt and appear in the target editor. So we have
>> to copy all missing nodes between the drop target and the orginal drag
>> source node too.
>>
>> I thought overriding NodeItemProvider.createAddCommand should do the
>> trick, but my custom add command gets the copies of the original
>> source nodes only, which do not have a container any more - so I
>> cannot rebuild the node branch:
>>
>> Inside DragAndDropCommand.prepareDropCopyOn():
>>
>> dragCommand = CopyCommand.create(domain, collection);
>> ...
>> dragCommand.execute();
>> isDragCommandExecuted = true;
>> dropCommand = AddCommand.create(domain, owner, null,
>> dragCommand.getResult()); // the copies do not have a container any
>> more...
>>
>>
>> All I need inside my AddCommand is a reference to the original source
>> node so I can copy its containers too...
>>
>> Do I have to write my own DragAndDropCommand or is there a more
>> elegant solution to this problem?
> It sounds like you'd need to specialize createDragAndDropCommand to
> create a specialized DragAndDropCommand where you do something a little
> different in prepareDropCopyOn.
I've worried that this might be your answer... Thanks anyway.
>>
>> Mario
|
|
|
Powered by
FUDForum. Page generated in 0.02595 seconds