Transfer[] transfers = new Transfer[] { LocalSelectionTransfer.getTransfer(), TextTransfer.getInstance(), URLTransfer.getInstance() };
/* Drag Support */
fViewer.addDragSupport(ops, transfers, new DragSourceListener() {
public void dragStart(final DragSourceEvent event) {
SafeRunner.run(new LoggingSafeRunnable() {
public void run() throws Exception {
LocalSelectionTransfer.getTransfer().setSelection(fViewer.getSelection());
LocalSelectionTransfer.getTransfer().setSelectionSetTime(event.time & 0xFFFFFFFFL);
event.doit = true;
}
});
}
public void dragSetData(final DragSourceEvent event) {
SafeRunner.run(new LoggingSafeRunnable() {
public void run() throws Exception {
/* Set Selection using LocalSelectionTransfer */
if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType))
event.data = LocalSelectionTransfer.getTransfer().getSelection();
/* Set Text using Text- or URLTransfer */
else if (TextTransfer.getInstance().isSupportedType(event.dataType) || URLTransfer.getInstance().isSupportedType(event.dataType))
setTextData(event);
}
});
}
public void dragFinished(DragSourceEvent event) {
SafeRunner.run(new LoggingSafeRunnable() {
public void run() throws Exception {
LocalSelectionTransfer.getTransfer().setSelection(null);
LocalSelectionTransfer.getTransfer().setSelectionSetTime(0);
}
});