369 JNIEXPORT jlong JNICALL
370 Java_sun_lwawt_macosx_CMenuItem_nativeCreate
371 (JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator)
372 {
373
374 CMenuItem *aCMenuItem = nil;
375 CMenu *parentCMenu = (CMenu *)jlong_to_ptr(parentCMenuObj);
376 JNF_COCOA_ENTER(env);
377
378 jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
379
380 NSMutableArray *args = nil;
381
382 // Create a new item....
383 if (isSeparator == JNI_TRUE) {
384 args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:YES], nil];
385 } else {
386 args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:NO], nil];
387 }
388
389 [ThreadUtilities performOnMainThread:@selector(_createMenuItem_OnAppKitThread:) onObject:[CMenuItem alloc] withObject:args waitUntilDone:YES awtMode:YES];
390
391 aCMenuItem = (CMenuItem *)[args objectAtIndex: 0];
392
393 if (aCMenuItem == nil) {
394 return 0L;
395 }
396
397 // and add it to the parent item.
398 [parentCMenu addJavaMenuItem: aCMenuItem];
399
400 // setLabel will be called after creation completes.
401
402 if (aCMenuItem) {
403 CFRetain(aCMenuItem); // GC
404 [aCMenuItem release];
405 }
406
407 JNF_COCOA_EXIT(env);
408 return ptr_to_jlong(aCMenuItem);
409 }
|
369 JNIEXPORT jlong JNICALL
370 Java_sun_lwawt_macosx_CMenuItem_nativeCreate
371 (JNIEnv *env, jobject peer, jlong parentCMenuObj, jboolean isSeparator)
372 {
373
374 CMenuItem *aCMenuItem = nil;
375 CMenu *parentCMenu = (CMenu *)jlong_to_ptr(parentCMenuObj);
376 JNF_COCOA_ENTER(env);
377
378 jobject cPeerObjGlobal = (*env)->NewGlobalRef(env, peer);
379
380 NSMutableArray *args = nil;
381
382 // Create a new item....
383 if (isSeparator == JNI_TRUE) {
384 args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:YES], nil];
385 } else {
386 args = [[NSMutableArray alloc] initWithObjects:[NSValue valueWithBytes:&cPeerObjGlobal objCType:@encode(jobject)], [NSNumber numberWithBool:NO], nil];
387 }
388
389 [ThreadUtilities performOnMainThread:@selector(_createMenuItem_OnAppKitThread:) on:[CMenuItem alloc] withObject:args waitUntilDone:YES];
390
391 aCMenuItem = (CMenuItem *)[args objectAtIndex: 0];
392
393 if (aCMenuItem == nil) {
394 return 0L;
395 }
396
397 // and add it to the parent item.
398 [parentCMenu addJavaMenuItem: aCMenuItem];
399
400 // setLabel will be called after creation completes.
401
402 if (aCMenuItem) {
403 CFRetain(aCMenuItem); // GC
404 [aCMenuItem release];
405 }
406
407 JNF_COCOA_EXIT(env);
408 return ptr_to_jlong(aCMenuItem);
409 }
|