From 16cb74e9e4f048dc79e2d33a45e30181ac3222d0 Mon Sep 17 00:00:00 2001 From: tkellner Date: Thu, 27 Feb 2014 16:03:22 +0000 Subject: Fix drag'n'drop on Mac Allow Move/Link operations; always use Copy git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@515 174cde9d-5d70-4d2a-aa98-46368bc2aaf7 --- .../gui/composites/DataSourceSelectComposite.java | 41 +++++----------------- 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'pdf-over-gui') diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java index 9f07312b..eede00a8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/DataSourceSelectComposite.java @@ -190,11 +190,7 @@ public class DataSourceSelectComposite extends StateComposite { } }); - //this.drop_area. - // this.drop_area.setBackground(back); - - DropTarget dnd_target = new DropTarget(this.drop_area, DND.DROP_DEFAULT - | DND.DROP_COPY); + DropTarget dnd_target = new DropTarget(this.drop_area, DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK); final FileTransfer fileTransfer = FileTransfer.getInstance(); Transfer[] types = new Transfer[] { fileTransfer }; dnd_target.setTransfer(types); @@ -202,7 +198,6 @@ public class DataSourceSelectComposite extends StateComposite { dnd_target.addDropListener(new DropTargetAdapter() { @Override public void drop(DropTargetEvent event) { - log.debug("Drop received: " + event); //$NON-NLS-1$ if (fileTransfer.isSupportedType(event.currentDataType)) { if (event.data == null) { log.error("Dropped file name was null"); //$NON-NLS-1$ @@ -223,43 +218,23 @@ public class DataSourceSelectComposite extends StateComposite { @Override public void dragOperationChanged(DropTargetEvent event) { - if (event.detail == DND.DROP_DEFAULT) { - if ((event.operations & DND.DROP_COPY) != 0) { - event.detail = DND.DROP_COPY; - } else { - event.detail = DND.DROP_NONE; - } - } + event.detail = DND.DROP_COPY; } @Override public void dragEnter(DropTargetEvent event) { - if (event.detail == DND.DROP_DEFAULT) { - if ((event.operations & DND.DROP_COPY) != 0) { - event.detail = DND.DROP_COPY; - MarkDragEnter(); - } else { - event.detail = DND.DROP_NONE; - } - } - // Only drop one item! - if (event.dataTypes.length > 1) { - event.detail = DND.DROP_NONE; - return; - } - // will accept text but prefer to have files dropped + // only accept transferable files for (int i = 0; i < event.dataTypes.length; i++) { if (fileTransfer.isSupportedType(event.dataTypes[i])) { event.currentDataType = event.dataTypes[i]; - // files should only be copied - if (event.detail != DND.DROP_COPY) { - event.detail = DND.DROP_NONE; - } - break; + event.detail = DND.DROP_COPY; + MarkDragEnter(); + return; } } + event.detail = DND.DROP_NONE; } - + /* (non-Javadoc) * @see org.eclipse.swt.dnd.DropTargetAdapter#dragLeave(org.eclipse.swt.dnd.DropTargetEvent) */ -- cgit v1.2.3