Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8261350: Create implementation for NSAccessibilityCheckBox protocol peer #1582

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -22,10 +22,11 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.platform;

public class SystemMetrics {
public static Metrics instance() {
return CgroupMetrics.getInstance();
}
}
#import "ButtonAccessibility.h"

@interface RadiobuttonAccessibility : ButtonAccessibility <NSAccessibilityRadioButton> {

};
- (id)accessibilityValue;
@end
Expand Up @@ -22,10 +22,20 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.platform;

public class SystemMetrics {
public static Metrics instance() {
return null;
}
#import "RadiobuttonAccessibility.h"
#import "JNIUtilities.h"
#import "ThreadUtilities.h"

/*
* Implementation of the accessibility peer for the radiobutton role
*/
@implementation RadiobuttonAccessibility

- (id) accessibilityValue
{
AWT_ASSERT_APPKIT_THREAD;
return [self accessibilityValueAttribute];
}

@end
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/

#import "ButtonAccessibility.h"

@interface CheckboxAccessibility : ButtonAccessibility <NSAccessibilityCheckBox> {

};
- (id)accessibilityValue;
@end
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/

#import "CheckboxAccessibility.h"
#import "JNIUtilities.h"
#import "ThreadUtilities.h"

/*
* Implementation of the accessibility peer for the checkbox role
*/
@implementation CheckboxAccessibility

- (id) accessibilityValue
{
AWT_ASSERT_APPKIT_THREAD;
return [self accessibilityValueAttribute];
}

@end
Expand Up @@ -46,9 +46,16 @@ + (void) initializeRolesMap {
/*
* Here we should keep all the mapping between the accessibility roles and implementing classes
*/
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:1];
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:8];

[rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"];
[rolesMap setObject:@"ImageAccessibility" forKey:@"icon"];
[rolesMap setObject:@"ImageAccessibility" forKey:@"desktopicon"];
[rolesMap setObject:@"SpinboxAccessibility" forKey:@"spinbox"];
[rolesMap setObject:@"StaticTextAccessibility" forKey:@"hyperlink"];
[rolesMap setObject:@"StaticTextAccessibility" forKey:@"label"];
[rolesMap setObject:@"RadiobuttonAccessibility" forKey:@"radiobutton"];
[rolesMap setObject:@"CheckboxAccessibility" forKey:@"checkbox"];
}

/*
Expand All @@ -58,7 +65,6 @@ + (void) initializeRolesMap {
+ (JavaComponentAccessibility *) getComponentAccessibility:(NSString *)role
{
AWT_ASSERT_APPKIT_THREAD;

if (rolesMap == nil) {
[self initializeRolesMap];
}
Expand Down Expand Up @@ -95,4 +101,20 @@ - (nullable id)accessibilityParent
return [self accessibilityParentAttribute];
}

// AccessibleAction support
- (BOOL)performAccessibleAction:(int)index
{
AWT_ASSERT_APPKIT_THREAD;
JNIEnv* env = [ThreadUtilities getJNIEnv];

GET_CACCESSIBILITY_CLASS_RETURN(FALSE);
DECLARE_STATIC_METHOD_RETURN(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction",
"(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V", FALSE);
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction,
[self axContextWithEnv:(env)], index, fComponent);
CHECK_EXCEPTION();

return TRUE;
}

@end