/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// External Java Accessibility links:
//
// <http://archives.java.sun.com/archives/java-access.html> (Sun's mailing list for Java accessibility)
#import "JavaComponentAccessibility.h"
#import "sun_lwawt_macosx_CAccessibility.h"
#import <AppKit/AppKit.h>
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
#import <dlfcn.h>
#import "JavaAccessibilityAction.h"
#import "JavaAccessibilityUtilities.h"
#import "JavaTextAccessibility.h"
#import "ThreadUtilities.h"
#import "AWTView.h"
// these constants are duplicated in CAccessibility.java
// If the value is >=0, it's an index
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleComponent, sjc_CAccessibility, "getAccessibleComponent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
static JNF_STATIC_MEMBER_CACHE(sjm_isFocusTraversable, sjc_CAccessibility, "isFocusTraversable", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;");
// sAttributeNamesForRoleCache holds the names of the attributes to which each java
// AccessibleRole responds (see AccessibleRole.java).
// This cache is queried before attempting to access a given attribute for a particular role.
@interface TabGroupAccessibility : JavaComponentAccessibility {
}
- (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
@end
@interface TabGroupControlAccessibility : JavaComponentAccessibility {
}
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole;
@end
@interface ScrollAreaAccessibility : JavaComponentAccessibility {
}
@end
- (NSString *)description
{
return [NSString stringWithFormat:@"%@(title:'%@', desc:'%@', value:'%@')", [self accessibilityRoleAttribute],
[self accessibilityTitleAttribute], [self accessibilityRoleDescriptionAttribute], [self accessibilityValueAttribute]];
}
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
{
if (self)
{
}
return self;
}
- (void)unregisterFromCocoaAXSystem
{
static void (*unregisterUniqueId)(id);
void *jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL);
});
}
- (void)dealloc
{
fAccessible = NULL;
fComponent = NULL;
fActionsLOCK = nil;
[super dealloc];
}
- (void)finalize
{
fAccessible = NULL;
fComponent = NULL;
[super finalize];
}
- (void)postValueChanged
{
}
- (void)postSelectionChanged
{
}
{
}
{
}
+ (void)initialize
{
if (sAttributeNamesForRoleCache == nil) {
}
}
if (sAccessibilityClass == NULL) {
JNF_STATIC_MEMBER_CACHE(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;");
#else
NSUInteger i;
for (i = 0; i < count; i++) {
}
sAccessibilityClass = JNFCallStaticObjectMethod(env, jm_getAccessibility, result); // AWT_THREADING Safe (known object)
}
}
{
NSAccessibilityPostNotification([NSApp accessibilityFocusedUIElement], NSAccessibilityFocusedUIElementChangedNotification);
}
return jaccessible;
}
}
return NULL;
}
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored
{
jobjectArray jchildrenAndRoles = JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
NSMutableArray *children = [NSMutableArray arrayWithCapacity:arrayLen/2]; //childrenAndRoles array contains two elements (child, role) for each child
NSUInteger i;
NSUInteger childIndex = (whichChildren >= 0) ? whichChildren : 0; // if we're getting one particular child, make sure to set its index correctly
{
if (jchildJavaRole != NULL) {
}
JavaComponentAccessibility *child = [self createWithParent:parent accessible:jchild role:childJavaRole index:childIndex withEnv:env withView:parent->fView];
childIndex++;
}
return children;
}
+ (JavaComponentAccessibility *)createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view
{
}
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
{
return [self createWithParent:nil accessible:jaccessible role:javaRole index:index withEnv:env withView:view];
}
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
{
// try to fetch the jCAX from Java, and return autoreleased
JavaComponentAccessibility *value = (JavaComponentAccessibility *) jlong_to_ptr(JNFGetLongField(env, jCAX, jf_ptr));
// otherwise, create a new instance
} else {
if ([nsRole isEqualToString:NSAccessibilityStaticTextRole] || [nsRole isEqualToString:NSAccessibilityTextAreaRole] || [nsRole isEqualToString:NSAccessibilityTextFieldRole]) {
} else {
}
}
// must init freshly -alloc'd object
[newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance
// must hard CFRetain() pointer poked into Java object
// return autoreleased instance
return [newChild autorelease];
}
{
static JNF_STATIC_MEMBER_CACHE(jm_getInitialAttributeStates, sjc_CAccessibility, "getInitialAttributeStates", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[Z");
// all elements respond to parent, role, role description, window, topLevelUIElement, help
// cmcnote: AXMenu usually doesn't respond to window / topLevelUIElement. But menus within a Java app's window
// probably should. Should we use some role other than AXMenu / AXMenuBar for Java menus?
// set accessible subrole
//cmcnote: should turn this into a constant
}
// Get all the other accessibility attributes states we need in one swell foop.
// javaRole isn't pulled in because we need protected access to AccessibleRole.key
jbooleanArray attributeStates = JNFCallStaticObjectMethod(env, jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
if (attributeStatesArray[0]) {
}
// According to javadoc, a component that is focusable will return true from isFocusTraversable,
// as well as having AccessibleState.FOCUSABLE in it's AccessibleStateSet.
// We use the former heuristic; if the component focus-traversable, add a focused attribute
// See also: accessibilityIsFocusedAttributeSettable
if (attributeStatesArray[1])
{
}
} else {
if (hasAxValue) {
//cmcnote: make this (and "passwordtext") constants instead of magic strings
}
}
}
// does it have an orientation?
if (attributeStatesArray[4]) {
}
// name
if (attributeStatesArray[5]) {
}
// children
if (attributeStatesArray[6]) {
// [attributeNames addObject:NSAccessibilitySelectedChildrenAttribute];
// [attributeNames addObject:NSAccessibilityVisibleChildrenAttribute];
//According to AXRoles.txt:
//VisibleChildren: radio group, list, row, table row subrole
//SelectedChildren: list
}
// Cleanup
return attributeNames;
}
{
@synchronized(fActionsLOCK) {
}
}
return fActions;
}
{
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleAction, sjc_CAccessibility, "getAccessibleAction", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleAction;");
// On MacOSX, text doesn't have actions, in java it does.
// cmcnote: NOT TRUE - Editable text has AXShowMenu. Textfields have AXConfirm. Static text has no actions.
jobject axAction = JNFCallStaticObjectMethod(env, jm_getAccessibleAction, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
//+++gdb NOTE: In MacOSX, there is just a single Action, not multiple. In java,
// the first one seems to be the most basic, so this will be used.
// cmcnote: NOT TRUE - Sometimes there are multiple actions, eg sliders have AXDecrement AND AXIncrement (radr://3893192)
JavaAxAction *action = [[JavaAxAction alloc] initWithEnv:env withAccessibleAction:axAction withIndex:0 withComponent:fComponent];
[fActions setObject:action forKey:[self isMenu] ? NSAccessibilityPickAction : NSAccessibilityPressAction];
}
}
{
}
{
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleParent, sjc_CAccessibility, "getAccessibleParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
} else {
}
}
}
return fParent;
}
{
return fView;
}
{
}
{
}
return fJavaRole;
}
{
return [role isEqualToString:NSAccessibilityMenuBarRole] || [role isEqualToString:NSAccessibilityMenuRole] || [role isEqualToString:NSAccessibilityMenuItemRole];
}
{
if (fIndex == -1) {
return NO;
}
return isChildSelected(env, ((JavaComponentAccessibility *)[self parent])->fAccessible, fIndex, fComponent);
}
{
if (fIndex == -1) {
return NO;
}
}
// the array of names for each role is cached in the sAttributeNamesForRoleCache
{
@synchronized(sAttributeNamesLOCK) {
return names;
}
}
NSLog(@"Warning in %s: could not find attribute names for role: %@", __FUNCTION__, [self javaRole]);
return nil;
}
// -- accessibility attributes --
return YES;
}
return YES;
}
// generic getters & setters
// cmcnote: it would make more sense if these generic getters/setters were in JavaAccessibilityUtilities
{
// turns attribute "NSAccessibilityEnabledAttribute" into getter "accessibilityEnabledAttribute",
// calls getter on self
}
{
// turns attribute "NSAccessibilityParentAttribute" into selector "accessibilityIsParentAttributeSettable",
// calls selector on self
}
{
// turns attribute "NSAccessibilityFocusAttribute" into setter "accessibilitySetFocusAttribute",
// calls setter on self
}
}
// specific attributes, in alphabetical order a la
// Elements that current element contains (NSArray)
{
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_VISIBLE_CHILDREN allowIgnored:NO];
}
return value;
}
{
return NO;
}
{
// Only special-casing for Lists, for now. This allows lists to be accessible, fixing radr://3856139 "JLists are broken".
// Will probably want to special-case for Tables when we implement them (radr://3096643 "Accessibility: Table").
// In AppKit, NSMatrixAccessibility (which uses NSAccessibilityListRole), NSTableRowAccessibility, and NSTableViewAccessibility are the
// only ones that override the default implementation in NSAccessibility
return [super accessibilityIndexOfChild:child];
}
return JNFCallStaticIntMethod([ThreadUtilities getJNIEnv], sjm_getAccessibleIndexInParent, ((JavaComponentAccessibility *)child)->fAccessible, ((JavaComponentAccessibility *)child)->fComponent);
}
// Without this optimization accessibilityChildrenAttribute is called in order to get the entire array of children.
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount {
// Children codes for ALL, SELECTED, VISIBLE are <0. If the code is >=0, we treat it as an index to a single child
NSArray *child = [JavaComponentAccessibility childrenOfParent:self withEnv:[ThreadUtilities getJNIEnv] withChildrenCode:(NSInteger)index allowIgnored:NO];
return child;
}
}
}
// Flag indicating enabled state of element (NSNumber)
{
static JNF_STATIC_MEMBER_CACHE(jm_isEnabled, sjc_CAccessibility, "isEnabled", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
NSNumber *value = [NSNumber numberWithBool:JNFCallStaticBooleanMethod(env, jm_isEnabled, fAccessible, fComponent)]; // AWT_THREADING Safe (AWTRunLoop)
}
return value;
}
{
return NO;
}
// Flag indicating presence of keyboard focus (NSNumber)
{
}
}
{
// According to javadoc, a component that is focusable will return true from isFocusTraversable,
// as well as having AccessibleState.FOCUSABLE in its AccessibleStateSet.
// We use the former heuristic; if the component focus-traversable, add a focused attribute
// See also initializeAttributeNamesWithEnv:
if (JNFCallStaticBooleanMethod(env, sjm_isFocusTraversable, fAccessible, fComponent)) { // AWT_THREADING Safe (AWTRunLoop)
return YES;
}
return NO;
}
{
static JNF_STATIC_MEMBER_CACHE(jm_requestFocus, sjc_CAccessibility, "requestFocus", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V");
{
JNFCallStaticVoidMethod(env, jm_requestFocus, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
}
// Instance description, such as a help tag string (NSString)
{
jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleDescription, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
{
return NO;
}
// Element's maximum value (id)
{
static JNF_STATIC_MEMBER_CACHE(jm_getMaximumAccessibleValue, sjc_CAccessibility, "getMaximumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;");
jobject axValue = JNFCallStaticObjectMethod(env, jm_getMaximumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
{
return NO;
}
// Element's minimum value (id)
{
static JNF_STATIC_MEMBER_CACHE(jm_getMinimumAccessibleValue, sjc_CAccessibility, "getMinimumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;");
jobject axValue = JNFCallStaticObjectMethod(env, jm_getMinimumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
{
return NO;
}
{
// cmcnote - should batch these two calls into one that returns an array of two bools, one for vertical and one for horiz
}
}
return nil;
}
{
return NO;
}
// Element containing current element (id)
{
}
{
return NO;
}
// Screen position of element's lower-left corner in lower-left relative screen coordinates (NSValue)
{
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
// NSAccessibility wants the bottom left point of the object in
// bottom left based screen coords
// Get the java screen coords, and make a NSPoint of the bottom left of the AxComponent.
// Now make it into Cocoa screen coords.
}
{
// In AppKit, position is only settable for a window (NSAccessibilityWindowRole). Our windows are taken care of natively, so we don't need to deal with this here
// We *could* make use of Java's AccessibleComponent.setLocation() method. Investigate. radr://3953869
return NO;
}
// Element type, such as NSAccessibilityRadioButtonRole (NSString). See the role table
{
// this component has assigned itself a custom AccessibleRole not in the sRoles array
}
}
return fNSRole;
}
{
return NO;
}
// Localized, user-readable description of role, such as radio button (NSString)
{
// first ask AppKit for its accessible role description for a given AXRole
// query java if necessary
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleRoleDisplayString, sjc_CAccessibility, "getAccessibleRoleDisplayString", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
jobject axRole = JNFCallStaticObjectMethod(env, jm_getAccessibleRoleDisplayString, fAccessible, fComponent);
} else {
value = @"unknown";
}
}
return value;
}
{
return NO;
}
// Currently selected children (NSArray)
{
NSArray *selectedChildren = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_SELECTED_CHILDREN allowIgnored:NO];
return selectedChildren;
}
return nil;
}
{
return NO; // cmcnote: actually it should be. so need to write accessibilitySetSelectedChildrenAttribute also
}
// Element size (NSValue)
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
{
// SIZE is settable in windows if [self styleMask] & NSResizableWindowMask - but windows are heavyweight so we're ok here
// SIZE is settable in columns if [[self tableValue] allowsColumnResizing - haven't dealt with columns yet
return NO;
}
// Element subrole type, such as NSAccessibilityTableRowSubrole (NSString). See the subrole attribute table at
{
{
}
/*
// other subroles. TableRow and OutlineRow may be relevant to us
NSAccessibilityCloseButtonSubrole // no, heavyweight window takes care of this
NSAccessibilityMinimizeButtonSubrole // "
NSAccessibilityOutlineRowSubrole // maybe?
NSAccessibilitySecureTextFieldSubrole // currently used
NSAccessibilityTableRowSubrole // maybe?
NSAccessibilityToolbarButtonSubrole // maybe?
NSAccessibilityUnknownSubrole
NSAccessibilityZoomButtonSubrole // no, heavyweight window takes care of this
NSAccessibilityStandardWindowSubrole// no, heavyweight window takes care of this
NSAccessibilityDialogSubrole // maybe?
NSAccessibilitySystemDialogSubrole // no
NSAccessibilityFloatingWindowSubrole // in 1.5 if we implement these, heavyweight will take care of them anyway
NSAccessibilitySystemFloatingWindowSubrole
NSAccessibilityIncrementArrowSubrole // no
NSAccessibilityDecrementArrowSubrole // no
NSAccessibilityIncrementPageSubrole // no
NSAccessibilityDecrementPageSubrole // no
NSAccessibilitySearchFieldSubrole //no
*/
return value;
}
{
return NO;
}
// Title of element, such as button text (NSString)
{
// Return empty string for labels, since their value and tile end up being the same thing and this leads to repeated text.
return @"";
}
jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
{
return NO;
}
{
}
{
return NO;
}
// Element's value (id)
// note that the appKit meaning of "accessibilityValue" is different from the java
// meaning of "accessibleValue", which is specific to numerical values
// (http://java.sun.com/j2se/1.3/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue(java.lang.Number))
{
static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;");
// ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
// a text value is taken care of in JavaTextAccessibility
// cmcnote should coalesce these calls into one java call
jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
return JNFJavaToNSNumber(env, JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent)); // AWT_THREADING Safe (AWTRunLoop)
}
{
// according ot AppKit sources, in general the value attribute is not settable, except in the cases
// of an NSScroller, an NSSplitView, and text that's both enabled & editable
{
isSettable = YES;
}
return isSettable;
}
{
}
// Child elements that are visible (NSArray)
{
NSArray *visibleChildren = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_VISIBLE_CHILDREN allowIgnored:NO];
return visibleChildren;
}
{
return NO;
}
// Window containing current element (id)
{
}
{
return NO;
}
// -- accessibility actions --
{
}
{
}
{
}
// -- misc accessibility --
{
return NO;
#else
#endif /* JAVA_AX_NO_IGNORES */
}
{
static JNF_STATIC_MEMBER_CACHE(jm_accessibilityHitTest, sjc_CAccessibility, "accessibilityHitTest", "(Ljava/awt/Container;FF)Ljavax/accessibility/Accessible;");
// Make it into java screen coords
jobject jaccessible = JNFCallStaticObjectMethod(env, jm_accessibilityHitTest, jparent, (jfloat)point.x, (jfloat)point.y); // AWT_THREADING Safe (AWTRunLoop)
}
}
if ([value accessibilityIsIgnored]) {
}
return value;
}
{
static JNF_STATIC_MEMBER_CACHE(jm_getFocusOwner, sjc_CAccessibility, "getFocusOwner", "(Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
}
}
}
return value;
}
@end
/*
* Class: sun_lwawt_macosx_CAccessibility
* Method: focusChanged
* Signature: ()V
*/
{
[ThreadUtilities performOnMainThread:@selector(postFocusChanged:) on:[JavaComponentAccessibility class] withObject:nil waitUntilDone:NO];
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: valueChanged
* Signature: (I)V
*/
{
[ThreadUtilities performOnMainThread:@selector(postValueChanged) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: selectionChanged
* Signature: (I)V
*/
{
[ThreadUtilities performOnMainThread:@selector(postSelectionChanged) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
}
/*
* Class: sun_lwawt_macosx_CAccessible
* Method: unregisterFromCocoaAXSystem
* Signature: (I)V
*/
{
[ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
}
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
{
self = [super initWithParent:parent withEnv:env withAccessible:accessible withIndex:index withView:view withJavaRole:javaRole];
if (self) {
}
return self;
}
{
return names;
}
{
NSArray *tabs = [self tabControlsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
// Looking at the JTabbedPane sources, there is always one AccessibleSelection.
// Go through the tabs and find selAccessible
NSUInteger i;
for (i = 0; i < _numTabs; i++) {
return aTab;
}
}
return nil;
}
- (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored
{
jobjectArray jtabsAndRoles = JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, fAccessible, fComponent, whichTabs, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
// all of the tabs have the same role, so we can just find out what that is here and use it for all the tabs
jobject jtabJavaRole = (*env)->GetObjectArrayElement(env, jtabsAndRoles, 1); // the array entries alternate between tab/role, starting with tab. so the first role is entry 1.
NSUInteger i;
NSUInteger tabIndex = (whichTabs >= 0) ? whichTabs : 0; // if we're getting one particular child, make sure to set its index correctly
JavaComponentAccessibility *tab = [[[TabGroupControlAccessibility alloc] initWithParent:self withEnv:env withAccessible:jtab withIndex:tabIndex withTabGroup:axContext withView:[self view] withJavaRole:tabJavaRole] autorelease];
tabIndex++;
}
return tabs;
}
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored
{
// Contents are the children of the selected tab.
NSArray *contents = [JavaComponentAccessibility childrenOfParent:currentTab withEnv:env withChildrenCode:whichTabs allowIgnored:allowIgnored];
return contents;
}
{
return [self tabControlsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
}
{
return NO; //cmcnote: not sure.
}
{
if (_numTabs == -1) {
}
return _numTabs;
}
{
return [self contentsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
}
{
return NO;
}
// axValue is the currently selected tab
{
}
{
return YES;
}
- (void)accessibilitySetValueAttribute:(id)value //cmcnote: not certain this is ever actually called. investigate.
{
// set the current tab
}
{
//children = AXTabs + AXContents
}
// Without this optimization accessibilityChildrenAttribute is called in order to get the entire array of children.
// See similar optimization in JavaComponentAccessibility. We have to extend the base implementation here, since
// children of tabs are AXTabs + AXContents
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount {
// Children codes for ALL, SELECTED, VISIBLE are <0. If the code is >=0, we treat it as an index to a single child
//children = AXTabs + AXContents
NSArray *children = [self tabControlsWithEnv:env withTabGroupAxContext:axContext withTabCode:index allowIgnored:NO]; // first look at the tabs
} else {
children= [self contentsWithEnv:env withTabGroupAxContext:axContext withTabCode:(index-[self numTabs]) allowIgnored:NO];
}
}
} else {
}
return result;
}
@end
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole
{
self = [super initWithParent:parent withEnv:env withAccessible:accessible withIndex:index withView:view withJavaRole:javaRole];
if (self) {
} else {
}
}
return self;
}
- (void)dealloc
{
if (fTabGroupAxContext != NULL) {
}
[super dealloc];
}
- (void)finalize
{
if (fTabGroupAxContext != NULL) {
}
[super finalize];
}
{
// Returns the current selection of the page tab list
return [NSNumber numberWithBool:ObjectEquals(env, axContext, getAxContextSelection(env, [self tabGroup], fIndex, fComponent), fComponent)];
}
{
TabGroupAction *action = [[TabGroupAction alloc] initWithEnv:env withTabGroup:[self tabGroup] withIndex:fIndex withComponent:fComponent];
}
{
if (fTabGroupAxContext == NULL) {
}
return fTabGroupAxContext;
}
@end
{
return names;
}
{
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
// The scroll bars are in the children.
return aElement;
}
}
}
return nil;
}
{
return NO;
}
{
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
// The scroll bars are in the children.
return aElement;
}
}
}
return nil;
}
{
return NO;
}
{
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
// The scroll bars are in the children. children less the scroll bars is the contents
// no scroll bars in contents
}
}
return contents;
}
{
return NO;
}
@end
/*
* Returns Object.equals for the two items
* This may use LWCToolkit.invokeAndWait(); don't call while holding fLock
* and try to pass a component so the event happens on the correct thread.
*/
{
if (pthread_main_np() != 0) {
// If we are on the AppKit thread
static JNF_STATIC_MEMBER_CACHE(jm_doEquals, sjc_LWCToolkit, "doEquals", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/awt/Component;)Z");
return JNFCallStaticBooleanMethod(env, jm_doEquals, a, b, component); // AWT_THREADING Safe (AWTRunLoopMode)
}
}