[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] DND

Hello.
I was trying to add DND support to my editor, and I can't do it.
In my navigator viewer I added this line:

this.viewer.addDragSupport(DND.DROP_COPY, new Transfer[]
{ ElementTransfer.getInstance() }, new ElementDragSourceListener(this.viewer));


It adds support for dragin.
ElementTransfer is a simple class that extends ByteArrayTransfer() and don't do too much. ElementDragSourceListener is a extension of DragSourceAdapter class.


It has method dragSetData() that sets event.data to my dragged object.

Now DROP SUPPORT.

In my EDITOR CLASS:

protected void initializeGraphicalViewer()
{
...
_graphicalViewer.addDropTargetListener(new DiagramDropTargetListener(_graphicalViewer));
...
}


and:

public class DiagramDropTargetListener implements TransferDropTargetListener{...}
// org.eclipse.jface.util.TransferDropTargetListener;


Method drop(DropTargetEvent event) is the one that should finaly drop dragged object. Unfortunatelly event.data = null.
When i did simple DEBUG it turns that dragSetData() is called at the very end, after drop() is called.


Now I'm really confused. Can someone please tell me how to implement this functionality? I'm trying for too long without any results.

Simple example, some clue, whatever will be nice, I'm desperate :)

Am I going good directions by the way?

Cheers, Greg