< prev index next >

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

Print this page
rev 54086 : 8240487: Cleanup whitespace in .cc, .hh, .m, and .mm files


1168     JNIEnv* env = [ThreadUtilities getJNIEnv];
1169 
1170     // Need to handle popupmenus differently.
1171     //
1172     // At least for now don't handle combo box menus.
1173     // This may change when later fixing issues which currently
1174     // exist for combo boxes, but for now the following is only
1175     // for JPopupMenus, not for combobox menus.
1176     id parent = [self parent];
1177     if ( [[self javaRole] isEqualToString:@"popupmenu"] &&
1178          ![[parent javaRole] isEqualToString:@"combobox"] ) {
1179         NSArray *children =
1180             [JavaComponentAccessibility childrenOfParent:self
1181                                         withEnv:env
1182                                         withChildrenCode:JAVA_AX_ALL_CHILDREN
1183                                         allowIgnored:YES];
1184         if ([children count] > 0) {
1185             // handle case of AXMenuItem
1186             // need to ask menu what is selected
1187             NSArray *selectedChildrenOfMenu =
1188                 [self accessibilitySelectedChildrenAttribute];
1189             JavaComponentAccessibility *selectedMenuItem =
1190                 [selectedChildrenOfMenu objectAtIndex:0];
1191             if (selectedMenuItem != nil) {
1192                 jobject itemValue =
1193                         JNFCallStaticObjectMethod( env,
1194                                                    sjm_getAccessibleName,
1195                                                    selectedMenuItem->fAccessible,
1196                                                    selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
1197                 if (itemValue == NULL) {
1198                     return nil;
1199                 }
1200                 NSString* itemString = JNFJavaToNSString(env, itemValue);
1201                 (*env)->DeleteLocalRef(env, itemValue);
1202                 return itemString;
1203             } else {
1204                 return nil;
1205             }
1206         }
1207     }
1208 
1209     // ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
1210     // a text value is taken care of in JavaTextAccessibility
1211 
1212     // cmcnote should coalesce these calls into one java call
1213     NSNumber *num = nil;
1214     jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
1215     if (axValue != NULL) {
1216         jobject str = JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent);
1217         if (str != NULL) {
1218             num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop)
1219             (*env)->DeleteLocalRef(env, str);
1220         }
1221         (*env)->DeleteLocalRef(env, axValue);
1222     }
1223     if (num == nil) {
1224         num = [NSNumber numberWithInt:0];




1168     JNIEnv* env = [ThreadUtilities getJNIEnv];
1169 
1170     // Need to handle popupmenus differently.
1171     //
1172     // At least for now don't handle combo box menus.
1173     // This may change when later fixing issues which currently
1174     // exist for combo boxes, but for now the following is only
1175     // for JPopupMenus, not for combobox menus.
1176     id parent = [self parent];
1177     if ( [[self javaRole] isEqualToString:@"popupmenu"] &&
1178          ![[parent javaRole] isEqualToString:@"combobox"] ) {
1179         NSArray *children =
1180             [JavaComponentAccessibility childrenOfParent:self
1181                                         withEnv:env
1182                                         withChildrenCode:JAVA_AX_ALL_CHILDREN
1183                                         allowIgnored:YES];
1184         if ([children count] > 0) {
1185             // handle case of AXMenuItem
1186             // need to ask menu what is selected
1187             NSArray *selectedChildrenOfMenu =
1188                 [self accessibilitySelectedChildrenAttribute];
1189             JavaComponentAccessibility *selectedMenuItem =
1190                 [selectedChildrenOfMenu objectAtIndex:0];
1191             if (selectedMenuItem != nil) {
1192                 jobject itemValue =
1193                         JNFCallStaticObjectMethod( env,
1194                                                    sjm_getAccessibleName,
1195                                                    selectedMenuItem->fAccessible,
1196                                                    selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
1197                 if (itemValue == NULL) {
1198                     return nil;
1199                 }
1200                 NSString* itemString = JNFJavaToNSString(env, itemValue);
1201                 (*env)->DeleteLocalRef(env, itemValue);
1202                 return itemString;
1203             } else {
1204                 return nil;
1205             }
1206         }
1207     }
1208 
1209     // ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
1210     // a text value is taken care of in JavaTextAccessibility
1211 
1212     // cmcnote should coalesce these calls into one java call
1213     NSNumber *num = nil;
1214     jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
1215     if (axValue != NULL) {
1216         jobject str = JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent);
1217         if (str != NULL) {
1218             num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop)
1219             (*env)->DeleteLocalRef(env, str);
1220         }
1221         (*env)->DeleteLocalRef(env, axValue);
1222     }
1223     if (num == nil) {
1224         num = [NSNumber numberWithInt:0];


< prev index next >