< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 629 }
 630 
 631 // the array of names for each role is cached in the sAttributeNamesForRoleCache
 632 - (NSArray *)accessibilityAttributeNames
 633 {
 634     JNIEnv* env = [ThreadUtilities getJNIEnv];
 635 
 636     @synchronized(sAttributeNamesLOCK) {
 637         NSString *javaRole = [self javaRole];
 638         NSArray *names =
 639             (NSArray *)[sAttributeNamesForRoleCache objectForKey:javaRole];
 640         if (names == nil) {
 641             names = [self initializeAttributeNamesWithEnv:env];
 642 #ifdef JAVA_AX_DEBUG
 643             NSLog(@"Initializing: %s for %@: %@", __FUNCTION__, javaRole, names);
 644 #endif
 645             [sAttributeNamesForRoleCache setObject:names forKey:javaRole];
 646         }
 647         // The above set of attributes is immutable per role, but some objects, if
 648         // they are the child of a list, need to add the selected and index attributes.



 649         id myParent = [self accessibilityParentAttribute];
 650         if ([myParent isKindOfClass:[JavaComponentAccessibility class]]) {
 651             NSString *parentRole = [(JavaComponentAccessibility *)myParent javaRole];
 652             if ([parentRole isEqualToString:@"list"]) {
 653                 NSMutableArray *moreNames =
 654                     [[NSMutableArray alloc] initWithCapacity: [names count] + 2];
 655                 [moreNames addObjectsFromArray: names];
 656                 [moreNames addObject:NSAccessibilitySelectedAttribute];
 657                 [moreNames addObject:NSAccessibilityIndexAttribute];
 658                 return moreNames;
 659             }
 660         }
 661         // popupmenu's return values not selected children
 662         if ( [javaRole isEqualToString:@"popupmenu"] &&
 663              ![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
 664             NSMutableArray *moreNames =
 665                 [[NSMutableArray alloc] initWithCapacity: [names count] + 1];
 666             [moreNames addObjectsFromArray: names];
 667             [moreNames addObject:NSAccessibilityValueAttribute];
 668             return moreNames;


   1 /*
   2  * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 629 }
 630 
 631 // the array of names for each role is cached in the sAttributeNamesForRoleCache
 632 - (NSArray *)accessibilityAttributeNames
 633 {
 634     JNIEnv* env = [ThreadUtilities getJNIEnv];
 635 
 636     @synchronized(sAttributeNamesLOCK) {
 637         NSString *javaRole = [self javaRole];
 638         NSArray *names =
 639             (NSArray *)[sAttributeNamesForRoleCache objectForKey:javaRole];
 640         if (names == nil) {
 641             names = [self initializeAttributeNamesWithEnv:env];
 642 #ifdef JAVA_AX_DEBUG
 643             NSLog(@"Initializing: %s for %@: %@", __FUNCTION__, javaRole, names);
 644 #endif
 645             [sAttributeNamesForRoleCache setObject:names forKey:javaRole];
 646         }
 647         // The above set of attributes is immutable per role, but some objects, if
 648         // they are the child of a list, need to add the selected and index attributes.
 649         if ([self accessibilityIsIgnored]) {
 650             return names;
 651         }
 652         id myParent = [self accessibilityParentAttribute];
 653         if ([myParent isKindOfClass:[JavaComponentAccessibility class]]) {
 654             NSString *parentRole = [(JavaComponentAccessibility *)myParent javaRole];
 655             if ([parentRole isEqualToString:@"list"]) {
 656                 NSMutableArray *moreNames =
 657                     [[NSMutableArray alloc] initWithCapacity: [names count] + 2];
 658                 [moreNames addObjectsFromArray: names];
 659                 [moreNames addObject:NSAccessibilitySelectedAttribute];
 660                 [moreNames addObject:NSAccessibilityIndexAttribute];
 661                 return moreNames;
 662             }
 663         }
 664         // popupmenu's return values not selected children
 665         if ( [javaRole isEqualToString:@"popupmenu"] &&
 666              ![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
 667             NSMutableArray *moreNames =
 668                 [[NSMutableArray alloc] initWithCapacity: [names count] + 1];
 669             [moreNames addObjectsFromArray: names];
 670             [moreNames addObject:NSAccessibilityValueAttribute];
 671             return moreNames;


< prev index next >