views:

185

answers:

1

The code is:

    DropTarget target = new DropTarget(sqlViewer.getTextWidget(), 
    DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK);
 Transfer[] types = new Transfer[] {TreeLeafListTransfer.getInstance(), 
    TextTransfer.getInstance(), FileTransfer.getInstance()};
 target.setTransfer(types);
 target.addDropListener(new DropTreeLeafAdapter(sqlViewer));

And it works normally for a view, but fails in an editor. What's the difference?
upd: Whtat is most strange - if I surround it with a try/catch block, it still fails without exception.
edit: The problem is bigger than just DnD not working. The whole editor fails to instantiate because of this block. Just an empty window appears.

A: 

it works normally for a view, but fails in an editor. What's the difference?

The difference should be in the transfert type:

To recap, transfer types allow drag sources to specify what kinds of object they allow to be dragged out of their widget, and they allow drop targets to specify what kinds of objects they are willing to receive.
For each transfer type, there is a subclass of org.eclipse.swt.dnd.Transfer. These subclasses implement the marshaling behavior that converts between objects and bytes, allowing drag and drop transfers between applications.

May be the list of Transfer type you are using is not quite compatible with the target (an Editor)? See this thread for more test around that.

Another item to consider is the proper setup of a TransferDropTargetListener (like in this thread).

Since I have not yet fully tested eclipse DnD, I cannot give you much more details on this topic, but hopefully that will give you something to start your own analysis.

VonC
see edit. the code fails whole editor.
Imaskar