feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2002, 2014, 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.
*/
@jdk.Exported(false)
abstract class AccessBridgeLoader {
/**
* Load JavaAccessBridge.DLL (our native half)
*/
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("JavaAccessBridge-32");
return null;
}
}, null, new java.lang.RuntimePermission("loadLibrary.JavaAccessBridge-32")
);
}
boolean useJAWT_DLL = false;
/**
* AccessBridgeLoader constructor
*/
AccessBridgeLoader() {
// load JAWTAccessBridge.DLL on JDK 1.4.1 or later
// determine which version of the JDK is running
String version = System.getProperty("java.version");
if (version != null)
useJAWT_DLL = (version.compareTo("1.4.1") >= 0);
if (useJAWT_DLL) {
// Note that we have to explicitly load JAWT.DLL
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("JAWT");
System.loadLibrary("JAWTAccessBridge-32");
return null;
}
}, null, new RuntimePermission("loadLibrary.JAWT"),
new RuntimePermission("loadLibrary.JAWTAccessBridge-32")
);
}
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2002, 2014, 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.
*/
@jdk.Exported(false)
abstract class AccessBridgeLoader {
/**
* Load JavaAccessBridge.DLL (our native half)
*/
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("JavaAccessBridge-64");
return null;
}
}, null, new RuntimePermission("loadLibrary.JavaAccessBridge-64")
);
}
boolean useJAWT_DLL = false;
/**
* AccessBridgLoader constructor
*/
AccessBridgeLoader() {
// load JAWTAccessBridge.DLL on JDK 1.4.1 or later
String version = System.getProperty("java.version");
if (version != null)
useJAWT_DLL = (version.compareTo("1.4.1") >= 0);
if (useJAWT_DLL) {
// Note that we have to explicitly load JAWT.DLL
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("JAWT");
System.loadLibrary("JAWTAccessBridge-64");
return null;
}
}, null, new RuntimePermission("loadLibrary.JAWT"),
new RuntimePermission("loadLibrary.JAWTAccessBridge-64")
);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2002, 2014, 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.
*/
package com.sun.java.accessibility.legacy;
@jdk.Exported(false)
abstract class AccessBridgeLoader {
/**
* Load JavaAccessBridge.DLL (our native half)
*/
static {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("JavaAccessBridge");
return null;
}
}, null, new RuntimePermission("loadLibrary.JavaAccessBridge")
);
}
boolean useJAWT_DLL = false;
/**
* AccessBridgeLoader constructor
*/
AccessBridgeLoader() {
String version = System.getProperty("java.version");
if (version != null)
useJAWT_DLL = (version.compareTo("1.4.1") >= 0);
// load JAWTAccessBridge.DLL on JDK 1.4.1 or later
if (useJAWT_DLL) {
// Note that we have to explicitly load JAWT.DLL
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Object>() {
public Object run() {
System.loadLibrary("JAWT");
System.loadLibrary("JAWTAccessBridge");
return null;
}
}, null, new RuntimePermission("loadLibrary.JAWT"),
new RuntimePermission("loadLibrary.JAWTAccessBridge")
);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,376 @@
/*
* Copyright (c) 2002, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.util.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import javax.accessibility.*;
/**
* <P>{@code AccessibilityEventMonitor} implements a PropertyChange listener
* on every UI object that implements interface {@code Accessible} in the Java
* Virtual Machine. The events captured by these listeners are made available
* through listeners supported by {@code AccessibilityEventMonitor}.
* With this, all the individual events on each of the UI object
* instances are funneled into one set of PropertyChange listeners.
* <p>This class depends upon {@link EventQueueMonitor}, which provides the base
* level support for capturing the top-level containers as they are created.
*
*/
@jdk.Exported
public class AccessibilityEventMonitor {
// listeners
/**
* The current list of registered {@link java.beans.PropertyChangeListener
* PropertyChangeListener} classes.
*
* @see #addPropertyChangeListener
* @see #removePropertyChangeListener
*/
static protected final AccessibilityListenerList listenerList =
new AccessibilityListenerList();
/**
* The actual listener that is installed on the component instances.
* This listener calls the other registered listeners when an event
* occurs. By doing things this way, the actual number of listeners
* installed on a component instance is drastically reduced.
*/
static protected final AccessibilityEventListener accessibilityListener =
new AccessibilityEventListener();
/**
* Adds the specified listener to receive all PropertyChange events on
* each UI object instance in the Java Virtual Machine as they occur.
* <P>Note: This listener is automatically added to all component
* instances created after this method is called. In addition, it
* is only added to UI object instances that support this listener type.
*
* @param l the listener to add
*
* @see #removePropertyChangeListener
*/
static public void addPropertyChangeListener(PropertyChangeListener l) {
if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
accessibilityListener.installListeners();
}
listenerList.add(PropertyChangeListener.class, l);
}
/**
* Removes the specified listener so it no longer receives PropertyChange
* events when they occur.
* @see #addPropertyChangeListener
* @param l the listener to remove
*/
static public void removePropertyChangeListener(PropertyChangeListener l) {
listenerList.remove(PropertyChangeListener.class, l);
if (listenerList.getListenerCount(PropertyChangeListener.class) == 0) {
accessibilityListener.removeListeners();
}
}
/**
* AccessibilityEventListener is the class that does all the work for
* AccessibilityEventMonitor. It is not intended for use by any other
* class except AccessibilityEventMonitor.
*
*/
static class AccessibilityEventListener implements TopLevelWindowListener,
PropertyChangeListener {
/**
* Create a new instance of this class and install it on each component
* instance in the virtual machine that supports any of the currently
* registered listeners in AccessibilityEventMonitor. Also registers
* itself as a TopLevelWindowListener with EventQueueMonitor so it can
* automatically add new listeners to new components.
* @see EventQueueMonitor
* @see AccessibilityEventMonitor
*/
public AccessibilityEventListener() {
EventQueueMonitor.addTopLevelWindowListener(this);
}
/**
* Installs PropertyChange listeners on all Accessible objects based
* upon the current topLevelWindows cached by EventQueueMonitor.
* @see EventQueueMonitor
* @see AWTEventMonitor
*/
protected void installListeners() {
Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows();
if (topLevelWindows != null) {
for (int i = 0; i < topLevelWindows.length; i++) {
if (topLevelWindows[i] instanceof Accessible) {
installListeners((Accessible) topLevelWindows[i]);
}
}
}
}
/**
* Installs PropertyChange listeners to the Accessible object, and it's
* children (so long as the object isn't of TRANSIENT state).
* @param a the Accessible object to add listeners to
*/
protected void installListeners(Accessible a) {
installListeners(a.getAccessibleContext());
}
/**
* Installs PropertyChange listeners to the AccessibleContext object,
* and it's * children (so long as the object isn't of TRANSIENT state).
* @param a the Accessible object to add listeners to
*/
private void installListeners(AccessibleContext ac) {
if (ac != null) {
AccessibleStateSet states = ac.getAccessibleStateSet();
if (!states.contains(AccessibleState.TRANSIENT)) {
ac.addPropertyChangeListener(this);
/*
* Don't add listeners to transient children. Components
* with transient children should return an AccessibleStateSet
* containing AccessibleState.MANAGES_DESCENDANTS. Components
* may not explicitly return the MANAGES_DESCENDANTS state.
* In this case, don't add listeners to the children of
* lists, tables and trees.
*/
AccessibleStateSet set = ac.getAccessibleStateSet();
if (set.contains(_AccessibleState.MANAGES_DESCENDANTS)) {
return;
}
AccessibleRole role = ac.getAccessibleRole();
if (role == AccessibleRole.LIST ||
role == AccessibleRole.TREE) {
return;
}
if (role == AccessibleRole.TABLE) {
// handle Oracle tables containing tables
Accessible child = ac.getAccessibleChild(0);
if (child != null) {
AccessibleContext ac2 = child.getAccessibleContext();
if (ac2 != null) {
role = ac2.getAccessibleRole();
if (role != null && role != AccessibleRole.TABLE) {
return;
}
}
}
}
int count = ac.getAccessibleChildrenCount();
for (int i = 0; i < count; i++) {
Accessible child = ac.getAccessibleChild(i);
if (child != null) {
installListeners(child);
}
}
}
}
}
/**
* Removes PropertyChange listeners on all Accessible objects based
* upon the topLevelWindows cached by EventQueueMonitor.
* @param eventID the event ID
* @see EventID
*/
protected void removeListeners() {
Window topLevelWindows[] = EventQueueMonitor.getTopLevelWindows();
if (topLevelWindows != null) {
for (int i = 0; i < topLevelWindows.length; i++) {
if (topLevelWindows[i] instanceof Accessible) {
removeListeners((Accessible) topLevelWindows[i]);
}
}
}
}
/**
* Removes PropertyChange listeners for the given Accessible object,
* it's children (so long as the object isn't of TRANSIENT state).
* @param a the Accessible object to remove listeners from
*/
protected void removeListeners(Accessible a) {
removeListeners(a.getAccessibleContext());
}
/**
* Removes PropertyChange listeners for the given AccessibleContext
* object, it's children (so long as the object isn't of TRANSIENT
* state).
* @param a the Accessible object to remove listeners from
*/
private void removeListeners(AccessibleContext ac) {
if (ac != null) {
// Listeners are not added to transient components.
AccessibleStateSet states = ac.getAccessibleStateSet();
if (!states.contains(AccessibleState.TRANSIENT)) {
ac.removePropertyChangeListener(this);
/*
* Listeners are not added to transient children. Components
* with transient children should return an AccessibleStateSet
* containing AccessibleState.MANAGES_DESCENDANTS. Components
* may not explicitly return the MANAGES_DESCENDANTS state.
* In this case, don't remove listeners from the children of
* lists, tables and trees.
*/
if (states.contains(_AccessibleState.MANAGES_DESCENDANTS)) {
return;
}
AccessibleRole role = ac.getAccessibleRole();
if (role == AccessibleRole.LIST ||
role == AccessibleRole.TABLE ||
role == AccessibleRole.TREE) {
return;
}
int count = ac.getAccessibleChildrenCount();
for (int i = 0; i < count; i++) {
Accessible child = ac.getAccessibleChild(i);
if (child != null) {
removeListeners(child);
}
}
}
}
}
/********************************************************************/
/* */
/* Listener Interface Methods */
/* */
/********************************************************************/
/* TopLevelWindow Methods ***************************************/
/**
* Called when top level window is created.
* @see EventQueueMonitor
* @see EventQueueMonitor#addTopLevelWindowListener
*/
public void topLevelWindowCreated(Window w) {
if (w instanceof Accessible) {
installListeners((Accessible) w);
}
}
/**
* Called when top level window is destroyed.
* @see EventQueueMonitor
* @see EventQueueMonitor#addTopLevelWindowListener
*/
public void topLevelWindowDestroyed(Window w) {
if (w instanceof Accessible) {
removeListeners((Accessible) w);
}
}
/* PropertyChangeListener Methods **************************************/
public void propertyChange(PropertyChangeEvent e) {
// propogate the event
Object[] listeners =
AccessibilityEventMonitor.listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i]==PropertyChangeListener.class) {
((PropertyChangeListener)listeners[i+1]).propertyChange(e);
}
}
// handle childbirth/death
String name = e.getPropertyName();
if (name.compareTo(AccessibleContext.ACCESSIBLE_CHILD_PROPERTY) == 0) {
Object oldValue = e.getOldValue();
Object newValue = e.getNewValue();
if ((oldValue == null) ^ (newValue == null)) { // one null, not both
if (oldValue != null) {
// this Accessible is a child that's going away
if (oldValue instanceof Accessible) {
Accessible a = (Accessible) oldValue;
removeListeners(a.getAccessibleContext());
} else if (oldValue instanceof AccessibleContext) {
removeListeners((AccessibleContext) oldValue);
}
} else if (newValue != null) {
// this Accessible is a child was just born
if (newValue instanceof Accessible) {
Accessible a = (Accessible) newValue;
installListeners(a.getAccessibleContext());
} else if (newValue instanceof AccessibleContext) {
installListeners((AccessibleContext) newValue);
}
}
} else {
System.out.println("ERROR in usage of PropertyChangeEvents for: " + e.toString());
}
}
}
}
}
/*
* workaround for no public AccessibleState constructor
*/
class _AccessibleState extends AccessibleState {
/**
* Indicates this object is responsible for managing its
* subcomponents. This is typically used for trees and tables
* that have a large number of subcomponents and where the
* objects are created only when needed and otherwise remain virtual.
* The application should not manage the subcomponents directly.
*/
public static final _AccessibleState MANAGES_DESCENDANTS
= new _AccessibleState ("managesDescendants");
/**
* Creates a new AccessibleState using the given locale independent key.
* This should not be a public method. Instead, it is used to create
* the constants in this file to make it a strongly typed enumeration.
* Subclasses of this class should enforce similar policy.
* <p>
* The key String should be a locale independent key for the state.
* It is not intended to be used as the actual String to display
* to the user. To get the localized string, use toDisplayString.
*
* @param key the locale independent name of the state.
* @see AccessibleBundle#toDisplayString
*/
protected _AccessibleState(String key) {
super(key);
}
}

View File

@@ -0,0 +1,182 @@
/*
* Copyright (c) 2005, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.util.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import javax.accessibility.*;
/**
* <P>The {@code AccessibilityListenerList} is a copy of the Swing
* {@link javax.swing.event.EventListenerList EventListerList} class.
*
*/
@jdk.Exported
public class AccessibilityListenerList {
/* A null array to be shared by all empty listener lists */
private final static Object[] NULL_ARRAY = new Object[0];
/**
* The list of listener type, listener pairs
*/
protected transient Object[] listenerList = NULL_ARRAY;
/**
* Passes back the event listener list as an array of listener type, listener pairs.
* Note that for performance reasons, this implementation passes back the actual
* data structure in which the listener data is stored internally. This method
* is guaranteed to pass back a non-null array, so that no null-checking
* is required in fire methods. A zero-length array of Object is returned if
* there are currently no listeners.
* <p>
* Absolutely no modification of the data contained in this array should be
* made. If any such manipulation is necessary, it should be done on a copy
* of the array returned rather than the array itself.
*
* @return an array of listener type, listener pairs.
*/
public Object[] getListenerList() {
return listenerList;
}
/**
* Returns the total number of listeners for this listener list.
*
* @return the total number of listeners for this listener list.
*/
public int getListenerCount() {
return listenerList.length/2;
}
/**
* Return the total number of listeners of the supplied type
* for this listener list.
*
* @param t the type of the listener to be counted
* @return the number of listeners found
*/
public int getListenerCount(Class t) {
int count = 0;
Object[] lList = listenerList;
for (int i = 0; i < lList.length; i+=2) {
if (t == (Class)lList[i])
count++;
}
return count;
}
/**
* Add the listener as a listener of the specified type.
*
* @param t the type of the listener to be added
* @param l the listener to be added
*/
public synchronized void add(Class t, EventListener l) {
if (!t.isInstance(l)) {
throw new IllegalArgumentException("Listener " + l +
" is not of type " + t);
}
if (l ==null) {
throw new IllegalArgumentException("Listener " + l +
" is null");
}
if (listenerList == NULL_ARRAY) {
// if this is the first listener added,
// initialize the lists
listenerList = new Object[] { t, l };
} else {
// Otherwise copy the array and add the new listener
int i = listenerList.length;
Object[] tmp = new Object[i+2];
System.arraycopy(listenerList, 0, tmp, 0, i);
tmp[i] = t;
tmp[i+1] = l;
listenerList = tmp;
}
}
/**
* Remove the listener as a listener of the specified type.
*
* @param t the type of the listener to be removed
* @param l the listener to be removed
*/
public synchronized void remove(Class t, EventListener l) {
if (!t.isInstance(l)) {
throw new IllegalArgumentException("Listener " + l +
" is not of type " + t);
}
if (l ==null) {
throw new IllegalArgumentException("Listener " + l +
" is null");
}
// Is l on the list?
int index = -1;
for (int i = listenerList.length-2; i>=0; i-=2) {
if ((listenerList[i]==t) && (listenerList[i+1] == l)) {
index = i;
break;
}
}
// If so, remove it
if (index != -1) {
Object[] tmp = new Object[listenerList.length-2];
// Copy the list up to index
System.arraycopy(listenerList, 0, tmp, 0, index);
// Copy from two past the index, up to
// the end of tmp (which is two elements
// shorter than the old list)
if (index < tmp.length)
System.arraycopy(listenerList, index+2, tmp, index,
tmp.length - index);
// set the listener array to the new array or null
listenerList = (tmp.length == 0) ? NULL_ARRAY : tmp;
}
}
/**
* Return a string representation of the {@code AccessibilityListenerList}.
*
* @return a string representation of the {@code AccessibilityListenerList}.
*/
public String toString() {
Object[] lList = listenerList;
String s = "EventListenerList: ";
s += lList.length/2 + " listeners: ";
for (int i = 0 ; i <= lList.length-2 ; i+=2) {
s += " type " + ((Class)lList[i]).getName();
s += " listener " + lList[i+1];
}
return s;
}
}

View File

@@ -0,0 +1,206 @@
/*
* Copyright (c) 2002, 2015, 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.
*/
package com.sun.java.accessibility.util;
/**
* EventID contains integer constants that map to event support in
* AWT and Swing. They are used by primarily by AWTEventMonitor,
* AWTEventsListener, SwingEventMonitor, and SwingEventListener, but
* can be freely used by any other class.
*
* @see AWTEventMonitor
* @see SwingEventMonitor
*
*/
@jdk.Exported
public class EventID {
/**
* Maps to AWT Action support (i.e., ActionListener and ActionEvent)
*/
static public final int ACTION = 0;
/**
* Maps to AWT Adjustment support (i.e., AdjustmentListener
* and AdjustmentEvent)
*/
static public final int ADJUSTMENT = 1;
/**
* Maps to AWT Component support (i.e., ComponentListener
* and ComponentEvent)
*/
static public final int COMPONENT = 2;
/**
* Maps to AWT Container support (i.e., ContainerListener
* and ContainerEvent)
*/
static public final int CONTAINER = 3;
/**
* Maps to AWT Focus support (i.e., FocusListener and FocusEvent)
*/
static public final int FOCUS = 4;
/**
* Maps to AWT Item support (i.e., ItemListener and ItemEvent)
*/
static public final int ITEM = 5;
/**
* Maps to AWT Key support (i.e., KeyListener and KeyEvent)
*/
static public final int KEY = 6;
/**
* Maps to AWT Mouse support (i.e., MouseListener and MouseEvent)
*/
static public final int MOUSE = 7;
/**
* Maps to AWT MouseMotion support (i.e., MouseMotionListener
* and MouseMotionEvent)
*/
static public final int MOTION = 8;
/**
* Maps to AWT Text support (i.e., TextListener and TextEvent)
*/
static public final int TEXT = 10;
/**
* Maps to AWT Window support (i.e., WindowListener and WindowEvent)
*/
static public final int WINDOW = 11;
/**
* Maps to Swing Ancestor support (i.e., AncestorListener and
* AncestorEvent)
*/
static public final int ANCESTOR = 12;
/**
* Maps to Swing Text Caret support (i.e., CaretListener and
* CaretEvent)
*/
static public final int CARET = 13;
/**
* Maps to Swing CellEditor support (i.e., CellEditorListener and
* CellEditorEvent)
*/
static public final int CELLEDITOR = 14;
/**
* Maps to Swing Change support (i.e., ChangeListener and
* ChangeEvent)
*/
static public final int CHANGE = 15;
/**
* Maps to Swing TableColumnModel support (i.e.,
* TableColumnModelListener and TableColumnModelEvent)
*/
static public final int COLUMNMODEL = 16;
/**
* Maps to Swing Document support (i.e., DocumentListener and
* DocumentEvent)
*/
static public final int DOCUMENT = 17;
/**
* Maps to Swing ListData support (i.e., ListDataListener and
* ListDataEvent)
*/
static public final int LISTDATA = 18;
/**
* Maps to Swing ListSelection support (i.e., ListSelectionListener and
* ListSelectionEvent)
*/
static public final int LISTSELECTION = 19;
/**
* Maps to Swing Menu support (i.e., MenuListener and
* MenuEvent)
*/
static public final int MENU = 20;
/**
* Maps to Swing PopupMenu support (i.e., PopupMenuListener and
* PopupMenuEvent)
*/
static public final int POPUPMENU = 21;
/**
* Maps to Swing TableModel support (i.e., TableModelListener and
* TableModelEvent)
*/
static public final int TABLEMODEL = 22;
/**
* Maps to Swing TreeExpansion support (i.e., TreeExpansionListener and
* TreeExpansionEvent)
*/
static public final int TREEEXPANSION = 23;
/**
* Maps to Swing TreeModel support (i.e., TreeModelListener and
* TreeModelEvent)
*/
static public final int TREEMODEL = 24;
/**
* Maps to Swing TreeSelection support (i.e., TreeSelectionListener and
* TreeSelectionEvent)
*/
static public final int TREESELECTION = 25;
/**
* Maps to Swing UndoableEdit support (i.e., UndoableEditListener and
* UndoableEditEvent)
*/
static public final int UNDOABLEEDIT = 26;
/**
* Maps to Beans PropertyChange support (i.e., PropertyChangeListener
* and PropertyChangeEvent)
*/
static public final int PROPERTYCHANGE = 27;
/**
* Maps to Beans VetoableChange support (i.e., VetoableChangeListener
* and VetoableChangeEvent)
*/
static public final int VETOABLECHANGE = 28;
/**
* Maps to Swing InternalFrame support (i.e., InternalFrameListener)
*/
static public final int INTERNALFRAME = 29;
}

View File

@@ -0,0 +1,619 @@
/*
* Copyright (c) 2002, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.accessibility.*;
import java.security.AccessController;
import java.security.PrivilegedAction;
/**
* The {@code EventQueueMonitor} class provides key core functionality for Assistive
* Technologies (and other system-level technologies that need some of the same
* things that Assistive Technology needs).
*
* @see AWTEventMonitor
* @see SwingEventMonitor
*/
@jdk.Exported
public class EventQueueMonitor
implements AWTEventListener {
// NOTE: All of the following properties are static. The reason
// for this is that there may be multiple EventQueue instances
// in use in the same VM. By making these properties static,
// we can guarantee we get the information from all of the
// EventQueue instances.
// The stuff that is cached.
//
static Vector topLevelWindows = new Vector();
static Window topLevelWindowWithFocus = null;
static Point currentMousePosition = null;
static Component currentMouseComponent = null;
// Low-level listener interfaces
//
static GUIInitializedListener guiInitializedListener = null;
static TopLevelWindowListener topLevelWindowListener = null;
static MouseMotionListener mouseMotionListener = null;
/**
* Class variable stating whether the assistive technologies have
* been loaded yet or not. The assistive technologies won't be
* loaded until the first event is posted to the EventQueue. This
* gives the toolkit a chance to do all the necessary initialization
* it needs to do.
*/
/**
* Class variable stating whether the GUI subsystem has been initialized
* or not.
*
* @see #isGUIInitialized
*/
static boolean guiInitialized = false;
/**
* Queue that holds events for later processing.
*/
static EventQueueMonitorItem componentEventQueue = null;
/**
* Class that tells us what the component event dispatch thread is.
*/
static private ComponentEvtDispatchThread cedt = null;
/**
* Handle the synchronization between the thing that populates the
* component event dispatch thread ({@link #queueComponentEvent})
* and the thing that processes the events ({@link ComponentEvtDispatchThread}).
*/
static Object componentEventQueueLock = new Object();
/**
* Create a new {@code EventQueueMonitor} instance. Normally, this will
* be called only by the AWT Toolkit during initialization time.
* Assistive technologies should not create instances of
* EventQueueMonitor by themselves. Instead, they should either
* refer to it directly via the static methods in this class, e.g.,
* {@link #getCurrentMousePosition} or obtain the instance by asking the
* Toolkit, e.g., {@link java.awt.Toolkit#getSystemEventQueue}.
*/
public EventQueueMonitor() {
if (cedt == null) {
cedt = new ComponentEvtDispatchThread("EventQueueMonitor-ComponentEvtDispatch");
cedt.setDaemon(true);
cedt.start();
}
}
/**
* Queue up a {@link java.awt.event.ComponentEvent ComponentEvent} for later
* processing by the {@link ComponentEvtDispatch} thread.
*
* @param e a {@code ComponentEvent}
*/
static void queueComponentEvent(ComponentEvent e) {
synchronized(componentEventQueueLock) {
EventQueueMonitorItem eqi = new EventQueueMonitorItem(e);
if (componentEventQueue == null) {
componentEventQueue = eqi;
} else {
EventQueueMonitorItem q = componentEventQueue;
while (true) {
if (q.next != null) {
q = q.next;
} else {
break;
}
}
q.next = eqi;
}
componentEventQueueLock.notifyAll();
}
}
/**
* Tell the {@code EventQueueMonitor} to start listening for events.
*/
public static void maybeInitialize() {
if (cedt == null) {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
public Object run() {
try {
long eventMask = AWTEvent.WINDOW_EVENT_MASK |
AWTEvent.FOCUS_EVENT_MASK |
AWTEvent.MOUSE_MOTION_EVENT_MASK;
Toolkit.getDefaultToolkit().addAWTEventListener(new EventQueueMonitor(), eventMask);
} catch (Exception e) {
}
return null;
}
}
);
}
}
/**
* Handle events as a result of registering a listener
* on the {@link java.awt.EventQueue EventQueue} in {@link #maybeInitialize}.
*/
public void eventDispatched(AWTEvent theEvent) {
processEvent(theEvent);
}
/**
* Assisitive technologies that have
* registered a {@link GUIInitializedListener} will be notified.
*
* @see #addGUIInitializedListener
*/
static void maybeNotifyAssistiveTechnologies() {
if (!guiInitialized) {
guiInitialized = true;
if (guiInitializedListener != null) {
guiInitializedListener.guiInitialized();
}
}
}
/********************************************************************/
/* */
/* Package Private Methods */
/* */
/********************************************************************/
/**
* Add a Container to the list of top-level containers
* in the cache. This follows the object's hierarchy up the
* tree until it finds the top most parent. If the parent is
* not already in the list of Containers, it adds it to the list.
*
* @param c the Container
*/
static void addTopLevelWindow(Component c) {
Container parent;
if (c == null) {
return;
}
if (!(c instanceof Window)) {
addTopLevelWindow(c.getParent());
return;
}
if ((c instanceof Dialog) || (c instanceof Window)) {
parent = (Container) c;
} else {
parent = c.getParent();
if (parent != null) {
addTopLevelWindow(parent);
return;
}
}
if (parent == null) {
parent = (Container) c;
}
// Because this method is static, do not make it synchronized because
// it can lock the whole class. Instead, just lock what needs to be
// locked.
//
synchronized (topLevelWindows) {
if ((parent != null) && !topLevelWindows.contains(parent)) {
topLevelWindows.addElement(parent);
if (topLevelWindowListener != null) {
topLevelWindowListener.topLevelWindowCreated((Window) parent);
}
}
}
}
/**
* Removes a container from the list of top level containers in the cache.
*
* @param c the top level container to remove
*/
static void removeTopLevelWindow(Window w) {
// Because this method is static, do not make it synchronized because
// it can lock the whole class. Instead, just lock what needs to be
// locked.
//
synchronized (topLevelWindows) {
if (topLevelWindows.contains(w)) {
topLevelWindows.removeElement(w);
if (topLevelWindowListener != null) {
topLevelWindowListener.topLevelWindowDestroyed(w);
}
}
}
}
/**
* Update current mouse position.
*
* @param mouseEvent the MouseEvent that holds the new mouse position.
*/
static void updateCurrentMousePosition(MouseEvent mouseEvent) {
Point oldMousePos = currentMousePosition;
// Be careful here. The component in the event might be
// hidden by the time we process the event.
try {
Point eventPoint = mouseEvent.getPoint();
currentMouseComponent = (Component) (mouseEvent.getSource());
currentMousePosition = currentMouseComponent.getLocationOnScreen();
currentMousePosition.translate(eventPoint.x,eventPoint.y);
} catch (Exception e) {
currentMousePosition = oldMousePos;
}
}
/**
* Process the event. This maintains the event cache in addition
* to calling all the registered listeners. NOTE: The events that
* come through here are from peered Components.
*
* @param theEvent the AWTEvent
*/
static void processEvent(AWTEvent theEvent) {
switch (theEvent.getID()) {
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
case FocusEvent.FOCUS_GAINED:
case WindowEvent.WINDOW_DEACTIVATED:
queueComponentEvent((ComponentEvent) theEvent);
break;
case WindowEvent.WINDOW_ACTIVATED:
// Dialogs fire WINDOW_ACTIVATED and FOCUS_GAINED events
// before WINDOW_OPENED so we need to add topLevelListeners
// for the dialog when it is first activated to get a
// focus gained event for the focus component in the dialog.
if (theEvent instanceof ComponentEvent) {
ComponentEvent ce = (ComponentEvent)theEvent;
if (ce.getComponent() instanceof Window) {
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
} else {
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
}
}
queueComponentEvent((ComponentEvent) theEvent);
break;
// handle WINDOW_OPENED and WINDOW_CLOSED events synchronously
case WindowEvent.WINDOW_OPENED:
if (theEvent instanceof ComponentEvent) {
ComponentEvent ce = (ComponentEvent)theEvent;
if (ce.getComponent() instanceof Window) {
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
} else {
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
EventQueueMonitor.addTopLevelWindow(ce.getComponent());
}
}
break;
case WindowEvent.WINDOW_CLOSED:
if (theEvent instanceof ComponentEvent) {
ComponentEvent ce = (ComponentEvent)theEvent;
EventQueueMonitor.removeTopLevelWindow((Window) (ce.getComponent()));
}
break;
default:
break;
}
}
/**
* Internal test
*/
static synchronized Component getShowingComponentAt(Container c, int x, int y) {
if (!c.contains(x, y)) {
return null;
}
int ncomponents = c.getComponentCount();
for (int i = 0 ; i < ncomponents ; i++) {
Component comp = c.getComponent(i);
if (comp != null && comp.isShowing()) {
Point location = comp.getLocation();
if (comp.contains(x - location.x, y - location.y)) {
return comp;
}
}
}
return c;
}
/**
* Return the Component at the given Point on the screen in the
* given Container.
*
* @param c the Container to search
* @param p the Point in screen coordinates
* @return the Component at the given Point on the screen in the
* given Container -- can be null if no Component is at that Point
*/
static synchronized Component getComponentAt(Container c, Point p) {
if (!c.isShowing()) {
return null;
}
Component comp;
Point containerLoc = c.getLocationOnScreen();
Point containerPoint = new Point(p.x - containerLoc.x,
p.y - containerLoc.y);
comp = getShowingComponentAt(c, containerPoint.x, containerPoint.y);
if ((comp != c) && (comp instanceof Container)) {
return getComponentAt((Container)comp,p);
} else {
return comp;
}
}
/**
* Obtain the {@link javax.accessibility.Accessible Accessible} object at the given point on the Screen.
* The return value may be null if an {@code Accessible} object cannot be
* found at the particular point.
*
* @param p the point to be accessed
* @return the {@code Accessible} at the specified point
*/
static public Accessible getAccessibleAt(Point p) {
Window w = getTopLevelWindowWithFocus();
Window[] wins = getTopLevelWindows();
Component c = null;
// See if the point we're being asked about is the
// currentMousePosition. If so, start with the component
// that we know the currentMousePostion is over
//
if (currentMousePosition == null) {
return null;
}
if (currentMousePosition.equals(p)) {
if (currentMouseComponent instanceof Container) {
c = getComponentAt((Container) currentMouseComponent, p);
}
}
// Try the window with focus next
//
if (c == null && w != null) {
c = getComponentAt(w,p);
}
// Try the other windows next. [[[WDW: Stacking order???]]]
if (c == null) {
for (int i = 0; i < wins.length; i++) {
c = getComponentAt(wins[i],p);
if (c != null) {
break;
}
}
}
if (c instanceof Accessible) {
AccessibleContext ac = ((Accessible) c).getAccessibleContext();
if (ac != null) {
AccessibleComponent acmp = ac.getAccessibleComponent();
if ((acmp != null) && (ac.getAccessibleChildrenCount() != 0)) {
Point location = acmp.getLocationOnScreen();
location.move(p.x - location.x, p.y - location.y);
return acmp.getAccessibleAt(location);
}
}
return (Accessible) c;
} else {
return Translator.getAccessible(c);
}
}
/********************************************************************/
/* */
/* Public Methods */
/* */
/********************************************************************/
/**
* Says whether the GUI subsystem has been initialized or not.
* If this returns true, the assistive technology can freely
* create GUI component instances. If the return value is false,
* the assistive technology should register a {@link GUIInitializedListener}
* and wait to create GUI component instances until the listener is
* called.
*
* @return true if the GUI subsystem has been initialized
* @see #addGUIInitializedListener
*/
static public boolean isGUIInitialized() {
maybeInitialize();
return guiInitialized;
}
/**
* Adds the specified listener to be notified when the GUI subsystem
* is initialized. Assistive technologies should get the results of
* {@link #isGUIInitialized} before calling this method.
*
* @param l the listener to add
* @see #isGUIInitialized
* @see #removeTopLevelWindowListener
*/
static public void addGUIInitializedListener(GUIInitializedListener l) {
maybeInitialize();
guiInitializedListener =
GUIInitializedMulticaster.add(guiInitializedListener,l);
}
/**
* Removes the specified listener to be notified when the GUI subsystem
* is initialized.
*
* @param l the listener to remove
* @see #addGUIInitializedListener
*/
static public void removeGUIInitializedListener(GUIInitializedListener l) {
guiInitializedListener =
GUIInitializedMulticaster.remove(guiInitializedListener,l);
}
/**
* Adds the specified listener to be notified when a top level window
* is created or destroyed.
*
* @param l the listener to add
* @see #removeTopLevelWindowListener
*/
static public void addTopLevelWindowListener(TopLevelWindowListener l) {
topLevelWindowListener =
TopLevelWindowMulticaster.add(topLevelWindowListener,l);
}
/**
* Removes the specified listener to be notified when a top level window
* is created or destroyed.
*
* @param l the listener to remove
* @see #addTopLevelWindowListener
*/
static public void removeTopLevelWindowListener(TopLevelWindowListener l) {
topLevelWindowListener =
TopLevelWindowMulticaster.remove(topLevelWindowListener,l);
}
/**
* Return the last recorded position of the mouse in screen coordinates.
*
* @return the last recorded position of the mouse in screen coordinates
*/
static public Point getCurrentMousePosition() {
return currentMousePosition;
}
/**
* Return the list of top level Windows in use in the Java Virtual Machine.
*
* @return an array of top level {@code Window}s in use in the Java Virtual Machine
*/
static public Window[] getTopLevelWindows() {
// Because this method is static, do not make it synchronized because
// it can lock the whole class. Instead, just lock what needs to be
// locked.
//
synchronized (topLevelWindows) {
int count = topLevelWindows.size();
if (count > 0) {
Window[] w = new Window[count];
for (int i = 0; i < count; i++) {
w[i] = (Window)topLevelWindows.elementAt(i);
}
return w;
} else {
return new Window[0];
}
}
}
/**
* Return the top level {@code Window} that currently has keyboard focus.
*
* @return the top level {@code Window} that currently has keyboard focus
*/
static public Window getTopLevelWindowWithFocus() {
return topLevelWindowWithFocus;
}
}
/**
* Handle all Component events in a separate thread. The reason for this is
* that WindowEvents tend to be used to do lots of processing on the Window
* hierarchy. As a result, it can frequently result in deadlock situations.
*/
class ComponentEvtDispatchThread extends Thread {
public ComponentEvtDispatchThread(String name) {
super(name);
}
public void run() {
ComponentEvent ce = null;
while (true) {
synchronized(EventQueueMonitor.componentEventQueueLock) {
while (EventQueueMonitor.componentEventQueue == null) {
try {
EventQueueMonitor.componentEventQueueLock.wait();
} catch (InterruptedException e) {
}
}
ce = (ComponentEvent)EventQueueMonitor.componentEventQueue.event;
EventQueueMonitor.componentEventQueue =
EventQueueMonitor.componentEventQueue.next;
}
switch (ce.getID()) {
case MouseEvent.MOUSE_MOVED:
case MouseEvent.MOUSE_DRAGGED:
EventQueueMonitor.updateCurrentMousePosition((MouseEvent) ce);
break;
case WindowEvent.WINDOW_ACTIVATED:
EventQueueMonitor.maybeNotifyAssistiveTechnologies();
EventQueueMonitor.topLevelWindowWithFocus = ((WindowEvent) ce).getWindow();
break;
default:
break;
}
}
}
}
/**
* EventQueueMonitorItem is the basic type that handles the
* queue for queueComponentEvent and the ComponentEvtDispatchThread.
*/
class EventQueueMonitorItem {
AWTEvent event;
EventQueueMonitorItem next;
EventQueueMonitorItem(AWTEvent evt) {
event = evt;
next = null;
}
}

View File

@@ -0,0 +1,61 @@
/*
* Copyright (c) 2002, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.awt.*;
import java.util.*;
import javax.accessibility.*;
/**
* The {@code GUIInitializedListener} interface is used by the {@link EventQueueMonitor}
* class to notify an interested party when the GUI subsystem has been
* initialized. This is necessary because assistive technologies can
* be loaded before the GUI subsystem is initialized. As a result,
* assistive technologies should check the
* {@link EventQueueMonitor#isGUIInitialized isGUIInitialized} method
* of {@code EventQueueMonitor} before creating any GUI components. If the
* return value is true, assistive technologies can create GUI components
* following the same thread restrictions as any other application. If
* the return value is false, the assistive technology should register
* a {@code GUIInitializedListener} with the {@code EventQueueMonitor} to be notified
* when the GUI subsystem is initialized.
*
* @see EventQueueMonitor
* @see EventQueueMonitor#isGUIInitialized
* @see EventQueueMonitor#addGUIInitializedListener
* @see EventQueueMonitor#removeGUIInitializedListener
*
*/
@jdk.Exported
public interface GUIInitializedListener extends EventListener {
/**
* Invoked when the GUI subsystem is initialized and it's OK for
* the assisitive technology to create instances of GUI objects.
*/
public void guiInitialized();
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2005, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.awt.*;
import java.util.EventListener;
import javax.accessibility.*;
/**
* The GUIInitializedMulticaster class is used to maintain a list of
* GUIInitializedListener classes. It is intended to be used primarily
* for internal support in the EventQueueMonitor class, and is not intended
* to be used by classes outside the Java Accessibility Utility package.
*
* @see EventQueueMonitor
* @see EventQueueMonitor#addGUIInitializedListener
* @see EventQueueMonitor#removeGUIInitializedListener
*
*/
@jdk.Exported(false)
public class GUIInitializedMulticaster
extends AWTEventMulticaster implements GUIInitializedListener
{
protected GUIInitializedMulticaster(EventListener a, EventListener b) {
super(a, b);
}
public void guiInitialized() {
((GUIInitializedListener)a).guiInitialized();
((GUIInitializedListener)b).guiInitialized();
}
public static GUIInitializedListener add(GUIInitializedListener a, GUIInitializedListener b) {
return (GUIInitializedListener)addInternal(a, b);
}
public static GUIInitializedListener remove(GUIInitializedListener l, GUIInitializedListener oldl) {
return (GUIInitializedListener)removeInternal(l, oldl);
}
protected static EventListener addInternal(EventListener a, EventListener b) {
if (a == null) return b;
if (b == null) return a;
return new GUIInitializedMulticaster(a, b);
}
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
if (l == oldl || l == null) {
return null;
} else if (l instanceof GUIInitializedMulticaster) {
return ((GUIInitializedMulticaster)l).remove(oldl);
} else {
return l; // it's not here
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2002, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.awt.*;
import java.util.*;
import javax.accessibility.*;
/**
* The {@code TopLevelWindowListener} interface is used by the {@link EventQueueMonitor}
* class to notify an interested party when a top level window is created
* or destroyed in the Java Virtual Machine. Classes wishing to express
* an interest in top level window events should implement this interface
* and register themselves with the {@code EventQueueMonitor} by calling the
* {@link EventQueueMonitor#addTopLevelWindowListener EventQueueMonitor.addTopLevelWindowListener}
* class method.
*
* @see EventQueueMonitor
* @see EventQueueMonitor#addTopLevelWindowListener
* @see EventQueueMonitor#removeTopLevelWindowListener
*
*/
@jdk.Exported
public interface TopLevelWindowListener extends EventListener {
/**
* Invoked when a new top level window has been created.
*
* @param w the Window that was created
*/
public void topLevelWindowCreated(Window w);
/**
* Invoked when a top level window has been destroyed.
*
* @param w the Window that was destroyed
*/
public void topLevelWindowDestroyed(Window w);
}

View File

@@ -0,0 +1,86 @@
/*
* Copyright (c) 2005, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.awt.*;
import java.util.EventListener;
import javax.accessibility.*;
/**
* The TopLevelWindowMulticaster class is used to maintain a list of
* TopLevelWindowListener classes. It is intended to be used primarily
* for internal support in the EventQueueMonitor class, and is not intended
* to be used by classes outside the Java Accessibility Utility package.
*
* @see EventQueueMonitor
* @see EventQueueMonitor#addTopLevelWindowListener
* @see EventQueueMonitor#removeTopLevelWindowListener
*
*/
@jdk.Exported(false)
public class TopLevelWindowMulticaster
extends AWTEventMulticaster implements TopLevelWindowListener
{
protected TopLevelWindowMulticaster(EventListener a, EventListener b) {
super(a, b);
}
public void topLevelWindowCreated(Window w) {
((TopLevelWindowListener)a).topLevelWindowCreated(w);
((TopLevelWindowListener)b).topLevelWindowCreated(w);
}
public void topLevelWindowDestroyed(Window w) {
((TopLevelWindowListener)a).topLevelWindowDestroyed(w);
((TopLevelWindowListener)b).topLevelWindowDestroyed(w);
}
public static TopLevelWindowListener add(TopLevelWindowListener a, TopLevelWindowListener b) {
return (TopLevelWindowListener)addInternal(a, b);
}
public static TopLevelWindowListener remove(TopLevelWindowListener l, TopLevelWindowListener oldl) {
return (TopLevelWindowListener)removeInternal(l, oldl);
}
protected static EventListener addInternal(EventListener a, EventListener b) {
if (a == null) return b;
if (b == null) return a;
return new TopLevelWindowMulticaster(a, b);
}
protected static EventListener removeInternal(EventListener l, EventListener oldl) {
if (l == oldl || l == null) {
return null;
} else if (l instanceof TopLevelWindowMulticaster) {
return ((TopLevelWindowMulticaster)l).remove(oldl);
} else {
return l; // it's not here
}
}
}

View File

@@ -0,0 +1,730 @@
/*
* Copyright (c) 2002, 2015, 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.
*/
package com.sun.java.accessibility.util;
import java.lang.*;
import java.beans.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
// Do not import Swing classes. This module is intended to work
// with both Swing and AWT.
// import javax.swing.*;
import javax.accessibility.*;
/**
* <p>The {@code Translator} class provides a translation to interface
* {@link javax.accessibility.Accessible Accessible}
* for objects that do not implement interface {@code Accessible}. Assistive
* technologies can use the {@link #getAccessible getAccessible} class method of
* {@code Translator} to obtain an object that implements interface {@code Accessible}.
* If the object passed in already implements interface {@code Accessible},
* {@code getAccessible} merely returns the object.
*
* <p>An example of how an assistive technology might use the {@code Translator}
* class is as follows:
*
* <PRE>
* Accessible accessible = Translator.getAccessible(someObj);
* // obtain information from the 'accessible' object.
* </PRE>
*
* <P>Note: This implementation is missing many things and is not a recommended way
* to implement accessibility features for a toolkit. Instead of relying upon this
* code, a toolkit's components should implement interface {@code Accessible} directly.
*/
@jdk.Exported
public class Translator extends AccessibleContext
implements Accessible, AccessibleComponent {
/** The source object needing translating. */
protected Object source;
/**
* Find a translator for this class. If one doesn't exist for this
* class explicitly, try its superclass and so on.
*
* @param c a Class
* @return the {@code Translator} Class for the Class passed in
*/
protected static Class getTranslatorClass(Class c) {
Class t = null;
if (c == null) {
return null;
}
try {
t = Class.forName("com.sun.java.accessibility.util."
+ c.getName()
+ "Translator");
return t;
} catch (Exception e) {
return getTranslatorClass(c.getSuperclass());
}
}
/**
* Obtain an object that implements interface {@code Accessible}. If the object
* passed in already implements interface {@code Accessible}, {@code getAccessible}
* merely returns the object.
*
* @param o an Object; if a null is passed in a null is returned
* @return an {@code Object}, possibly the {@code Object} passed in, that
* implements the {@code Accessible} interface for the {@code Object}
* which was passed in
*/
public static Accessible getAccessible(Object o) {
Accessible a = null;
if (o == null) {
return null;
}
if (o instanceof Accessible) {
a = (Accessible)o;
} else {
Class translatorClass = getTranslatorClass(o.getClass());
if (translatorClass != null) {
try {
Translator t = (Translator)translatorClass.newInstance();
t.setSource(o);
a = t;
} catch (Exception e) {
}
}
}
if (a == null) {
a = new Translator(o);
}
return a;
}
/**
* Create a new {@code Translator}. You must call the {@link #setSource setSource}
* method to set the object to be translated after calling this constructor.
*/
public Translator() {
}
/**
* Create a new {@code Translator} with the source object o.
*
* @param o the Component that does not implement interface
* {@link javax.accessibility.Accessible Accessible}
*/
public Translator(Object o) {
source = o;
}
/**
* Get the source {@code Object} of the {@code Translator}.
*
* @return the source {@code Object} of the {@code Translator}
*/
public Object getSource() {
return source;
}
/**
* Set the source object of the {@code Translator}.
*
* @param o the Component that does not implement interface Accessible
*/
public void setSource(Object o) {
source = o;
}
/**
* Returns true if this object is the same as the one passed in.
*
* @param o the {@code Object} to check against
* @return true if this is the same object
*/
public boolean equals(Object o) {
return source.equals(o);
}
// Accessible methods
/**
* Returns this object.
*/
public AccessibleContext getAccessibleContext() {
return this;
}
// AccessibleContext methods
/**
* Get the accessible name of this object.
*
* @return the localized name of the object; can be null if this object
* does not have a name
*/
public String getAccessibleName() {
if (source instanceof MenuItem) {
return ((MenuItem) source).getLabel();
} else if (source instanceof Component) {
return ((Component) source).getName();
} else {
return null;
}
}
/**
* Set the name of this object.
*/
public void setAccessibleName(String s) {
if (source instanceof MenuItem) {
((MenuItem) source).setLabel(s);
} else if (source instanceof Component) {
((Component) source).setName(s);
}
}
/**
* Get the accessible description of this object.
*
* @return the description of the object; can be null if this object does
* not have a description
*/
public String getAccessibleDescription() {
return null;
}
/**
* Set the accessible description of this object.
*
* @param s the new localized description of the object
*/
public void setAccessibleDescription(String s) {
}
/**
* Get the role of this object.
*
* @return an instance of AccessibleRole describing the role of the object
*/
public AccessibleRole getAccessibleRole() {
return AccessibleRole.UNKNOWN;
}
/**
* Get the state of this object, given an already populated state.
* This method is intended for use by subclasses so they don't have
* to check for everything.
*
* @return an instance of {@code AccessibleStateSet}
* containing the current state of the object
*/
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = new AccessibleStateSet();
if (source instanceof Component) {
Component c = (Component) source;
for (Container p = c.getParent(); p != null; p = p.getParent()) {
if (p instanceof Window) {
if (((Window)p).getFocusOwner() == c) {
states.add(AccessibleState.FOCUSED);
}
}
}
}
if (isEnabled()) {
states.add(AccessibleState.ENABLED);
}
if (isFocusTraversable()) {
states.add(AccessibleState.FOCUSABLE);
}
if (source instanceof MenuItem) {
states.add(AccessibleState.FOCUSABLE);
}
return states;
}
/**
* Get the accessible parent of this object.
*
* @return the accessible parent of this object; can be null if this
* object does not have an accessible parent
*/
public Accessible getAccessibleParent() {
if (accessibleParent != null) {
return accessibleParent;
} else if (source instanceof Component) {
return getAccessible(((Component) source).getParent());
} else {
return null;
}
}
/**
* Get the index of this object in its accessible parent.
*
* @return -1 of this object does not have an accessible parent; otherwise,
* the index of the child in its accessible parent
*/
public int getAccessibleIndexInParent() {
if (source instanceof Component) {
Container parent = ((Component) source).getParent();
if (parent != null) {
Component ca[] = parent.getComponents();
for (int i = 0; i < ca.length; i++) {
if (source.equals(ca[i])) {
return i;
}
}
}
}
return -1;
}
/**
* Returns the number of accessible children in the object.
*
* @return the number of accessible children in the object
*/
public int getAccessibleChildrenCount() {
if (source instanceof Container) {
Component[] children = ((Container) source).getComponents();
int count = 0;
for (int i = 0; i < children.length; i++) {
Accessible a = getAccessible(children[i]);
if (a != null) {
count++;
}
}
return count;
} else {
return 0;
}
}
/**
* Return the nth accessible child of the object.
*
* @param i zero-based index of child
* @return the nth accessible child of the object
*/
public Accessible getAccessibleChild(int i) {
if (source instanceof Container) {
Component[] children = ((Container) source).getComponents();
int count = 0;
for (int j = 0; j < children.length; j++) {
Accessible a = getAccessible(children[j]);
if (a != null) {
if (count == i) {
AccessibleContext ac = a.getAccessibleContext();
if (ac != null) {
ac.setAccessibleParent(this);
}
return a;
} else {
count++;
}
}
}
}
return null;
}
/**
* Gets the {@code Locale} of the component. If the component does not have a
* locale, the locale of its parent is returned.
*
* @return the {@code Locale} of the object
*/
public Locale getLocale() throws IllegalComponentStateException {
if (source instanceof Component) {
return ((Component) source).getLocale();
} else {
return null;
}
}
/**
* Add a {@code PropertyChangeListener} to the listener list. The listener
* is registered for all properties.
*/
public void addPropertyChangeListener(PropertyChangeListener l) {
}
/**
* Remove the {@code PropertyChangeListener} from the listener list.
*/
public void removePropertyChangeListener(PropertyChangeListener l) {
}
// AccessibleComponent methods
/**
* Get the background {@code Color} of this object.
*
* @return if supported, the background {@code Color} of the object;
* otherwise, null
*
*/
public Color getBackground() {
if (source instanceof Component) { // MenuComponent doesn't do background
return ((Component) source).getBackground();
} else {
return null;
}
}
/**
* Set the background {@code Color} of this object.
*
* @param c the new {@code Color} for the background
*/
public void setBackground(Color c) {
if (source instanceof Component) { // MenuComponent doesn't do background
((Component) source).setBackground(c);
}
}
/**
* Get the foreground {@code Color} of this object.
*
* @return if supported, the foreground {@code Color} of the object; otherwise, null
*/
public Color getForeground() {
if (source instanceof Component) { // MenuComponent doesn't do foreground
return ((Component) source).getForeground();
} else {
return null;
}
}
/**
* Set the foreground {@code Color} of this object.
*
* @param c the new {@code Color} for the foreground
*/
public void setForeground(Color c) {
if (source instanceof Component) { // MenuComponent doesn't do foreground
((Component) source).setForeground(c);
}
}
/**
* Get the {@code Cursor} of this object.
*
* @return if supported, the Cursor of the object; otherwise, null
*/
public Cursor getCursor() {
if (source instanceof Component) { // MenuComponent doesn't do cursor
return ((Component) source).getCursor();
} else {
return null;
}
}
/**
* Set the {@code Cursor} of this object.
* @param c the new {@code Cursor} for the object
*/
public void setCursor(Cursor c) {
if (source instanceof Component) { // MenuComponent doesn't do cursor
((Component) source).setCursor(c);
}
}
/**
* Get the {@code Font} of this object.
*
* @return if supported, the {@code Font} for the object; otherwise, null
*/
public Font getFont() {
if (source instanceof Component) {
return ((Component) source).getFont();
} else if (source instanceof MenuComponent) {
return ((MenuComponent) source).getFont();
} else {
return null;
}
}
/**
* Set the {@code Font} of this object.
*
* @param f the new {@code Font} for the object
*/
public void setFont(Font f) {
if (source instanceof Component) {
((Component) source).setFont(f);
} else if (source instanceof MenuComponent) {
((MenuComponent) source).setFont(f);
}
}
/**
* Get the {@code FontMetrics} of this object.
*
* @param f the {@code Font}
* @return if supported, the {@code FontMetrics} the object; otherwise, null
* @see #getFont
*/
public FontMetrics getFontMetrics(Font f) {
if (source instanceof Component) {
return ((Component) source).getFontMetrics(f);
} else {
return null;
}
}
/**
* Determine if the object is enabled.
*
* @return true if object is enabled; otherwise, false
*/
public boolean isEnabled() {
if (source instanceof Component) {
return ((Component) source).isEnabled();
} else if (source instanceof MenuItem) {
return ((MenuItem) source).isEnabled();
} else {
return true;
}
}
/**
* Set the enabled state of the object.
*
* @param b if true, enables this object; otherwise, disables it
*/
public void setEnabled(boolean b) {
if (source instanceof Component) {
((Component) source).setEnabled(b);
} else if (source instanceof MenuItem) {
((MenuItem) source).setEnabled(b);
}
}
/**
* Determine if the object is visible.
*
* @return true if object is visible; otherwise, false
*/
public boolean isVisible() {
if (source instanceof Component) {
return ((Component) source).isVisible();
} else {
return false;
}
}
/**
* Set the visible state of the object.
*
* @param b if true, shows this object; otherwise, hides it
*/
public void setVisible(boolean b) {
if (source instanceof Component) {
((Component) source).setVisible(b);
}
}
/**
* Determine if the object is showing. This is determined by checking
* the visibility of the object and ancestors of the object.
*
* @return true if object is showing; otherwise, false
*/
public boolean isShowing() {
if (source instanceof Component) {
return ((Component) source).isShowing();
} else {
return false;
}
}
/**
* Checks whether the specified {@code Point} is within this
* object's bounds, where the {@code Point} is relative to the coordinate
* system of the object.
*
* @param p the {@code Point} relative to the coordinate system of the object
* @return true if object contains {@code Point}; otherwise false
*/
public boolean contains(Point p) {
if (source instanceof Component) {
return ((Component) source).contains(p);
} else {
return false;
}
}
/**
* Returns the location of the object on the screen.
*
* @return location of object on screen; can be null if this object
* is not on the screen
*/
public Point getLocationOnScreen() {
if (source instanceof Component) {
return ((Component) source).getLocationOnScreen();
} else {
return null;
}
}
/**
* Returns the location of the object relative to parent.
*
* @return location of object relative to parent; can be null if
* this object or its parent are not on the screen
*/
public Point getLocation() {
if (source instanceof Component) {
return ((Component) source).getLocation();
} else {
return null;
}
}
/**
* Sets the location of the object relative to parent.
*/
public void setLocation(Point p) {
if (source instanceof Component) {
((Component) source).setLocation(p);
}
}
/**
* Returns the current bounds of this object.
*
* @return current bounds of object; can be null if this object
* is not on the screen
*/
public Rectangle getBounds() {
if (source instanceof Component) {
return ((Component) source).getBounds();
} else {
return null;
}
}
/**
* Sets the current bounds of this object.
*/
public void setBounds(Rectangle r) {
if (source instanceof Component) {
((Component) source).setBounds(r);
}
}
/**
* Returns the current size of this object.
*
* @return current size of object; can be null if this object is
* not on the screen
*/
public Dimension getSize() {
if (source instanceof Component) {
return ((Component) source).getSize();
} else {
return null;
}
}
/**
* Sets the current size of this object.
*/
public void setSize(Dimension d) {
if (source instanceof Component) {
((Component) source).setSize(d);
}
}
/**
* Returns the accessible child contained at the local coordinate
* Point, if one exists.
*
* @return the Accessible at the specified location, if it exists
*/
public Accessible getAccessibleAt(Point p) {
if (source instanceof Component) {
Component c = ((Component) source).getComponentAt(p);
if (c != null) {
return (getAccessible(c));
}
}
return null;
}
/**
* Returns whether this object can accept focus or not.
*
* @return true if object can accept focus; otherwise false
*/
public boolean isFocusTraversable() {
if (source instanceof Component) {
return ((Component) source).isFocusTraversable();
} else {
return false;
}
}
/**
* Requests focus for this object.
*/
public void requestFocus() {
if (source instanceof Component) {
((Component) source).requestFocus();
}
}
/**
* Adds the specified {@code FocusListener} to receive focus events from
* this component.
*
* @param l the focus listener
*/
public synchronized void addFocusListener(FocusListener l) {
if (source instanceof Component) {
((Component) source).addFocusListener(l);
}
}
/**
* Removes the specified focus listener so it no longer receives focus
* events from this component.
*
* @param l the focus listener; this method performs no function, nor does it
* throw an exception if the listener specified was not previously added
* to this component; if listener is null, no exception is thrown and no
* action is performed.
*/
public synchronized void removeFocusListener(FocusListener l) {
if (source instanceof Component) {
((Component) source).removeFocusListener(l);
}
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2002, 2012, 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.
*/
package com.sun.java.accessibility.util.java.awt;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.accessibility.*;
import com.sun.java.accessibility.util.*;
/**
* <p>The Translator class provides a translation to interface Accessible
* for objects that do not implement interface Accessible. Assistive
* technologies can use the 'getAccessible' class method of Translator to
* obtain an object that implements interface Accessible. If the object
* passed in already implements interface Accessible, getAccessible merely
* returns the object.
*
* <p>An example of how an assistive technology might use the Translator
* class is as follows:
*
* <PRE>
* Accessible accessible = Translator.getAccessible(someObj);
* // obtain information from the 'accessible' object.
* </PRE>
*
* <P>This class extends the Translator class to provide specific support
* for the Button class. Translator.getAccessible() will automatically
* load this class when an assistive technology asks for an accessible
* translator for Button.
*
*/
public class ButtonTranslator extends Translator {
/**
* Get the name of this object.
* @return the name of the object -- can be null if this object does
* not have a name
*/
public String getAccessibleName() {
return ((Button) source).getLabel();
}
/**
* Set the name of this object.
*/
public void setAccessibleName(String s) {
((Button) source).setLabel(s);
}
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PUSH_BUTTON;
}
}

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) 2002, 2012, 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.
*/
package com.sun.java.accessibility.util.java.awt;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.accessibility.*;
import com.sun.java.accessibility.util.*;
/**
* <p>The Translator class provides a translation to interface Accessible
* for objects that do not implement interface Accessible. Assistive
* technologies can use the 'getAccessible' class method of Translator to
* obtain an object that implements interface Accessible. If the object
* passed in already implements interface Accessible, getAccessible merely
* returns the object.
*
* <p>An example of how an assistive technology might use the Translator
* class is as follows:
*
* <PRE>
* Accessible accessible = Translator.getAccessible(someObj);
* // obtain information from the 'accessible' object.
* </PRE>
*
* <P>This class extends the Translator class to provide specific support
* for the Checkbox class. Translator.getAccessible() will automatically
* load this class when an assistive technology asks for an accessible
* translator for Checkbox.
*
*/
public class CheckboxTranslator extends Translator {
/**
* Get the state of this object.
* @return an instance of AccessibleState containing the current state of the object
* @see AccessibleState
*/
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
if (((Checkbox) source).getState()) {
states.add(AccessibleState.CHECKED);
}
return states;
}
/**
* Get the name of this object.
* @return the name of the object -- can be null if this object does
* not have a name
*/
public String getAccessibleName() {
return ((Checkbox) source).getLabel();
}
/**
* Set the name of this object.
*/
public void setAccessibleName(String s) {
((Checkbox) source).setLabel(s);
}
public AccessibleRole getAccessibleRole() {
return AccessibleRole.CHECK_BOX;
}
}

View File

@@ -0,0 +1,73 @@
/*
* Copyright (c) 2002, 2012, 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.
*/
package com.sun.java.accessibility.util.java.awt;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.accessibility.*;
import com.sun.java.accessibility.util.*;
/**
* <p>The Translator class provides a translation to interface Accessible
* for objects that do not implement interface Accessible. Assistive
* technologies can use the 'getAccessible' class method of Translator to
* obtain an object that implements interface Accessible. If the object
* passed in already implements interface Accessible, getAccessible merely
* returns the object.
*
* <p>An example of how an assistive technology might use the Translator
* class is as follows:
*
* <PRE>
* Accessible accessible = Translator.getAccessible(someObj);
* // obtain information from the 'accessible' object.
* </PRE>
*
* <P>This class extends the Translator class to provide specific support
* for the Label class. Translator.getAccessible() will automatically
* load this class when an assistive technology asks for an accessible
* translator for Label.
*
*/
public class LabelTranslator extends Translator {
public String getAccessibleName() {
return ((Label) source).getText();
}
/**
* Set the name of this object.
*/
public void setAccessibleName(String s) {
((Label) source).setText(s);
}
public AccessibleRole getAccessibleRole() {
return AccessibleRole.LABEL;
}
}

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 2002, 2012, 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.
*/
package com.sun.java.accessibility.util.java.awt;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.accessibility.*;
import com.sun.java.accessibility.util.*;
/**
* <p>The Translator class provides a translation to interface Accessible
* for objects that do not implement interface Accessible. Assistive
* technologies can use the 'getAccessible' class method of Translator to
* obtain an object that implements interface Accessible. If the object
* passed in already implements interface Accessible, getAccessible merely
* returns the object.
*
* <p>An example of how an assistive technology might use the Translator
* class is as follows:
*
* <PRE>
* Accessible accessible = Translator.getAccessible(someObj);
* // obtain information from the 'accessible' object.
* </PRE>
*
* <P>This class extends the Translator class to provide specific support
* for the List class. Translator.getAccessible() will automatically
* load this class when an assistive technology asks for an accessible
* translator for List.
*
*/
public class ListTranslator extends Translator {
/**
* Get the state of this object.
* @return an instance of AccessibleState containing the current state of the object
* @see AccessibleState
*/
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = super.getAccessibleStateSet();
if (((java.awt.List) source).isMultipleMode()) {
states.add(AccessibleState.MULTISELECTABLE);
}
if (((java.awt.List) source).getSelectedItems().length > 0) {
states.add(AccessibleState.SELECTED);
}
return states;
}
public AccessibleRole getAccessibleRole() {
return AccessibleRole.LIST;
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 2002, 2012, 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.
*/
package com.sun.java.accessibility.util.java.awt;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import javax.accessibility.*;
import com.sun.java.accessibility.util.*;
/**
* <p>The Translator class provides a translation to interface Accessible
* for objects that do not implement interface Accessible. Assistive
* technologies can use the 'getAccessible' class method of Translator to
* obtain an object that implements interface Accessible. If the object
* passed in already implements interface Accessible, getAccessible merely
* returns the object.
*
* <p>An example of how an assistive technology might use the Translator
* class is as follows:
*
* <PRE>
* Accessible accessible = Translator.getAccessible(someObj);
* // obtain information from the 'accessible' object.
* </PRE>
*
* <P>This class extends the Translator class to provide specific support
* for the TextComponent class. Translator.getAccessible() will automatically
* load this class when an assistive technology asks for an accessible
* translator for TextComponent.
*
*/
public class TextComponentTranslator extends Translator {
public AccessibleRole getAccessibleRole() {
return AccessibleRole.TEXT;
}
}

View File

@@ -0,0 +1,69 @@
/*
* Copyright (c) 2013, 2015, 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.
*/
/**
* Provides a collection of interfaces and classes that compose the Java Accessibility
* Utilities. The classes are used by Assistive Technologies, such as the screen
* readers which are used by those who are blind, and help provide access to GUI
* toolkits that implement the Java Accessibility API. An overview of the important
* classes follows.
*
* <p>The class {@code AccessibilityEventMonitor} implements a PropertyChange
* listener on every UI object that implements interface {@code Accessible} in the Java
* Virtual Machine.
*
* <p> The class {@code AWTEventMonitor} implements a suite of listeners that are
* conditionally installed on every AWT component instance in the Java Virtual Machine.
*
* <p>The class {@code EventQueueMonitor} provides key core functionality for
* Assistive Technologies (and other system-level technologies that need some of
* the same things that Assistive Technology needs).
*
* <p>The class {@code GUIInitializedMulticaster} is used to maintain a list of
* {@code GUIInitializedListener} classes which are used by the {@code EventQueueMonitor}
* class to notify an interested party when the GUI subsystem has been initialized.
* Note that this class is intended to be used primarily for internal support in
* the {@code EventQueueMonitor} class, and is not intended to be used by classes
* outside the Java Accessibility Utility package.
*
* <p>The class {@code SwingEventMonitor} extends {@code AWTEventMonitor} by adding
* a suite of listeners conditionally installed on every Swing component instance
* in the Java Virtual Machine.
*
* <p>The class {@code TopLevelWindowMulticaster} is used to maintain a list of
* {@code TopLevelWindowListener} classes which are used by the {@code EventQueueMonitor}
* class to notify an interested party when a top level window is created or destroyed
* in the Java Virtual Machine Note that this class is intended to be used primarily
* for internal support in the {@code EventQueueMonitor} class, and is not intended
* to be used by classes outside the Java Accessibility Utility package.
*
* <p>The class {@code Translator} provides a translation to interface {@code Accessible}
* for objects that do not implement interface {@code Accessible}.
*
* @since JDK1.7
*/
@jdk.Exported
package com.sun.java.accessibility.util;