Hi,
I'm facing the same problem.
I'm using two Eclipse 4 parts where each part has one JFace viewer. The DragSource is a TreeViewer, the DropTarget is a CheckboxTableViewer.
Here is the code for the two Viewer and the custom Transfer object:
Transfer[] transfer = new Transfer[] { SeriesTransfer.getInstance() };
treeViewer.addDragSupport(DND.DROP_COPY, transfer,
new DragSourceAdapter() {
@Override
public void dragStart(DragSourceEvent event) {
System.out.println("start");
}
@Override
public void dragSetData(DragSourceEvent event) {
System.out.println("set");
}
@Override
public void dragFinished(DragSourceEvent event) {
}
});
checkboxTableViewer.addDropSupport(DND.DROP_COPY, transfer,
new ViewerDropAdapter(checkboxTableViewer) {
@Override
public void drop(DropTargetEvent event) {
System.out.println("drop");
super.drop(event);
}
@Override
public boolean performDrop(Object data) {
System.out.println("perform");
return true;
}
@Override
public boolean validateDrop(Object target, int operation,
TransferData transferType) {
System.out.println(transferType.type);
return true;
}
});
public class SeriesTransfer extends ByteArrayTransfer {
private static final String TYPE_NAME = TimeSeries.class.getName();
private static final int TYPE_ID = registerType(TYPE_NAME);
private static SeriesTransfer instance;
private SeriesTransfer() {
};
public static SeriesTransfer getInstance() {
if (instance == null)
instance = new SeriesTransfer();
return instance;
}
@Override
protected int[] getTypeIds() {
return new int[] { TYPE_ID };
}
@Override
protected String[] getTypeNames() {
return new String[] { TYPE_NAME };
}
@Override
public boolean isSupportedType(TransferData transferData) {
return super.isSupportedType(transferData);
}
}
Dragging the item works and dragStart and validateDrop are called (also the methods of the super- interface dragEnter and dragOver. But the items cannot be dropped and neither thedragSetData method is called nor the drop method.
The isSupportedType method returns true, if the object is of the specified type.
What am I missing?
Thank you!
Bastian