84 |
import javax.accessibility.AccessibleRole; |
import javax.accessibility.AccessibleRole; |
85 |
import javax.accessibility.AccessibleStateSet; |
import javax.accessibility.AccessibleStateSet; |
86 |
import javax.swing.border.Border; |
import javax.swing.border.Border; |
87 |
|
import javax.swing.border.CompoundBorder; |
88 |
|
import javax.swing.border.TitledBorder; |
89 |
import javax.swing.event.AncestorEvent; |
import javax.swing.event.AncestorEvent; |
90 |
import javax.swing.event.AncestorListener; |
import javax.swing.event.AncestorListener; |
91 |
import javax.swing.event.EventListenerList; |
import javax.swing.event.EventListenerList; |
163 |
protected ContainerListener accessibleContainerHandler; |
protected ContainerListener accessibleContainerHandler; |
164 |
protected FocusListener accessibleFocusHandler; |
protected FocusListener accessibleFocusHandler; |
165 |
|
|
166 |
|
/** |
167 |
|
* Manages the property change listeners; |
168 |
|
*/ |
169 |
|
private SwingPropertyChangeSupport changeSupport; |
170 |
|
|
171 |
protected AccessibleJComponent() |
protected AccessibleJComponent() |
172 |
{ |
{ |
173 |
// TODO: Implement this properly. |
changeSupport = new SwingPropertyChangeSupport(this); |
174 |
} |
} |
175 |
|
|
176 |
/** |
/** |
180 |
*/ |
*/ |
181 |
public void addPropertyChangeListener(PropertyChangeListener listener) |
public void addPropertyChangeListener(PropertyChangeListener listener) |
182 |
{ |
{ |
183 |
// TODO: Why is this overridden? |
changeSupport.addPropertyChangeListener(listener); |
|
super.addPropertyChangeListener(listener); |
|
184 |
} |
} |
185 |
|
|
186 |
|
/** |
187 |
|
* Removes a propery change listener from the list of registered listeners. |
188 |
|
* |
189 |
|
* @param listener the listener to remove |
190 |
|
*/ |
191 |
public void removePropertyChangeListener(PropertyChangeListener listener) |
public void removePropertyChangeListener(PropertyChangeListener listener) |
192 |
{ |
{ |
193 |
// TODO: Implement this properly. |
changeSupport.removePropertyChangeListener(listener); |
194 |
|
} |
195 |
|
|
196 |
|
/** |
197 |
|
* Returns the number of accessible children of this object. |
198 |
|
* |
199 |
|
* @return the number of accessible children of this object |
200 |
|
*/ |
201 |
|
public int getAccessibleChildrenCount() |
202 |
|
{ |
203 |
|
int count = 0; |
204 |
|
Component[] children = getComponents(); |
205 |
|
for (int i = 0; i < children.length; ++i) |
206 |
|
{ |
207 |
|
if (children[i] instanceof Accessible) |
208 |
|
count++; |
209 |
|
} |
210 |
|
return count; |
211 |
|
} |
212 |
|
|
213 |
|
/** |
214 |
|
* Returns the accessible child component at index <code>i</code>. |
215 |
|
* |
216 |
|
* @param i the index of the accessible child to return |
217 |
|
* |
218 |
|
* @return the accessible child component at index <code>i</code> |
219 |
|
*/ |
220 |
|
public Accessible getAccessibleChild(int i) |
221 |
|
{ |
222 |
|
int index = 0; |
223 |
|
Component[] children = getComponents(); |
224 |
|
Accessible found = null; |
225 |
|
for (int j = 0; index != i; j++) |
226 |
|
{ |
227 |
|
if (children[j] instanceof Accessible) |
228 |
|
index++; |
229 |
|
if (index == i) |
230 |
|
found = (Accessible) children[index]; |
231 |
|
} |
232 |
|
// TODO: Figure out what to do when i is not a valid index. |
233 |
|
return found; |
234 |
} |
} |
|
public int getAccessibleChildrenCount() { return 0; } |
|
|
public Accessible getAccessibleChild(int value0) { return null; } |
|
235 |
|
|
236 |
/** |
/** |
237 |
* Returns the accessible state set of this component. |
* Returns the accessible state set of this component. |
245 |
return super.getAccessibleStateSet(); |
return super.getAccessibleStateSet(); |
246 |
} |
} |
247 |
|
|
248 |
public String getAccessibleName() { return null; } |
/** |
249 |
public String getAccessibleDescription() { return null; } |
* Returns the localized name for this object. Generally this should |
250 |
public AccessibleRole getAccessibleRole() { return null; } |
* almost never return {@link Component#getName()} since that is not |
251 |
protected String getBorderTitle(Border value0) { return null; } |
* a localized name. If the object is some kind of text component (like |
252 |
public String getToolTipText() { return null; } |
* a menu item), then the value of the object may be returned. Also, if |
253 |
public String getTitledBorderText() { return null; } |
* the object has a tooltip, the value of the tooltip may also be |
254 |
public AccessibleKeyBinding getAccessibleKeyBinding() { return null; } |
* appropriate. |
255 |
|
* |
256 |
|
* @return the localized name for this object or <code>null</code> if this |
257 |
|
* object has no name |
258 |
|
*/ |
259 |
|
public String getAccessibleName() |
260 |
|
{ |
261 |
|
// TODO: Figure out what exactly to return here. It's possible that this |
262 |
|
// method simply should return null. |
263 |
|
return null; |
264 |
|
} |
265 |
|
|
266 |
|
/** |
267 |
|
* Returns the localized description of this object. |
268 |
|
* |
269 |
|
* @return the localized description of this object or <code>null</code> |
270 |
|
* if this object has no description |
271 |
|
*/ |
272 |
|
public String getAccessibleDescription() |
273 |
|
{ |
274 |
|
// TODO: Figure out what exactly to return here. It's possible that this |
275 |
|
// method simply should return null. |
276 |
|
return null; |
277 |
|
} |
278 |
|
|
279 |
|
/** |
280 |
|
* Returns the accessible role of this component. |
281 |
|
* |
282 |
|
* @return the accessible role of this component |
283 |
|
* |
284 |
|
* @see AccessibleRole |
285 |
|
*/ |
286 |
|
public AccessibleRole getAccessibleRole() |
287 |
|
{ |
288 |
|
// TODO: Check if this is correct. |
289 |
|
return AccessibleRole.SWING_COMPONENT; |
290 |
|
} |
291 |
|
|
292 |
|
/** |
293 |
|
* Recursivly searches a border hierarchy (starting at <code>border) for |
294 |
|
* a titled border and returns the title if one is found, <code>null</code> |
295 |
|
* otherwise. |
296 |
|
* |
297 |
|
* @param border the border to start search from |
298 |
|
* |
299 |
|
* @return the border title of a possibly found titled border |
300 |
|
*/ |
301 |
|
protected String getBorderTitle(Border border) |
302 |
|
{ |
303 |
|
String title = null; |
304 |
|
if (border instanceof CompoundBorder) |
305 |
|
{ |
306 |
|
CompoundBorder compound = (CompoundBorder) border; |
307 |
|
Border inner = compound.getInsideBorder(); |
308 |
|
title = getBorderTitle(inner); |
309 |
|
if (title == null) |
310 |
|
{ |
311 |
|
Border outer = compound.getOutsideBorder(); |
312 |
|
title = getBorderTitle(outer); |
313 |
|
} |
314 |
|
} |
315 |
|
else if (border instanceof TitledBorder) |
316 |
|
{ |
317 |
|
TitledBorder titled = (TitledBorder) border; |
318 |
|
title = titled.getTitle(); |
319 |
|
} |
320 |
|
return title; |
321 |
|
} |
322 |
|
|
323 |
|
/** |
324 |
|
* Returns the tooltip text for this accessible component. |
325 |
|
* |
326 |
|
* @return the tooltip text for this accessible component |
327 |
|
*/ |
328 |
|
public String getToolTipText() |
329 |
|
{ |
330 |
|
return JComponent.this.getToolTipText(); |
331 |
|
} |
332 |
|
|
333 |
|
/** |
334 |
|
* Returns the title of the border of this accessible component if |
335 |
|
* this component has a titled border, otherwise returns <code>null</code>. |
336 |
|
* |
337 |
|
* @return the title of the border of this accessible component if |
338 |
|
* this component has a titled border, otherwise returns |
339 |
|
* <code>null</code> |
340 |
|
*/ |
341 |
|
public String getTitledBorderText() |
342 |
|
{ |
343 |
|
return getBorderTitle(getBorder()); |
344 |
|
} |
345 |
|
|
346 |
|
/** |
347 |
|
* Returns the keybindings associated with this accessible component or |
348 |
|
* <code>null</code> if the component does not support key bindings. |
349 |
|
* |
350 |
|
* @return the keybindings associated with this accessible component |
351 |
|
*/ |
352 |
|
public AccessibleKeyBinding getAccessibleKeyBinding() |
353 |
|
{ |
354 |
|
// TODO: Implement this properly. |
355 |
|
return null; |
356 |
|
} |
357 |
} |
} |
358 |
|
|
359 |
/** |
/** |
3182 |
Rectangle currentClip = clip; |
Rectangle currentClip = clip; |
3183 |
Component found = this; |
Component found = this; |
3184 |
Container parent = this; |
Container parent = this; |
3185 |
while (parent != null) |
while (parent != null && !(parent instanceof Window)) |
3186 |
{ |
{ |
3187 |
Container newParent = parent.getParent(); |
Container newParent = parent.getParent(); |
3188 |
if (newParent == null) |
if (newParent == null) |