From 151ef65b13f5de0541270de79370a5f60d3b090d Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Wed, 20 Jun 2012 10:47:58 -0400 Subject: Bug 383069 - SWT Cocoa's URLTransfer does not return correct file url on Mac OS X --- .../cocoa/org/eclipse/swt/dnd/URLTransfer.java | 1 + .../eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras | 4 ++++ .../cocoa/org/eclipse/swt/internal/cocoa/NSString.java | 5 +++++ .../Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java | 1 + 4 files changed, 11 insertions(+) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java index 2982c0a69c..c316886fa9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/URLTransfer.java @@ -78,6 +78,7 @@ public Object nativeToJava(TransferData transferData){ if (!isSupportedType(transferData) || transferData.data == null) return null; NSURL nsUrl = (NSURL) transferData.data; NSString nsString = nsUrl.absoluteString(); + nsString = nsString.stringByReplacingPercentEscapesUsingEncoding(OS.NSUTF8StringEncoding); return nsString.getString(); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras index ba8bfd3f46..f556849dd2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras @@ -968,6 +968,10 @@ + + + + diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java index 4cd074f24e..ed953f8a9c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSString.java @@ -134,6 +134,11 @@ public NSString stringByReplacingOccurrencesOfString(NSString target, NSString r return result == this.id ? this : (result != 0 ? new NSString(result) : null); } +public NSString stringByReplacingPercentEscapesUsingEncoding(int /*long*/ enc) { + int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_stringByReplacingPercentEscapesUsingEncoding_, enc); + return result == this.id ? this : (result != 0 ? new NSString(result) : null); +} + public static NSString stringWithCharacters(char[] characters, int /*long*/ length) { int /*long*/ result = OS.objc_msgSend(OS.class_NSString, OS.sel_stringWithCharacters_length_, characters, length); return result != 0 ? new NSString(result) : null; 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 dbd1eccbc0..e18fd42a20 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 @@ -2087,6 +2087,7 @@ public static final int /*long*/ sel_stringByAppendingString_ = sel_registerName public static final int /*long*/ sel_stringByDeletingLastPathComponent = sel_registerName("stringByDeletingLastPathComponent"); public static final int /*long*/ sel_stringByDeletingPathExtension = sel_registerName("stringByDeletingPathExtension"); public static final int /*long*/ sel_stringByReplacingOccurrencesOfString_withString_ = sel_registerName("stringByReplacingOccurrencesOfString:withString:"); +public static final int /*long*/ sel_stringByReplacingPercentEscapesUsingEncoding_ = sel_registerName("stringByReplacingPercentEscapesUsingEncoding:"); public static final int /*long*/ sel_stringForObjectValue_ = sel_registerName("stringForObjectValue:"); public static final int /*long*/ sel_stringForType_ = sel_registerName("stringForType:"); public static final int /*long*/ sel_stringValue = sel_registerName("stringValue"); -- cgit