src/macosx/native/sun/awt/CMenu.m

Print this page

        

*** 36,46 **** @implementation CMenu - (id)initWithPeer:(jobject)peer { AWT_ASSERT_APPKIT_THREAD; // Create the new NSMenu ! self = [super initWithPeer:peer asSeparator:[NSNumber numberWithBool:NO]]; if (self) { fMenu = [NSMenu javaMenuWithTitle:@""]; [fMenu retain]; [fMenu setAutoenablesItems:NO]; } --- 36,46 ---- @implementation CMenu - (id)initWithPeer:(jobject)peer { AWT_ASSERT_APPKIT_THREAD; // Create the new NSMenu ! self = [super initWithPeer:peer asSeparator:NO]; if (self) { fMenu = [NSMenu javaMenuWithTitle:@""]; [fMenu retain]; [fMenu setAutoenablesItems:NO]; }
*** 51,72 **** [fMenu release]; fMenu = nil; [super dealloc]; } - - (void)addJavaSubmenu:(CMenu *)submenu { - [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) on:self withObject:submenu waitUntilDone:YES]; - } - - - (void)addJavaMenuItem:(CMenuItem *)theMenuItem { - [ThreadUtilities performOnMainThread:@selector(addNativeItem_OnAppKitThread:) on:self withObject:theMenuItem waitUntilDone:YES]; - } - - - (void)addNativeItem_OnAppKitThread:(CMenuItem *)itemModified { - AWT_ASSERT_APPKIT_THREAD; - [itemModified addNSMenuItemToMenu:[self menu]]; - } - (void)setJavaMenuTitle:(NSString *)title { if (title) { [ThreadUtilities performOnMainThread:@selector(setNativeMenuTitle_OnAppKitThread:) on:self withObject:title waitUntilDone:YES]; --- 51,60 ----
*** 131,153 **** @end CMenu * createCMenu (jobject cPeerObjGlobal) { ! CMenu *aCMenu = nil; ! ! // We use an array here only to be able to get a return value ! NSMutableArray *args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], nil]; ! ! [ThreadUtilities performOnMainThread:@selector(_create_OnAppKitThread:) on:[CMenu alloc] withObject:args waitUntilDone:YES]; ! ! aCMenu = (CMenu *)[args objectAtIndex: 0]; ! ! if (aCMenu == nil) { ! return 0L; ! } ! return aCMenu; } /* --- 119,132 ---- @end CMenu * createCMenu (jobject cPeerObjGlobal) { ! __block CMenu *aCMenu = nil; ! [ThreadUtilities performOnMainThreadWaiting:YES block:^() { ! aCMenu = [[CMenu alloc] initWithPeer:cPeerObjGlobal]; ! }]; return aCMenu; } /*
*** 155,175 **** * Method: nativeCreateSubMenu * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CMenu_nativeCreateSubMenu ! (JNIEnv *env, jobject peer, jlong parentMenu) { ! CMenu *aCMenu = nil; JNF_COCOA_ENTER(env); jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer); ! ! aCMenu = createCMenu (cPeerObjGlobal); ! ! // Add it to the parent menu ! [((CMenu *)jlong_to_ptr(parentMenu)) addJavaSubmenu: aCMenu]; JNF_COCOA_EXIT(env); return ptr_to_jlong(aCMenu); } --- 134,155 ---- * Method: nativeCreateSubMenu * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CMenu_nativeCreateSubMenu ! (JNIEnv *env, jobject peer, jlong jParentMenu) { ! __block CMenu *aCMenu = nil; ! CMenu* parentMenu = (CMenu *)jlong_to_ptr(jParentMenu); ! JNF_COCOA_ENTER(env); jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer); ! [ThreadUtilities performOnMainThreadWaiting:YES block:^() { ! aCMenu = [[CMenu alloc] initWithPeer:cPeerObjGlobal]; ! [aCMenu addNSMenuItemToMenu:[parentMenu menu]]; ! }]; JNF_COCOA_EXIT(env); return ptr_to_jlong(aCMenu); }
*** 181,200 **** * Method: nativeCreateMenu * Signature: (JZ)J */ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CMenu_nativeCreateMenu ! (JNIEnv *env, jobject peer, ! jlong parentMenuBar, jboolean isHelpMenu, jint insertLocation) { ! CMenu *aCMenu = nil; CMenuBar *parent = (CMenuBar *)jlong_to_ptr(parentMenuBar); JNF_COCOA_ENTER(env); jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer); ! ! aCMenu = createCMenu (cPeerObjGlobal); // Add it to the menu bar. [parent javaAddMenu:aCMenu atIndex:insertLocation]; // If the menu is already the help menu (because we are creating an entire --- 161,180 ---- * Method: nativeCreateMenu * Signature: (JZ)J */ JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CMenu_nativeCreateMenu ! (JNIEnv *env, jobject peer, jlong parentMenuBar, jboolean isHelpMenu, jint insertLocation) { ! __block CMenu *aCMenu = nil; CMenuBar *parent = (CMenuBar *)jlong_to_ptr(parentMenuBar); JNF_COCOA_ENTER(env); jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer); ! [ThreadUtilities performOnMainThreadWaiting:YES block:^() { ! aCMenu = [[CMenu alloc] initWithPeer:cPeerObjGlobal]; ! }]; // Add it to the menu bar. [parent javaAddMenu:aCMenu atIndex:insertLocation]; // If the menu is already the help menu (because we are creating an entire