< prev index next >

src/java.desktop/macosx/native/libawt_lwawt/awt/ApplicationDelegate.m

Print this page
rev 54094 : 8257853: Remove dependencies on JNF's JNI utility functions in AWT and 2D code
rev 54096 : 8259651: [macOS] Replace JNF_COCOA_ENTER/EXIT macros
rev 54098 : 8260616: Removing remaining JNF dependencies in the java.desktop module
8259729: Missed JNFInstanceOf -> IsInstanceOf conversion

*** 30,44 **** #import "com_apple_eawt__AppEventHandler.h" #import "com_apple_eawt__AppMenuBarHandler.h" #import "com_apple_eawt__AppMenuBarHandler.h" #import "com_apple_eawt__AppMiscHandlers.h" - #import <JavaNativeFoundation/JavaNativeFoundation.h> - #import "CPopupMenu.h" #import "ThreadUtilities.h" #import "NSApplicationAWT.h" #pragma mark App Menu helpers // The following is a AWT convention? --- 30,43 ---- #import "com_apple_eawt__AppEventHandler.h" #import "com_apple_eawt__AppMenuBarHandler.h" #import "com_apple_eawt__AppMenuBarHandler.h" #import "com_apple_eawt__AppMiscHandlers.h" #import "CPopupMenu.h" #import "ThreadUtilities.h" #import "NSApplicationAWT.h" + #import "JNIUtilities.h" #pragma mark App Menu helpers // The following is a AWT convention?
*** 241,253 **** BOOL prefsAvailable = ([self.fPreferencesMenu menu] != nil); BOOL prefsEnabled = (prefsAvailable && [self.fPreferencesMenu isEnabled] && ([self.fPreferencesMenu target] != nil)); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! static JNF_CLASS_CACHE(sjc_AppMenuBarHandler, "com/apple/eawt/_AppMenuBarHandler"); ! static JNF_STATIC_MEMBER_CACHE(sjm_initMenuStates, sjc_AppMenuBarHandler, "initMenuStates", "(ZZZZ)V"); ! JNFCallStaticVoidMethod(env, sjm_initMenuStates, aboutAvailable, aboutEnabled, prefsAvailable, prefsEnabled); // register for the finish launching and system power off notifications by default NSNotificationCenter *ctr = [NSNotificationCenter defaultCenter]; Class clz = [ApplicationDelegate class]; [ctr addObserver:clz selector:@selector(_willFinishLaunching) name:NSApplicationWillFinishLaunchingNotification object:nil]; --- 240,254 ---- BOOL prefsAvailable = ([self.fPreferencesMenu menu] != nil); BOOL prefsEnabled = (prefsAvailable && [self.fPreferencesMenu isEnabled] && ([self.fPreferencesMenu target] != nil)); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! DECLARE_CLASS_RETURN(sjc_AppMenuBarHandler, "com/apple/eawt/_AppMenuBarHandler", NULL); ! DECLARE_STATIC_METHOD_RETURN(sjm_initMenuStates, sjc_AppMenuBarHandler, "initMenuStates", "(ZZZZ)V", NULL); ! (*env)->CallStaticVoidMethod(env, sjc_AppMenuBarHandler, sjm_initMenuStates, ! aboutAvailable, aboutEnabled, prefsAvailable, prefsEnabled); ! CHECK_EXCEPTION(); // register for the finish launching and system power off notifications by default NSNotificationCenter *ctr = [NSNotificationCenter defaultCenter]; Class clz = [ApplicationDelegate class]; [ctr addObserver:clz selector:@selector(_willFinishLaunching) name:NSApplicationWillFinishLaunchingNotification object:nil];
*** 270,308 **** [super dealloc]; } #pragma mark Callbacks from AppKit ! static JNF_CLASS_CACHE(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler"); - (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent { AWT_ASSERT_APPKIT_THREAD; if (!fHandlesURLTypes) return; NSString *url = [[openURLEvent paramDescriptorForKeyword:keyDirectObject] stringValue]; //fprintf(stderr,"jm_handleOpenURL\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jstring jURL = JNFNSToJavaString(env, url); ! static JNF_STATIC_MEMBER_CACHE(jm_handleOpenURI, sjc_AppEventHandler, "handleOpenURI", "(Ljava/lang/String;)V"); ! JNFCallStaticVoidMethod(env, jm_handleOpenURI, jURL); // AWT_THREADING Safe (event) (*env)->DeleteLocalRef(env, jURL); [replyEvent insertDescriptor:[NSAppleEventDescriptor nullDescriptor] atIndex:0]; } // Helper for both open file and print file methods // Creates a Java list of files from a native list of files - (jobject)_createFilePathArrayFrom:(NSArray *)filenames withEnv:(JNIEnv *)env { ! static JNF_CLASS_CACHE(sjc_ArrayList, "java/util/ArrayList"); ! static JNF_CTOR_CACHE(jm_ArrayList_ctor, sjc_ArrayList, "(I)V"); ! static JNF_MEMBER_CACHE(jm_ArrayList_add, sjc_ArrayList, "add", "(Ljava/lang/Object;)Z"); - jobject jFileNamesArray = JNFNewObject(env, jm_ArrayList_ctor, (jint)[filenames count]); // AWT_THREADING Safe (known object) for (NSString *filename in filenames) { ! jstring jFileName = JNFNormalizedJavaStringForPath(env, filename); ! JNFCallVoidMethod(env, jFileNamesArray, jm_ArrayList_add, jFileName); } return jFileNamesArray; } --- 271,324 ---- [super dealloc]; } #pragma mark Callbacks from AppKit ! static jclass sjc_AppEventHandler = NULL; ! #define GET_APPEVENTHANDLER_CLASS() \ ! GET_CLASS(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler"); ! ! #define GET_APPEVENTHANDLER_CLASS_RETURN(ret) \ ! GET_CLASS_RETURN(sjc_AppEventHandler, "com/apple/eawt/_AppEventHandler", ret); - (void)_handleOpenURLEvent:(NSAppleEventDescriptor *)openURLEvent withReplyEvent:(NSAppleEventDescriptor *)replyEvent { AWT_ASSERT_APPKIT_THREAD; if (!fHandlesURLTypes) return; NSString *url = [[openURLEvent paramDescriptorForKeyword:keyDirectObject] stringValue]; //fprintf(stderr,"jm_handleOpenURL\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! jstring jURL = NSStringToJavaString(env, url); ! GET_APPEVENTHANDLER_CLASS(); ! DECLARE_STATIC_METHOD(jm_handleOpenURI, sjc_AppEventHandler, "handleOpenURI", "(Ljava/lang/String;)V"); ! (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenURI, jURL); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, jURL); [replyEvent insertDescriptor:[NSAppleEventDescriptor nullDescriptor] atIndex:0]; } // Helper for both open file and print file methods // Creates a Java list of files from a native list of files - (jobject)_createFilePathArrayFrom:(NSArray *)filenames withEnv:(JNIEnv *)env { ! static jclass sjc_ArrayList = NULL; ! if (sjc_ArrayList == NULL) { ! sjc_ArrayList = (*env)->FindClass(env, "java/util/ArrayList"); ! if (sjc_ArrayList != NULL) sjc_ArrayList = (*env)->NewGlobalRef(env, sjc_ArrayList); \ ! } ! CHECK_NULL_RETURN(sjc_ArrayList, NULL); ! DECLARE_METHOD_RETURN(jm_ArrayList_ctor, sjc_ArrayList, "<init>", "(I)V", NULL); ! DECLARE_METHOD_RETURN(jm_ArrayList_add, sjc_ArrayList, "add", "(Ljava/lang/Object;)Z", NULL); ! ! jobject jFileNamesArray = (*env)->NewObject(env, sjc_ArrayList, jm_ArrayList_ctor, (jint)[filenames count]); ! CHECK_EXCEPTION_NULL_RETURN(jFileNamesArray, NULL); for (NSString *filename in filenames) { ! jstring jFileName = NormalizedPathJavaStringFromNSString(env, filename); ! (*env)->CallVoidMethod(env, jFileNamesArray, jm_ArrayList_add, jFileName); ! CHECK_EXCEPTION(); } return jFileNamesArray; }
*** 318,334 **** JNIEnv *env = [ThreadUtilities getJNIEnv]; // if these files were opened from a Spotlight query, try to get the search text from the current AppleEvent NSAppleEventDescriptor *currentEvent = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; NSString *searchString = [[currentEvent paramDescriptorForKeyword:keyAESearchText] stringValue]; ! jstring jSearchString = JNFNSToJavaString(env, searchString); // convert the file names array jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env]; ! static JNF_STATIC_MEMBER_CACHE(jm_handleOpenFiles, sjc_AppEventHandler, "handleOpenFiles", "(Ljava/util/List;Ljava/lang/String;)V"); ! JNFCallStaticVoidMethod(env, jm_handleOpenFiles, jFileNamesArray, jSearchString); (*env)->DeleteLocalRef(env, jFileNamesArray); (*env)->DeleteLocalRef(env, jSearchString); [theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; } --- 334,353 ---- JNIEnv *env = [ThreadUtilities getJNIEnv]; // if these files were opened from a Spotlight query, try to get the search text from the current AppleEvent NSAppleEventDescriptor *currentEvent = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; NSString *searchString = [[currentEvent paramDescriptorForKeyword:keyAESearchText] stringValue]; ! jstring jSearchString = NSStringToJavaString(env, searchString); // convert the file names array jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env]; ! GET_APPEVENTHANDLER_CLASS(); ! DECLARE_STATIC_METHOD(jm_handleOpenFiles, sjc_AppEventHandler, ! "handleOpenFiles", "(Ljava/util/List;Ljava/lang/String;)V"); ! (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleOpenFiles, jFileNamesArray, jSearchString); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, jFileNamesArray); (*env)->DeleteLocalRef(env, jSearchString); [theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; }
*** 339,350 **** if (!fHandlesDocumentTypes) return NSPrintingCancelled; //fprintf(stderr,"jm_handlePrintFile\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env]; ! static JNF_STATIC_MEMBER_CACHE(jm_handlePrintFile, sjc_AppEventHandler, "handlePrintFiles", "(Ljava/util/List;)V"); ! JNFCallStaticVoidMethod(env, jm_handlePrintFile, jFileNamesArray); // AWT_THREADING Safe (event) (*env)->DeleteLocalRef(env, jFileNamesArray); return NSPrintingSuccess; } --- 358,372 ---- if (!fHandlesDocumentTypes) return NSPrintingCancelled; //fprintf(stderr,"jm_handlePrintFile\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; jobject jFileNamesArray = [self _createFilePathArrayFrom:fileNames withEnv:env]; ! GET_APPEVENTHANDLER_CLASS_RETURN(NSPrintingCancelled); ! DECLARE_STATIC_METHOD_RETURN(jm_handlePrintFile, sjc_AppEventHandler, ! "handlePrintFiles", "(Ljava/util/List;)V", NSPrintingCancelled); ! (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handlePrintFile, jFileNamesArray); ! CHECK_EXCEPTION(); (*env)->DeleteLocalRef(env, jFileNamesArray); return NSPrintingSuccess; }
*** 352,363 **** + (void)_notifyJava:(jint)notificationType { AWT_ASSERT_APPKIT_THREAD; //fprintf(stderr,"jm_handleOpenApplication\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! static JNF_STATIC_MEMBER_CACHE(jm_handleNativeNotification, sjc_AppEventHandler, "handleNativeNotification", "(I)V"); ! JNFCallStaticVoidMethod(env, jm_handleNativeNotification, notificationType); // AWT_THREADING Safe (event) } // About menu handler - (void)_aboutMenuHandler { [ApplicationDelegate _notifyJava:com_apple_eawt__AppEventHandler_NOTIFY_ABOUT]; --- 374,387 ---- + (void)_notifyJava:(jint)notificationType { AWT_ASSERT_APPKIT_THREAD; //fprintf(stderr,"jm_handleOpenApplication\n"); JNIEnv *env = [ThreadUtilities getJNIEnv]; ! GET_APPEVENTHANDLER_CLASS(); ! DECLARE_STATIC_METHOD(jm_handleNativeNotification, sjc_AppEventHandler, "handleNativeNotification", "(I)V"); ! (*env)->CallStaticVoidMethod(env, sjc_AppEventHandler, jm_handleNativeNotification, notificationType); ! CHECK_EXCEPTION(); } // About menu handler - (void)_aboutMenuHandler { [ApplicationDelegate _notifyJava:com_apple_eawt__AppEventHandler_NOTIFY_ABOUT];
*** 542,662 **** * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt_Application_nativeInitializeApplicationDelegate (JNIEnv *env, jclass clz) { ! JNF_COCOA_ENTER(env); // Force initialization to happen on AppKit thread! [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ApplicationDelegate sharedDelegate]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppEventHandler * Method: nativeOpenCocoaAboutWindow * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeOpenCocoaAboutWindow (JNIEnv *env, jclass clz) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp orderFrontStandardAboutPanel:nil]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppEventHandler * Method: nativeReplyToAppShouldTerminate * Signature: (Z)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeReplyToAppShouldTerminate (JNIEnv *env, jclass clz, jboolean doTerminate) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp replyToApplicationShouldTerminate:doTerminate]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppEventHandler * Method: nativeRegisterForNotification * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeRegisterForNotification (JNIEnv *env, jclass clz, jint notificationType) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(_registerForNotification:) on:[ApplicationDelegate class] withObject:[NSNumber numberWithInt:notificationType] ! waitUntilDone:NO]; // AWT_THREADING Safe (non-blocking) ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeSetDockMenu * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockMenu (JNIEnv *env, jclass clz, jlong nsMenuPtr) { ! JNF_COCOA_ENTER(env); NSMenu *menu = (NSMenu *)jlong_to_ptr(nsMenuPtr); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ApplicationDelegate sharedDelegate].fDockMenu = menu; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeSetDockIconImage * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconImage (JNIEnv *env, jclass clz, jlong nsImagePtr) { ! JNF_COCOA_ENTER(env); NSImage *_image = (NSImage *)jlong_to_ptr(nsImagePtr); [ThreadUtilities performOnMainThread:@selector(_setDockIconImage:) on:[ApplicationDelegate class] withObject:_image waitUntilDone:NO]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeSetDockIconProgress * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconProgress (JNIEnv *env, jclass clz, jint value) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(_setDockIconProgress:) on:[ApplicationDelegate class] withObject:[NSNumber numberWithInt:value] waitUntilDone:NO]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeGetDockIconImage --- 566,686 ---- * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt_Application_nativeInitializeApplicationDelegate (JNIEnv *env, jclass clz) { ! JNI_COCOA_ENTER(env); // Force initialization to happen on AppKit thread! [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ApplicationDelegate sharedDelegate]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppEventHandler * Method: nativeOpenCocoaAboutWindow * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeOpenCocoaAboutWindow (JNIEnv *env, jclass clz) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp orderFrontStandardAboutPanel:nil]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppEventHandler * Method: nativeReplyToAppShouldTerminate * Signature: (Z)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeReplyToAppShouldTerminate (JNIEnv *env, jclass clz, jboolean doTerminate) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp replyToApplicationShouldTerminate:doTerminate]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppEventHandler * Method: nativeRegisterForNotification * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppEventHandler_nativeRegisterForNotification (JNIEnv *env, jclass clz, jint notificationType) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(_registerForNotification:) on:[ApplicationDelegate class] withObject:[NSNumber numberWithInt:notificationType] ! waitUntilDone:NO]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeSetDockMenu * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockMenu (JNIEnv *env, jclass clz, jlong nsMenuPtr) { ! JNI_COCOA_ENTER(env); NSMenu *menu = (NSMenu *)jlong_to_ptr(nsMenuPtr); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ [ApplicationDelegate sharedDelegate].fDockMenu = menu; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeSetDockIconImage * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconImage (JNIEnv *env, jclass clz, jlong nsImagePtr) { ! JNI_COCOA_ENTER(env); NSImage *_image = (NSImage *)jlong_to_ptr(nsImagePtr); [ThreadUtilities performOnMainThread:@selector(_setDockIconImage:) on:[ApplicationDelegate class] withObject:_image waitUntilDone:NO]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeSetDockIconProgress * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconProgress (JNIEnv *env, jclass clz, jint value) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(_setDockIconProgress:) on:[ApplicationDelegate class] withObject:[NSNumber numberWithInt:value] waitUntilDone:NO]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppDockIconHandler * Method: nativeGetDockIconImage
*** 665,681 **** JNIEXPORT jlong JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeGetDockIconImage (JNIEnv *env, jclass clz) { __block NSImage *image = nil; ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ image = [[ApplicationDelegate _dockIconImage] retain]; }]; ! JNF_COCOA_EXIT(env); return ptr_to_jlong(image); } /* --- 689,705 ---- JNIEXPORT jlong JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeGetDockIconImage (JNIEnv *env, jclass clz) { __block NSImage *image = nil; ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ image = [[ApplicationDelegate _dockIconImage] retain]; }]; ! JNI_COCOA_EXIT(env); return ptr_to_jlong(image); } /*
*** 684,798 **** * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconBadge (JNIEnv *env, jclass clz, jstring badge) { ! JNF_COCOA_ENTER(env); ! NSString *badgeString = JNFJavaToNSString(env, badge); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSDockTile *dockTile = [NSApp dockTile]; [dockTile setBadgeLabel:badgeString]; [dockTile display]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeRequestActivation * Signature: (Z)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestActivation (JNIEnv *env, jclass clz, jboolean allWindows) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSApplicationActivationOptions options = allWindows ? NSApplicationActivateAllWindows : 0; options |= NSApplicationActivateIgnoringOtherApps; // without this, nothing happens! [[NSRunningApplication currentApplication] activateWithOptions:options]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeRequestUserAttention * Signature: (Z)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestUserAttention (JNIEnv *env, jclass clz, jboolean critical) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp requestUserAttention:critical ? NSCriticalRequest : NSInformationalRequest]; }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeOpenHelpViewer * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeOpenHelpViewer (JNIEnv *env, jclass clz) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(showHelp:) on:NSApp withObject:nil waitUntilDone:NO]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeEnableSuddenTermination * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeEnableSuddenTermination (JNIEnv *env, jclass clz) { ! JNF_COCOA_ENTER(env); [[NSProcessInfo processInfo] enableSuddenTermination]; // Foundation thread-safe ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeDisableSuddenTermination * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeDisableSuddenTermination (JNIEnv *env, jclass clz) { ! JNF_COCOA_ENTER(env); [[NSProcessInfo processInfo] disableSuddenTermination]; // Foundation thread-safe ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMenuBarHandler * Method: nativeSetMenuState * Signature: (IZZ)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState (JNIEnv *env, jclass clz, jint menuID, jboolean visible, jboolean enabled) { ! JNF_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate]; switch (menuID) { case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT: --- 708,822 ---- * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppDockIconHandler_nativeSetDockIconBadge (JNIEnv *env, jclass clz, jstring badge) { ! JNI_COCOA_ENTER(env); ! NSString *badgeString = JavaStringToNSString(env, badge); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSDockTile *dockTile = [NSApp dockTile]; [dockTile setBadgeLabel:badgeString]; [dockTile display]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeRequestActivation * Signature: (Z)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestActivation (JNIEnv *env, jclass clz, jboolean allWindows) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ NSApplicationActivationOptions options = allWindows ? NSApplicationActivateAllWindows : 0; options |= NSApplicationActivateIgnoringOtherApps; // without this, nothing happens! [[NSRunningApplication currentApplication] activateWithOptions:options]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeRequestUserAttention * Signature: (Z)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeRequestUserAttention (JNIEnv *env, jclass clz, jboolean critical) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [NSApp requestUserAttention:critical ? NSCriticalRequest : NSInformationalRequest]; }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeOpenHelpViewer * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeOpenHelpViewer (JNIEnv *env, jclass clz) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThread:@selector(showHelp:) on:NSApp withObject:nil waitUntilDone:NO]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeEnableSuddenTermination * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeEnableSuddenTermination (JNIEnv *env, jclass clz) { ! JNI_COCOA_ENTER(env); [[NSProcessInfo processInfo] enableSuddenTermination]; // Foundation thread-safe ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMiscHandlers * Method: nativeDisableSuddenTermination * Signature: ()V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMiscHandlers_nativeDisableSuddenTermination (JNIEnv *env, jclass clz) { ! JNI_COCOA_ENTER(env); [[NSProcessInfo processInfo] disableSuddenTermination]; // Foundation thread-safe ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMenuBarHandler * Method: nativeSetMenuState * Signature: (IZZ)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState (JNIEnv *env, jclass clz, jint menuID, jboolean visible, jboolean enabled) { ! JNI_COCOA_ENTER(env); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ ApplicationDelegate *delegate = [ApplicationDelegate sharedDelegate]; switch (menuID) { case com_apple_eawt__AppMenuBarHandler_MENU_ABOUT:
*** 802,826 **** [delegate _updatePreferencesMenu:visible enabled:enabled]; break; } }]; ! JNF_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMenuBarHandler * Method: nativeSetDefaultMenuBar * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetDefaultMenuBar (JNIEnv *env, jclass clz, jlong cMenuBarPtr) { ! JNF_COCOA_ENTER(env); CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ApplicationDelegate sharedDelegate].fDefaultMenuBar = menu; }]; ! JNF_COCOA_EXIT(env); } --- 826,850 ---- [delegate _updatePreferencesMenu:visible enabled:enabled]; break; } }]; ! JNI_COCOA_EXIT(env); } /* * Class: com_apple_eawt__AppMenuBarHandler * Method: nativeSetDefaultMenuBar * Signature: (J)V */ JNIEXPORT void JNICALL Java_com_apple_eawt__1AppMenuBarHandler_nativeSetDefaultMenuBar (JNIEnv *env, jclass clz, jlong cMenuBarPtr) { ! JNI_COCOA_ENTER(env); CMenuBar *menu = (CMenuBar *)jlong_to_ptr(cMenuBarPtr); [ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ApplicationDelegate sharedDelegate].fDefaultMenuBar = menu; }]; ! JNI_COCOA_EXIT(env); }
< prev index next >