From aa5a5aaebe142abd891a4f8f1fad06bf51ae6ae6 Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Fri, 28 Sep 2012 10:47:37 -0400 Subject: Bug 385258 - dragSetData calls before dropAccept in Cocoa DND with FileTransfer - use OS const instead of public.file-url --- .../cocoa/org/eclipse/swt/dnd/Clipboard.java | 4 ++-- .../cocoa/org/eclipse/swt/dnd/DragSource.java | 2 +- .../cocoa/org/eclipse/swt/dnd/DropTarget.java | 2 +- .../cocoa/org/eclipse/swt/dnd/FileTransfer.java | 2 +- bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c | 12 ++++++++++++ .../org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c | 1 + .../org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h | 1 + .../cocoa/org/eclipse/swt/internal/cocoa/OS.java | 3 +++ 8 files changed, 22 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java index 1e6cb58bed..8b107b42f6 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/Clipboard.java @@ -289,7 +289,7 @@ public Object getContents(Transfer transfer, int clipboards) { type.isEqual(OS.NSRTFPboardType) || type.isEqual(OS.NSHTMLPboardType)) { tdata.data = pasteboard.stringForType(type); - } else if (type.isEqual(OS.NSFilenamesPboardType) || type.getString().equals("public.file-url")) { + } else if (type.isEqual(OS.NSFilenamesPboardType) || type.isEqual(OS.kUTTypeFileURL)) { tdata.data = new NSArray(pasteboard.propertyListForType(OS.NSFilenamesPboardType).id); } else if (type.isEqual(OS.NSURLPboardType) || type.isEqual(OS.kUTTypeURL)) { tdata.data = NSURL.URLFromPasteboard(pasteboard); @@ -462,7 +462,7 @@ public void setContents(Object[] data, Transfer[] dataTypes, int clipboards) { } else if (dataType.isEqual(OS.NSURLPboardType) || dataType.isEqual(OS.kUTTypeURL)) { NSURL url = (NSURL) tdata; url.writeToPasteboard(pasteboard); - } else if (dataType.isEqual(OS.NSFilenamesPboardType) || dataType.getString().equals("public.file-url")) { + } else if (dataType.isEqual(OS.NSFilenamesPboardType) || dataType.isEqual(OS.kUTTypeFileURL)) { pasteboard.setPropertyList((NSArray) tdata, OS.NSFilenamesPboardType); } else { pasteboard.setData((NSData) tdata, dataType); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java index f98c486ae0..59634a60b3 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DragSource.java @@ -754,7 +754,7 @@ void pasteboard_provideDataForType(long /*int*/ id, long /*int*/ sel, long /*int } else if (dataType.isEqual(OS.NSURLPboardType) || dataType.isEqual(OS.kUTTypeURL)) { NSURL url = (NSURL) tdata; url.writeToPasteboard(pasteboard); - } else if (dataType.isEqual(OS.NSFilenamesPboardType) || dataType.getString().equals("public.file-url")) { + } else if (dataType.isEqual(OS.NSFilenamesPboardType) || dataType.isEqual(OS.kUTTypeFileURL)) { NSArray array = (NSArray) transferData.data; int count = (int) /*64*/ array.count(); paths = new String[count]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java index ca8e836298..aa8b71eac5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java @@ -694,7 +694,7 @@ boolean drop(NSObject sender) { tdata.data = pasteboard.stringForType(type); } else if (type.isEqual(OS.NSURLPboardType) || type.isEqual(OS.kUTTypeURL)) { tdata.data = NSURL.URLFromPasteboard(pasteboard); - } else if (type.isEqual(OS.NSFilenamesPboardType) || type.getString().equals("public.file-url")) { + } else if (type.isEqual(OS.NSFilenamesPboardType) || type.isEqual(OS.kUTTypeFileURL)) { tdata.data = new NSArray(pasteboard.propertyListForType(OS.NSFilenamesPboardType).id); } else { tdata.data = pasteboard.dataForType(type); diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java index 7d821e521d..a9a11a965a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/FileTransfer.java @@ -38,7 +38,7 @@ public class FileTransfer extends ByteArrayTransfer { static FileTransfer _instance = new FileTransfer(); static final String ID_NAME = OS.NSFilenamesPboardType.getString(); static final int ID = registerType(ID_NAME); - static final String ID1_NAME = "public.file-url"; + static final String ID1_NAME = OS.kUTTypeFileURL.getString(); static final int ID1 = registerType(ID1_NAME); FileTransfer() {} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c index 4265e29710..21b99210cf 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os.c @@ -6276,6 +6276,18 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(kCTParagraphStyleAttributeName) } #endif +#ifndef NO_kUTTypeFileURL +JNIEXPORT jintLong JNICALL OS_NATIVE(kUTTypeFileURL) + (JNIEnv *env, jclass that) +{ + jintLong rc = 0; + OS_NATIVE_ENTER(env, that, kUTTypeFileURL_FUNC); + rc = (jintLong)kUTTypeFileURL; + OS_NATIVE_EXIT(env, that, kUTTypeFileURL_FUNC); + return rc; +} +#endif + #ifndef NO_kUTTypeURL JNIEXPORT jintLong JNICALL OS_NATIVE(kUTTypeURL) (JNIEnv *env, jclass that) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c index bc7ced2440..a36dfd3067 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.c @@ -465,6 +465,7 @@ char * OS_nativeFunctionNames[] = { "kCTForegroundColorAttributeName", "kCTParagraphStyleAttributeName", "kTISPropertyUnicodeKeyLayoutData", + "kUTTypeFileURL", "kUTTypeURL", #ifndef JNI64 "memmove__ILorg_eclipse_swt_internal_cocoa_CFRange_2I", diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h index 908ae58737..dd2199afa1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_stats.h @@ -475,6 +475,7 @@ typedef enum { kCTForegroundColorAttributeName_FUNC, kCTParagraphStyleAttributeName_FUNC, kTISPropertyUnicodeKeyLayoutData_FUNC, + kUTTypeFileURL_FUNC, kUTTypeURL_FUNC, #ifndef JNI64 memmove__ILorg_eclipse_swt_internal_cocoa_CFRange_2I_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java index 426a229703..cee3d8203a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java @@ -535,6 +535,9 @@ public static final native long /*int*/ kCFTypeDictionaryKeyCallBacks(); /** @method flags=const address*/ public static final native long /*int*/ kCFTypeDictionaryValueCallBacks(); +/** @method flags=const */ +public static final native long /*int*/ kUTTypeFileURL(); +public static final NSString kUTTypeFileURL = new NSString(kUTTypeFileURL()); /** @method flags=const */ public static final native long /*int*/ kUTTypeURL(); public static final NSString kUTTypeURL = new NSString(kUTTypeURL()); -- cgit