diff options
author | Lakshmi Shanmugam | 2015-10-23 08:13:25 +0000 |
---|---|---|
committer | Lakshmi Shanmugam | 2017-08-11 11:44:04 +0000 |
commit | a99439d30a7b8da847601ddd9043ac241ce028e9 (patch) | |
tree | be5e70e99f9afc317dd7558d51ddcce1c584a76d /bundles/org.eclipse.swt/Eclipse SWT PI | |
parent | d81458a98525bf0b98909d362bde0ba3e3199d56 (diff) | |
download | eclipse.platform.swt-a99439d30a7b8da847601ddd9043ac241ce028e9.tar.gz eclipse.platform.swt-a99439d30a7b8da847601ddd9043ac241ce028e9.tar.xz eclipse.platform.swt-a99439d30a7b8da847601ddd9043ac241ce028e9.zip |
Bug 467205 - [10.10] FileDialog/DirectoryDialog with SWT.SHEET misplacedI20170811-2000
after slide-down animation
Replaced deprecated NSSavePanel and NSOpenPanel APIs with newer ones.
The new API NSSavePanel.beginSheetModalForWindow that is required to
show the Sheet, uses objective-c block for completion
handler. This call can't be made directly from Java, as Java doesn't
support the block syntax (^). Hence, it is called from a wrapper
function inside C code in os_custom.c. The wrapper function calls
beginSheetModalForWindow with the objective C block syntax. The
completion handler block is also implemented in os_custom.c which
callsback to the Java
functionFileDialog/DirectoryDialog._completionHandler().
Change-Id: Ib03881a68ef7ecaf2132cf91a4137aef8b6fe3fc
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI')
7 files changed, 76 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c index 08fac00104..398f0c961e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/library/os_custom.c @@ -238,3 +238,35 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(NSAccessibilityRowIndexRangeAttribute) } #endif +typedef void (*FunctionPointer)(jintLong result); +typedef void (^ObjcBlock)(jintLong result); + +/* +Method that takes a function pointer as input and returns a objective-c block +which calls the function pointed to by the function pointer. +*/ +ObjcBlock functionToBlock(FunctionPointer func) { + return [[^(jintLong result) { + func(result); + } copy] autorelease]; +} + +/* +Wrapper function which receives a function pointer from Java and calls NSSavePanel.beginSheetModalForWindow +with objective-C block (with block syntax) as the last parameter. +*/ +#ifndef NO_beginSheetModalForWindow +JNIEXPORT jintLong JNICALL OS_NATIVE(beginSheetModalForWindow) + (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jintLong arg2, FunctionPointer arg3) +{ + jintLong rc = 0; + + OS_NATIVE_ENTER(env, that, beginSheetModalForWindow_FUNC); + + rc = (jintLong)((jintLong (*)(jintLong, jintLong, jintLong, void (^)(jintLong)))objc_msgSend)(arg0, arg1, arg2, functionToBlock(arg3)); + + OS_NATIVE_EXIT(env, that, beginSheetModalForWindow_FUNC); + return rc; +} +#endif + 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 985d265455..bac2ebb6a5 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 @@ -448,6 +448,7 @@ char * OS_nativeFunctionNames[] = { "UTTypeEqual", "UnionRgn", "_1_1BIG_1ENDIAN_1_1", + "beginSheetModalForWindow", "call", "class_1addIvar", "class_1addMethod", 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 1d72006f83..3fcc56dfe6 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 @@ -458,6 +458,7 @@ typedef enum { UTTypeEqual_FUNC, UnionRgn_FUNC, _1_1BIG_1ENDIAN_1_1_FUNC, + beginSheetModalForWindow_FUNC, call_FUNC, class_1addIvar_FUNC, class_1addMethod_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras index 9d196bf08e..107326b8c9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras @@ -181,6 +181,9 @@ <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> </method> + <method selector="stopModal" swt_gen="true"> + <retval swt_gen="true"></retval> + </method> <method selector="terminate:" swt_gen="true"> <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> @@ -2799,10 +2802,18 @@ <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> </method> + <method selector="setDirectoryURL:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> <method selector="setMessage:" swt_gen="true"> <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> </method> + <method selector="setNameFieldStringValue:" swt_gen="true"> + <arg swt_gen="true"></arg> + <retval swt_gen="true"></retval> + </method> <method selector="setTitle:" swt_gen="true"> <arg swt_gen="true"></arg> <retval swt_gen="true"></retval> diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSApplication.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSApplication.java index bcfc7e752e..6bd75b3d67 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSApplication.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSApplication.java @@ -161,6 +161,10 @@ public void stop(id sender) { OS.objc_msgSend(this.id, OS.sel_stop_, sender != null ? sender.id : 0); } +public void stopModal() { + OS.objc_msgSend(this.id, OS.sel_stopModal); +} + public void terminate(id sender) { OS.objc_msgSend(this.id, OS.sel_terminate_, sender != null ? sender.id : 0); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java index 8b6b3d5213..c590a29d5c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSSavePanel.java @@ -62,10 +62,18 @@ public void setDirectory(NSString path) { OS.objc_msgSend(this.id, OS.sel_setDirectory_, path != null ? path.id : 0); } +public void setDirectoryURL(NSURL directoryURL) { + OS.objc_msgSend(this.id, OS.sel_setDirectoryURL_, directoryURL != null ? directoryURL.id : 0); +} + public void setMessage(NSString message) { OS.objc_msgSend(this.id, OS.sel_setMessage_, message != null ? message.id : 0); } +public void setNameFieldStringValue(NSString nameFieldStringValue) { + OS.objc_msgSend(this.id, OS.sel_setNameFieldStringValue_, nameFieldStringValue != null ? nameFieldStringValue.id : 0); +} + public void setTitle(NSString title) { OS.objc_msgSend(this.id, OS.sel_setTitle_, title != null ? title.id : 0); } 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 1642111f6a..9e6ce3da39 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 @@ -130,6 +130,8 @@ public class OS extends C { public static final long /*int*/ sel_setQuota = sel_registerName( "setQuota:" ); public static final long /*int*/ sel_webView_frame_exceededDatabaseQuotaForSecurityOrigin_database_ = sel_registerName( "webView:frame:exceededDatabaseQuotaForSecurityOrigin:database:" ); + public static final long /*int*/ sel_beginSheetModalForWindow_completionHandler_ = sel_registerName("beginSheetModalForWindow:completionHandler:"); + /* These are not generated in order to avoid creating static methods on all classes */ public static final long /*int*/ sel_isSelectorExcludedFromWebScript_ = sel_registerName("isSelectorExcludedFromWebScript:"); public static final long /*int*/ sel_webScriptNameForSelector_ = sel_registerName("webScriptNameForSelector:"); @@ -184,6 +186,19 @@ public class OS extends C { public static final long /*int*/ class_NSToolbarView = objc_getClass("NSToolbarView"); + /* + * Wrapper function which will call NSSavePanel.beginSheetModalForWindow. This + * implementation allows passing of objective-C block from Java to C code, and + * receives a callback from the block to a Java function. Here, handler is a + * the function pointer of the function that will be called by the objective-C + * block. + */ + /** @method flags=no_gen*/ + public static native void beginSheetModalForWindow(long id, long sel, long window, long handler); + public static void beginSheetModalForWindow(NSPanel id, NSWindow window, long handler) { + OS.beginSheetModalForWindow(id.id, OS.sel_beginSheetModalForWindow_completionHandler_, window != null ? window.id : 0, handler); + } + /** JNI natives */ /** @method flags=jni */ @@ -1912,6 +1927,7 @@ public static final long /*int*/ sel_setDelegate_ = sel_registerName("setDelegat public static final long /*int*/ sel_setDestination_allowOverwrite_ = sel_registerName("setDestination:allowOverwrite:"); public static final long /*int*/ sel_setDictionary_ = sel_registerName("setDictionary:"); public static final long /*int*/ sel_setDirectory_ = sel_registerName("setDirectory:"); +public static final long /*int*/ sel_setDirectoryURL_ = sel_registerName("setDirectoryURL:"); public static final long /*int*/ sel_setDisplayMode_ = sel_registerName("setDisplayMode:"); public static final long /*int*/ sel_setDisplaysLinkToolTips_ = sel_registerName("setDisplaysLinkToolTips:"); public static final long /*int*/ sel_setDocumentCursor_ = sel_registerName("setDocumentCursor:"); @@ -2014,6 +2030,7 @@ public static final long /*int*/ sel_setMinimumFractionDigits_ = sel_registerNam public static final long /*int*/ sel_setMinimumIntegerDigits_ = sel_registerName("setMinimumIntegerDigits:"); public static final long /*int*/ sel_setMiterLimit_ = sel_registerName("setMiterLimit:"); public static final long /*int*/ sel_setMovable_ = sel_registerName("setMovable:"); +public static final long /*int*/ sel_setNameFieldStringValue_ = sel_registerName("setNameFieldStringValue:"); public static final long /*int*/ sel_setNeedsDisplay_ = sel_registerName("setNeedsDisplay:"); public static final long /*int*/ sel_setNeedsDisplayInRect_ = sel_registerName("setNeedsDisplayInRect:"); public static final long /*int*/ sel_setNumberOfVisibleItems_ = sel_registerName("setNumberOfVisibleItems:"); @@ -2136,6 +2153,7 @@ public static final long /*int*/ sel_statusItemWithLength_ = sel_registerName("s public static final long /*int*/ sel_stop_ = sel_registerName("stop:"); public static final long /*int*/ sel_stopAnimation_ = sel_registerName("stopAnimation:"); public static final long /*int*/ sel_stopLoading_ = sel_registerName("stopLoading:"); +public static final long /*int*/ sel_stopModal = sel_registerName("stopModal"); public static final long /*int*/ sel_string = sel_registerName("string"); public static final long /*int*/ sel_stringByAddingPercentEscapesUsingEncoding_ = sel_registerName("stringByAddingPercentEscapesUsingEncoding:"); public static final long /*int*/ sel_stringByAppendingPathComponent_ = sel_registerName("stringByAppendingPathComponent:"); @@ -4405,4 +4423,5 @@ public static final native void memmove(long /*int*/ dest, NSSize src, long /*in public static final native void memmove(NSSize dest, long /*int*/ src, long /*int*/ size); /** This section is auto generated */ + } |