author | dholmes |
Sun, 08 Jul 2018 20:00:46 -0400 | |
changeset 51005 | 0083d474b0e1 |
parent 47216 | 71c04702a3d5 |
child 52252 | de9486d74a74 |
permissions | -rw-r--r-- |
29883
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
1 |
/* |
42712
679c4f3300b1
8167182: Exported elements referring to inaccessible types in jdk.accessibility
prr
parents:
34894
diff
changeset
|
2 |
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. |
29883
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
4 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
10 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
15 |
* accompanied this code). |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
16 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
20 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
23 |
* questions. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
24 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
25 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
26 |
package com.sun.java.accessibility.util; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
27 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
28 |
import java.util.*; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
29 |
import java.beans.*; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
30 |
import java.awt.*; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
31 |
import java.awt.event.*; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
32 |
import javax.accessibility.*; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
33 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
34 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
35 |
* <P>{@code AccessibilityEventMonitor} implements a PropertyChange listener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
36 |
* on every UI object that implements interface {@code Accessible} in the Java |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
37 |
* Virtual Machine. The events captured by these listeners are made available |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
38 |
* through listeners supported by {@code AccessibilityEventMonitor}. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
39 |
* With this, all the individual events on each of the UI object |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
40 |
* instances are funneled into one set of PropertyChange listeners. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
41 |
* <p>This class depends upon {@link EventQueueMonitor}, which provides the base |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
42 |
* level support for capturing the top-level containers as they are created. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
43 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
44 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
45 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
46 |
public class AccessibilityEventMonitor { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
47 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
48 |
// listeners |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
49 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
50 |
* The current list of registered {@link java.beans.PropertyChangeListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
51 |
* PropertyChangeListener} classes. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
52 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
53 |
* @see #addPropertyChangeListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
54 |
* @see #removePropertyChangeListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
55 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
56 |
static protected final AccessibilityListenerList listenerList = |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
57 |
new AccessibilityListenerList(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
58 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
59 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
60 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
61 |
* The actual listener that is installed on the component instances. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
62 |
* This listener calls the other registered listeners when an event |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
63 |
* occurs. By doing things this way, the actual number of listeners |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
64 |
* installed on a component instance is drastically reduced. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
65 |
*/ |
42712
679c4f3300b1
8167182: Exported elements referring to inaccessible types in jdk.accessibility
prr
parents:
34894
diff
changeset
|
66 |
static private final AccessibilityEventListener accessibilityListener = |
29883
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
67 |
new AccessibilityEventListener(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
68 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
69 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
70 |
* Adds the specified listener to receive all PropertyChange events on |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
71 |
* each UI object instance in the Java Virtual Machine as they occur. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
72 |
* <P>Note: This listener is automatically added to all component |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
73 |
* instances created after this method is called. In addition, it |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
74 |
* is only added to UI object instances that support this listener type. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
75 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
76 |
* @param l the listener to add |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
77 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
78 |
* @see #removePropertyChangeListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
79 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
80 |
static public void addPropertyChangeListener(PropertyChangeListener l) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
81 |
if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
82 |
accessibilityListener.installListeners(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
83 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
84 |
listenerList.add(PropertyChangeListener.class, l); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
85 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
86 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
87 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
88 |
* Removes the specified listener so it no longer receives PropertyChange |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
89 |
* events when they occur. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
90 |
* @see #addPropertyChangeListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
91 |
* @param l the listener to remove |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
92 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
93 |
static public void removePropertyChangeListener(PropertyChangeListener l) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
94 |
listenerList.remove(PropertyChangeListener.class, l); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
95 |
if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
96 |
accessibilityListener.removeListeners(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
97 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
98 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
99 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
100 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
101 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
102 |
* AccessibilityEventListener is the class that does all the work for |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
103 |
* AccessibilityEventMonitor. It is not intended for use by any other |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
104 |
* class except AccessibilityEventMonitor. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
105 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
106 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
107 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
108 |
static class AccessibilityEventListener implements TopLevelWindowListener, |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
109 |
PropertyChangeListener { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
110 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
111 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
112 |
* Create a new instance of this class and install it on each component |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
113 |
* instance in the virtual machine that supports any of the currently |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
114 |
* registered listeners in AccessibilityEventMonitor. Also registers |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
115 |
* itself as a TopLevelWindowListener with EventQueueMonitor so it can |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
116 |
* automatically add new listeners to new components. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
117 |
* @see EventQueueMonitor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
118 |
* @see AccessibilityEventMonitor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
119 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
120 |
public AccessibilityEventListener() { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
121 |
EventQueueMonitor.addTopLevelWindowListener(this); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
122 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
123 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
124 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
125 |
* Installs PropertyChange listeners on all Accessible objects based |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
126 |
* upon the current topLevelWindows cached by EventQueueMonitor. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
127 |
* @see EventQueueMonitor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
128 |
* @see AWTEventMonitor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
129 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
130 |
protected void installListeners() { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
131 |
Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
132 |
if (topLevelWindows != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
133 |
for (int i = 0; i < topLevelWindows.length; i++) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
134 |
if (topLevelWindows[i] instanceof Accessible) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
135 |
installListeners((Accessible) topLevelWindows[i]); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
136 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
137 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
138 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
139 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
140 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
141 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
142 |
* Installs PropertyChange listeners to the Accessible object, and it's |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
143 |
* children (so long as the object isn't of TRANSIENT state). |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
144 |
* @param a the Accessible object to add listeners to |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
145 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
146 |
protected void installListeners(Accessible a) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
147 |
installListeners(a.getAccessibleContext()); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
148 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
149 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
150 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
151 |
* Installs PropertyChange listeners to the AccessibleContext object, |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
152 |
* and it's * children (so long as the object isn't of TRANSIENT state). |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
153 |
* @param a the Accessible object to add listeners to |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
154 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
155 |
private void installListeners(AccessibleContext ac) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
156 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
157 |
if (ac != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
158 |
AccessibleStateSet states = ac.getAccessibleStateSet(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
159 |
if (!states.contains(AccessibleState.TRANSIENT)) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
160 |
ac.addPropertyChangeListener(this); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
161 |
/* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
162 |
* Don't add listeners to transient children. Components |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
163 |
* with transient children should return an AccessibleStateSet |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
164 |
* containing AccessibleState.MANAGES_DESCENDANTS. Components |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
165 |
* may not explicitly return the MANAGES_DESCENDANTS state. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
166 |
* In this case, don't add listeners to the children of |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
167 |
* lists, tables and trees. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
168 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
169 |
AccessibleStateSet set = ac.getAccessibleStateSet(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
170 |
if (set.contains(_AccessibleState.MANAGES_DESCENDANTS)) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
171 |
return; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
172 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
173 |
AccessibleRole role = ac.getAccessibleRole(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
174 |
if (role == AccessibleRole.LIST || |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
175 |
role == AccessibleRole.TREE) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
176 |
return; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
177 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
178 |
if (role == AccessibleRole.TABLE) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
179 |
// handle Oracle tables containing tables |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
180 |
Accessible child = ac.getAccessibleChild(0); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
181 |
if (child != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
182 |
AccessibleContext ac2 = child.getAccessibleContext(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
183 |
if (ac2 != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
184 |
role = ac2.getAccessibleRole(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
185 |
if (role != null && role != AccessibleRole.TABLE) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
186 |
return; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
187 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
188 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
189 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
190 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
191 |
int count = ac.getAccessibleChildrenCount(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
192 |
for (int i = 0; i < count; i++) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
193 |
Accessible child = ac.getAccessibleChild(i); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
194 |
if (child != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
195 |
installListeners(child); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
196 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
197 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
198 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
199 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
200 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
201 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
202 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
203 |
* Removes PropertyChange listeners on all Accessible objects based |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
204 |
* upon the topLevelWindows cached by EventQueueMonitor. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
205 |
* @param eventID the event ID |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
206 |
* @see EventID |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
207 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
208 |
protected void removeListeners() { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
209 |
Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
210 |
if (topLevelWindows != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
211 |
for (int i = 0; i < topLevelWindows.length; i++) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
212 |
if (topLevelWindows[i] instanceof Accessible) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
213 |
removeListeners((Accessible) topLevelWindows[i]); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
214 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
215 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
216 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
217 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
218 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
219 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
220 |
* Removes PropertyChange listeners for the given Accessible object, |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
221 |
* it's children (so long as the object isn't of TRANSIENT state). |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
222 |
* @param a the Accessible object to remove listeners from |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
223 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
224 |
protected void removeListeners(Accessible a) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
225 |
removeListeners(a.getAccessibleContext()); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
226 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
227 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
228 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
229 |
* Removes PropertyChange listeners for the given AccessibleContext |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
230 |
* object, it's children (so long as the object isn't of TRANSIENT |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
231 |
* state). |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
232 |
* @param a the Accessible object to remove listeners from |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
233 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
234 |
private void removeListeners(AccessibleContext ac) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
235 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
236 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
237 |
if (ac != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
238 |
// Listeners are not added to transient components. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
239 |
AccessibleStateSet states = ac.getAccessibleStateSet(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
240 |
if (!states.contains(AccessibleState.TRANSIENT)) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
241 |
ac.removePropertyChangeListener(this); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
242 |
/* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
243 |
* Listeners are not added to transient children. Components |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
244 |
* with transient children should return an AccessibleStateSet |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
245 |
* containing AccessibleState.MANAGES_DESCENDANTS. Components |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
246 |
* may not explicitly return the MANAGES_DESCENDANTS state. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
247 |
* In this case, don't remove listeners from the children of |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
248 |
* lists, tables and trees. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
249 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
250 |
if (states.contains(_AccessibleState.MANAGES_DESCENDANTS)) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
251 |
return; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
252 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
253 |
AccessibleRole role = ac.getAccessibleRole(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
254 |
if (role == AccessibleRole.LIST || |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
255 |
role == AccessibleRole.TABLE || |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
256 |
role == AccessibleRole.TREE) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
257 |
return; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
258 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
259 |
int count = ac.getAccessibleChildrenCount(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
260 |
for (int i = 0; i < count; i++) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
261 |
Accessible child = ac.getAccessibleChild(i); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
262 |
if (child != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
263 |
removeListeners(child); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
264 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
265 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
266 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
267 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
268 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
269 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
270 |
/********************************************************************/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
271 |
/* */ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
272 |
/* Listener Interface Methods */ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
273 |
/* */ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
274 |
/********************************************************************/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
275 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
276 |
/* TopLevelWindow Methods ***************************************/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
277 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
278 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
279 |
* Called when top level window is created. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
280 |
* @see EventQueueMonitor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
281 |
* @see EventQueueMonitor#addTopLevelWindowListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
282 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
283 |
public void topLevelWindowCreated(Window w) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
284 |
if (w instanceof Accessible) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
285 |
installListeners((Accessible) w); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
286 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
287 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
288 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
289 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
290 |
* Called when top level window is destroyed. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
291 |
* @see EventQueueMonitor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
292 |
* @see EventQueueMonitor#addTopLevelWindowListener |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
293 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
294 |
public void topLevelWindowDestroyed(Window w) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
295 |
if (w instanceof Accessible) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
296 |
removeListeners((Accessible) w); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
297 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
298 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
299 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
300 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
301 |
/* PropertyChangeListener Methods **************************************/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
302 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
303 |
public void propertyChange(PropertyChangeEvent e) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
304 |
// propogate the event |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
305 |
Object[] listeners = |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
306 |
AccessibilityEventMonitor.listenerList.getListenerList(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
307 |
for (int i = listeners.length-2; i>=0; i-=2) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
308 |
if (listeners[i]==PropertyChangeListener.class) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
309 |
((PropertyChangeListener)listeners[i+1]).propertyChange(e); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
310 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
311 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
312 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
313 |
// handle childbirth/death |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
314 |
String name = e.getPropertyName(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
315 |
if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
316 |
Object oldValue = e.getOldValue(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
317 |
Object newValue = e.getNewValue(); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
318 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
319 |
if ((oldValue == null) ^ (newValue == null)) { // one null, not both |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
320 |
if (oldValue != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
321 |
// this Accessible is a child that's going away |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
322 |
if (oldValue instanceof Accessible) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
323 |
Accessible a = (Accessible) oldValue; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
324 |
removeListeners(a.getAccessibleContext()); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
325 |
} else if (oldValue instanceof AccessibleContext) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
326 |
removeListeners((AccessibleContext) oldValue); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
327 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
328 |
} else if (newValue != null) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
329 |
// this Accessible is a child was just born |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
330 |
if (newValue instanceof Accessible) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
331 |
Accessible a = (Accessible) newValue; |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
332 |
installListeners(a.getAccessibleContext()); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
333 |
} else if (newValue instanceof AccessibleContext) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
334 |
installListeners((AccessibleContext) newValue); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
335 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
336 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
337 |
} else { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
338 |
System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString()); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
339 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
340 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
341 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
342 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
343 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
344 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
345 |
/* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
346 |
* workaround for no public AccessibleState constructor |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
347 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
348 |
class _AccessibleState extends AccessibleState { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
349 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
350 |
* Indicates this object is responsible for managing its |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
351 |
* subcomponents. This is typically used for trees and tables |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
352 |
* that have a large number of subcomponents and where the |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
353 |
* objects are created only when needed and otherwise remain virtual. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
354 |
* The application should not manage the subcomponents directly. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
355 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
356 |
public static final _AccessibleState MANAGES_DESCENDANTS |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
357 |
= new _AccessibleState ("managesDescendants"); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
358 |
|
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
359 |
/** |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
360 |
* Creates a new AccessibleState using the given locale independent key. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
361 |
* This should not be a public method. Instead, it is used to create |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
362 |
* the constants in this file to make it a strongly typed enumeration. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
363 |
* Subclasses of this class should enforce similar policy. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
364 |
* <p> |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
365 |
* The key String should be a locale independent key for the state. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
366 |
* It is not intended to be used as the actual String to display |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
367 |
* to the user. To get the localized string, use toDisplayString. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
368 |
* |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
369 |
* @param key the locale independent name of the state. |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
370 |
* @see AccessibleBundle#toDisplayString |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
371 |
*/ |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
372 |
protected _AccessibleState(String key) { |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
373 |
super(key); |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
374 |
} |
e02d168adbc6
8076182: Open Source Java Access Bridge - Create Patch for JEP C127 8055831
ptbrunet
parents:
diff
changeset
|
375 |
} |