author | sveerabhadra |
Fri, 22 Dec 2017 11:00:06 +0530 | |
changeset 48640 | 42ad9a781f51 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
12047 | 1 |
/* |
37787 | 2 |
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. |
12047 | 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 |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
#import "JavaAccessibilityAction.h" |
|
27 |
#import "JavaAccessibilityUtilities.h" |
|
28 |
||
29 |
#import "ThreadUtilities.h" |
|
30 |
||
31 |
||
32 |
@implementation JavaAxAction |
|
33 |
||
34 |
- (id)initWithEnv:(JNIEnv *)env withAccessibleAction:(jobject)accessibleAction withIndex:(jint)index withComponent:(jobject)component |
|
35 |
{ |
|
36 |
self = [super init]; |
|
37 |
if (self) { |
|
37787 | 38 |
fAccessibleAction = JNFNewWeakGlobalRef(env, accessibleAction); |
12047 | 39 |
fIndex = index; |
37787 | 40 |
fComponent = JNFNewWeakGlobalRef(env, component); |
12047 | 41 |
} |
42 |
return self; |
|
43 |
} |
|
44 |
||
45 |
- (void)dealloc |
|
46 |
{ |
|
47 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
48 |
||
37787 | 49 |
JNFDeleteWeakGlobalRef(env, fAccessibleAction); |
12047 | 50 |
fAccessibleAction = NULL; |
51 |
||
37787 | 52 |
JNFDeleteWeakGlobalRef(env, fComponent); |
12047 | 53 |
fComponent = NULL; |
54 |
||
55 |
[super dealloc]; |
|
56 |
} |
|
57 |
||
58 |
- (NSString *)getDescription |
|
59 |
{ |
|
60 |
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleActionDescription, sjc_CAccessibility, "getAccessibleActionDescription", "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)Ljava/lang/String;"); |
|
61 |
||
62 |
JNIEnv* env = [ThreadUtilities getJNIEnv]; |
|
63 |
||
37787 | 64 |
jobject fCompLocal = (*env)->NewLocalRef(env, fComponent); |
65 |
if ((*env)->IsSameObject(env, fCompLocal, NULL)) { |
|
39873
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
66 |
return nil; |
37787 | 67 |
} |
68 |
NSString *str = nil; |
|
39873
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
69 |
jstring jstr = JNFCallStaticObjectMethod( env, |
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
70 |
jm_getAccessibleActionDescription, |
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
71 |
fAccessibleAction, |
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
72 |
fIndex, |
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
73 |
fCompLocal ); |
37787 | 74 |
if (jstr != NULL) { |
39873
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
75 |
str = JNFJavaToNSString(env, jstr); // AWT_THREADING Safe (AWTRunLoopMode) |
37787 | 76 |
(*env)->DeleteLocalRef(env, jstr); |
77 |
} |
|
78 |
(*env)->DeleteLocalRef(env, fCompLocal); |
|
39873
76907ae1b680
8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents:
37787
diff
changeset
|
79 |
return str; |
12047 | 80 |
} |
81 |
||
82 |
- (void)perform |
|
83 |
{ |
|
84 |
static JNF_STATIC_MEMBER_CACHE(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction", "(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V"); |
|
85 |
||
86 |
JNIEnv* env = [ThreadUtilities getJNIEnv]; |
|
87 |
||
88 |
JNFCallStaticVoidMethod(env, jm_doAccessibleAction, fAccessibleAction, fIndex, fComponent); // AWT_THREADING Safe (AWTRunLoopMode) |
|
89 |
} |
|
90 |
||
91 |
@end |
|
92 |
||
93 |
||
94 |
@implementation TabGroupAction |
|
95 |
||
96 |
- (id)initWithEnv:(JNIEnv *)env withTabGroup:(jobject)tabGroup withIndex:(jint)index withComponent:(jobject)component |
|
97 |
{ |
|
98 |
self = [super init]; |
|
99 |
if (self) { |
|
37787 | 100 |
fTabGroup = JNFNewWeakGlobalRef(env, tabGroup); |
12047 | 101 |
fIndex = index; |
37787 | 102 |
fComponent = JNFNewWeakGlobalRef(env, component); |
12047 | 103 |
} |
104 |
return self; |
|
105 |
} |
|
106 |
||
107 |
- (void)dealloc |
|
108 |
{ |
|
109 |
JNIEnv *env = [ThreadUtilities getJNIEnvUncached]; |
|
110 |
||
37787 | 111 |
JNFDeleteWeakGlobalRef(env, fTabGroup); |
12047 | 112 |
fTabGroup = NULL; |
113 |
||
37787 | 114 |
JNFDeleteWeakGlobalRef(env, fComponent); |
12047 | 115 |
fComponent = NULL; |
116 |
||
117 |
[super dealloc]; |
|
118 |
} |
|
119 |
||
120 |
- (NSString *)getDescription |
|
121 |
{ |
|
122 |
return @"click"; |
|
123 |
} |
|
124 |
||
125 |
- (void)perform |
|
126 |
{ |
|
127 |
JNIEnv* env = [ThreadUtilities getJNIEnv]; |
|
128 |
||
129 |
setAxContextSelection(env, fTabGroup, fIndex, fComponent); |
|
130 |
} |
|
131 |
||
132 |
@end |