| Advanced Drag & Drop [message #499266] |
Fri, 20 November 2009 10:49  |
Eclipse User |
|
|
|
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 11:07   |
Eclipse User |
|
|
|
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
|
|
|
| Re: Advanced Drag & Drop [message #499283 is a reply to message #499271] |
Fri, 20 November 2009 11:42  |
Eclipse User |
|
|
|
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.03829 seconds