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.
- *
- *
An example of how an assistive technology might use the Translator
- * class is as follows:
- *
- *
- * Accessible accessible = Translator.getAccessible(someObj);
- * // obtain information from the 'accessible' object.
- *
- *
- *
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;
- }
-}
--- /dev/null 2015-07-13 16:49:44.000000000 -0500
+++ new/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/internal/ButtonTranslator.java 2015-07-13 16:49:43.368440900 -0500
@@ -0,0 +1,78 @@
+/*
+ * 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.internal;
+
+import java.lang.*;
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+import javax.accessibility.*;
+import com.sun.java.accessibility.util.*;
+
+/**
+ *
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.
+ *
+ *
An example of how an assistive technology might use the Translator
+ * class is as follows:
+ *
+ *
+ * Accessible accessible = Translator.getAccessible(someObj);
+ * // obtain information from the 'accessible' object.
+ *
+ *
+ *
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;
+ }
+}
--- old/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/java/awt/CheckboxTranslator.java 2015-07-13 16:49:48.703746000 -0500
+++ /dev/null 2015-07-13 16:49:48.000000000 -0500
@@ -1,91 +0,0 @@
-/*
- * 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.java.awt;
-
-import java.lang.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.image.*;
-import javax.accessibility.*;
-import com.sun.java.accessibility.util.*;
-
-/**
- *
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.
- *
- *
An example of how an assistive technology might use the Translator
- * class is as follows:
- *
- *
- * Accessible accessible = Translator.getAccessible(someObj);
- * // obtain information from the 'accessible' object.
- *
- *
- *
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;
- }
-}
--- /dev/null 2015-07-13 16:49:49.000000000 -0500
+++ new/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/internal/CheckboxTranslator.java 2015-07-13 16:49:47.556680400 -0500
@@ -0,0 +1,91 @@
+/*
+ * 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.internal;
+
+import java.lang.*;
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+import javax.accessibility.*;
+import com.sun.java.accessibility.util.*;
+
+/**
+ *
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.
+ *
+ *
An example of how an assistive technology might use the Translator
+ * class is as follows:
+ *
+ *
+ * Accessible accessible = Translator.getAccessible(someObj);
+ * // obtain information from the 'accessible' object.
+ *
+ *
+ *
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;
+ }
+}
--- old/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/java/awt/LabelTranslator.java 2015-07-13 16:49:52.964989800 -0500
+++ /dev/null 2015-07-13 16:49:53.000000000 -0500
@@ -1,73 +0,0 @@
-/*
- * 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.java.awt;
-
-import java.lang.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.image.*;
-import javax.accessibility.*;
-import com.sun.java.accessibility.util.*;
-
-/**
- *
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.
- *
- *
An example of how an assistive technology might use the Translator
- * class is as follows:
- *
- *
- * Accessible accessible = Translator.getAccessible(someObj);
- * // obtain information from the 'accessible' object.
- *
- *
- *
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;
- }
-}
--- /dev/null 2015-07-13 16:49:53.000000000 -0500
+++ new/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/internal/LabelTranslator.java 2015-07-13 16:49:51.782922100 -0500
@@ -0,0 +1,73 @@
+/*
+ * 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.internal;
+
+import java.lang.*;
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+import javax.accessibility.*;
+import com.sun.java.accessibility.util.*;
+
+/**
+ *
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.
+ *
+ *
An example of how an assistive technology might use the Translator
+ * class is as follows:
+ *
+ *
+ * Accessible accessible = Translator.getAccessible(someObj);
+ * // obtain information from the 'accessible' object.
+ *
+ *
+ *
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;
+ }
+}
--- old/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/java/awt/ListTranslator.java 2015-07-13 16:49:57.165230000 -0500
+++ /dev/null 2015-07-13 16:49:57.000000000 -0500
@@ -1,78 +0,0 @@
-/*
- * 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.java.awt;
-
-import java.lang.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.image.*;
-import javax.accessibility.*;
-import com.sun.java.accessibility.util.*;
-
-/**
- *
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.
- *
- *
An example of how an assistive technology might use the Translator
- * class is as follows:
- *
- *
- * Accessible accessible = Translator.getAccessible(someObj);
- * // obtain information from the 'accessible' object.
- *
- *
- *
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;
- }
-}
--- /dev/null 2015-07-13 16:49:57.000000000 -0500
+++ new/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/internal/ListTranslator.java 2015-07-13 16:49:55.984162400 -0500
@@ -0,0 +1,78 @@
+/*
+ * 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.internal;
+
+import java.lang.*;
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+import javax.accessibility.*;
+import com.sun.java.accessibility.util.*;
+
+/**
+ *
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.
+ *
+ *
An example of how an assistive technology might use the Translator
+ * class is as follows:
+ *
+ *
+ * Accessible accessible = Translator.getAccessible(someObj);
+ * // obtain information from the 'accessible' object.
+ *
+ *
+ *
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;
+ }
+}
--- old/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/java/awt/TextComponentTranslator.java 2015-07-13 16:50:01.297466300 -0500
+++ /dev/null 2015-07-13 16:50:01.000000000 -0500
@@ -1,62 +0,0 @@
-/*
- * 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.java.awt;
-
-import java.lang.*;
-import java.util.*;
-import java.awt.*;
-import java.awt.image.*;
-import javax.accessibility.*;
-import com.sun.java.accessibility.util.*;
-
-/**
- *
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.
- *
- *
An example of how an assistive technology might use the Translator
- * class is as follows:
- *
- *
- * Accessible accessible = Translator.getAccessible(someObj);
- * // obtain information from the 'accessible' object.
- *
- *
- *
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;
- }
-}
--- /dev/null 2015-07-13 16:50:01.000000000 -0500
+++ new/src/jdk.accessibility/share/classes/com/sun/java/accessibility/util/internal/TextComponentTranslator.java 2015-07-13 16:50:00.142400300 -0500
@@ -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.internal;
+
+import java.lang.*;
+import java.util.*;
+import java.awt.*;
+import java.awt.image.*;
+import javax.accessibility.*;
+import com.sun.java.accessibility.util.*;
+
+/**
+ *
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.
+ *
+ *
An example of how an assistive technology might use the Translator
+ * class is as follows:
+ *
+ *
+ * Accessible accessible = Translator.getAccessible(someObj);
+ * // obtain information from the 'accessible' object.
+ *
+ *
+ *
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;
+ }
+}
--- old/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/AccessBridge.java 2015-07-13 16:50:05.487706000 -0500
+++ /dev/null 2015-07-13 16:50:05.000000000 -0500
@@ -1,7170 +0,0 @@
-/*
- * 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;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-import java.lang.*;
-import java.lang.reflect.*;
-
-import java.beans.*;
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-import javax.swing.tree.*;
-import javax.swing.table.*;
-import javax.swing.plaf.TreeUI;
-
-import javax.accessibility.*;
-import com.sun.java.accessibility.util.*;
-import sun.awt.AWTAccessor;
-import sun.awt.AppContext;
-import sun.awt.SunToolkit;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CountDownLatch;
-
-/*
- * Note: This class has to be public. It's loaded from the VM like this:
- * Class.forName(atName).newInstance();
- */
-@jdk.Exported(false)
-final public class AccessBridge {
-
- private static AccessBridge theAccessBridge;
- private ObjectReferences references;
- private EventHandler eventHandler;
-
- // Maps AccessibleRoles strings to AccessibleRoles.
- private ConcurrentHashMap accessibleRoleMap = new ConcurrentHashMap<>();
-
- /**
- If the object's role is in the following array getVirtualAccessibleName
- will use the extended search algorithm.
- */
- private ArrayList extendedVirtualNameSearchRoles = new ArrayList<>();
- /**
- If the role of the object's parent is in the following array
- getVirtualAccessibleName will NOT use the extended search
- algorithm even if the object's role is in the
- extendedVirtualNameSearchRoles array.
- */
- private ArrayList noExtendedVirtualNameSearchParentRoles = new ArrayList<>();
-
- private static native boolean isSysWow();
-
-
- /**
- * Load DLLs
- */
- static {
- // Load the appropriate DLLs
- boolean is32on64 = false;
- if (System.getProperty("os.arch").equals("x86")) {
- // 32 bit JRE
- // Load jabsysinfo.dll so can determine Win bitness
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Void run() {
- System.loadLibrary("jabsysinfo");
- return null;
- }
- }, null, new java.lang.RuntimePermission("loadLibrary.jabsysinfo")
- );
- if (isSysWow()) {
- // 32 bit JRE on 64 bit OS
- is32on64 = true;
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Void run() {
- System.loadLibrary("javaaccessbridge-32");
- return null;
- }
- }, null, new java.lang.RuntimePermission("loadLibrary.javaaccessbridge-32")
- );
- }
- }
- if (!is32on64) {
- // 32 bit JRE on 32 bit OS or 64 bit JRE on 64 bit OS
- java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction() {
- public Void run() {
- System.loadLibrary("javaaccessbridge");
- return null;
- }
- }, null, new java.lang.RuntimePermission("loadLibrary.javaaccessbridge")
- );
- }
- }
-
- /**
- * AccessBridge constructor
- *
- * Note: This constructor has to be public. It's called from the VM like this:
- * Class.forName(atName).newInstance();
- */
- public AccessBridge() {
- theAccessBridge = this;
- references = new ObjectReferences();
-
- // initialize shutdown hook
- Runtime runTime = Runtime.getRuntime();
- shutdownHook hook = new shutdownHook();
- runTime.addShutdownHook(new Thread(hook));
-
- // initialize AccessibleRole map
- initAccessibleRoleMap();
-
- // determine which version of the JDK is running
- String version = getJavaVersionProperty();
- debugString("JDK version = "+version);
-
- // initialize the methods that map HWNDs and Java top-level
- // windows
- initHWNDcalls();
-
- // is this a JVM we can use?
- // install JDK 1.2 and later Swing ToolKit listener
- EventQueueMonitor.isGUIInitialized();
-
- // start the Java event handler
- eventHandler = new EventHandler(this);
-
- // register for menu selection events
- MenuSelectionManager.defaultManager().addChangeListener(eventHandler);
-
- // register as a NativeWindowHandler
- addNativeWindowHandler(new DefaultNativeWindowHandler());
-
- // start in a new thread
- Thread abthread = new Thread(new dllRunner());
- abthread.setDaemon(true);
- abthread.start();
- debugString("AccessBridge started");
- }
-
- /*
- * adaptor to run the AccessBridge DLL
- */
- private class dllRunner implements Runnable {
- public void run() {
- runDLL();
- }
- }
-
- /*
- * shutdown hook
- */
- private class shutdownHook implements Runnable {
-
- public void run() {
- debugString("***** shutdownHook: shutting down...");
- javaShutdown();
- }
- }
-
-
- /*
- * Initialize the hashtable that maps Strings to AccessibleRoles.
- */
- private void initAccessibleRoleMap() {
- /*
- * Initialize the AccessibleRoles map. This code uses methods in
- * java.lang.reflect.* to build the map.
- */
- try {
- Class> clAccessibleRole = Class.forName ("javax.accessibility.AccessibleRole");
- if (null != clAccessibleRole) {
- AccessibleRole roleUnknown = AccessibleRole.UNKNOWN;
- Field [] fields = clAccessibleRole.getFields ();
- int i = 0;
- for (i = 0; i < fields.length; i ++) {
- Field f = fields [i];
- if (javax.accessibility.AccessibleRole.class == f.getType ()) {
- AccessibleRole nextRole = (AccessibleRole) (f.get (roleUnknown));
- String nextRoleString = nextRole.toDisplayString (Locale.US);
- accessibleRoleMap.put (nextRoleString, nextRole);
- }
- }
- }
- } catch (Exception e) {}
-
- /*
- Build the extendedVirtualNameSearchRoles array list. I chose this method
- because some of the Accessible Roles that need to be added to it are not
- available in all versions of the J2SE that we want to support.
- */
- extendedVirtualNameSearchRoles.add (AccessibleRole.COMBO_BOX);
- try {
- /*
- Added in J2SE 1.4
- */
- extendedVirtualNameSearchRoles.add (AccessibleRole.DATE_EDITOR);
- } catch (NoSuchFieldError e) {}
- extendedVirtualNameSearchRoles.add (AccessibleRole.LIST);
- extendedVirtualNameSearchRoles.add (AccessibleRole.PASSWORD_TEXT);
- extendedVirtualNameSearchRoles.add (AccessibleRole.SLIDER);
- try {
- /*
- Added in J2SE 1.3
- */
- extendedVirtualNameSearchRoles.add (AccessibleRole.SPIN_BOX);
- } catch (NoSuchFieldError e) {}
- extendedVirtualNameSearchRoles.add (AccessibleRole.TABLE);
- extendedVirtualNameSearchRoles.add (AccessibleRole.TEXT);
- extendedVirtualNameSearchRoles.add (AccessibleRole.UNKNOWN);
-
- noExtendedVirtualNameSearchParentRoles.add (AccessibleRole.TABLE);
- noExtendedVirtualNameSearchParentRoles.add (AccessibleRole.TOOL_BAR);
- }
-
- /**
- * start the AccessBridge DLL running in its own thread
- */
- private native void runDLL();
-
- /**
- * debugging output (goes to OutputDebugStr())
- */
- private native void sendDebugString(String debugStr);
-
- /**
- * debugging output (goes to OutputDebugStr())
- */
- private void debugString(String debugStr) {
- sendDebugString(debugStr);
- }
-
- /* ===== utility methods ===== */
-
- /**
- * decrement the reference to the object (called by native code)
- */
- private void decrementReference(Object o) {
- references.decrement(o);
- }
-
- /**
- * get the java.version property from the JVM
- */
- private String getJavaVersionProperty() {
- String s = System.getProperty("java.version");
- if (s != null) {
- references.increment(s);
- return s;
- }
- return null;
- }
-
- /* ===== HWND/Java window mapping methods ===== */
-
- // Java toolkit methods for mapping HWNDs to Java components
- private Method javaGetComponentFromNativeWindowHandleMethod;
- private Method javaGetNativeWindowHandleFromComponentMethod;
-
- // native jawt methods for mapping HWNDs to Java components
- private native int jawtGetNativeWindowHandleFromComponent(Component comp);
-
- private native Component jawtGetComponentFromNativeWindowHandle(int handle);
-
- Toolkit toolkit;
-
- /**
- * map an HWND to an AWT Component
- */
- private void initHWNDcalls() {
- Class> integerParemter[] = new Class>[1];
- integerParemter[0] = Integer.TYPE;
- Class> componentParemter[] = new Class>[1];
- try {
- componentParemter[0] = Class.forName("java.awt.Component");
- } catch (ClassNotFoundException e) {
- debugString("Exception: " + e.toString());
- }
- toolkit = Toolkit.getDefaultToolkit();
- return;
- }
-
- // native window handler interface
- private interface NativeWindowHandler {
- public Accessible getAccessibleFromNativeWindowHandle(int nativeHandle);
- }
-
- // hash table of native window handle to AccessibleContext mappings
- static private ConcurrentHashMap windowHandleToContextMap = new ConcurrentHashMap<>();
-
- // hash table of AccessibleContext to native window handle mappings
- static private ConcurrentHashMap contextToWindowHandleMap = new ConcurrentHashMap<>();
-
- /*
- * adds a virtual window handler to our hash tables
- */
- static private void registerVirtualFrame(final Accessible a,
- Integer nativeWindowHandle ) {
- if (a != null) {
- AccessibleContext ac = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return a.getAccessibleContext();
- }
- }, a);
- windowHandleToContextMap.put(nativeWindowHandle, ac);
- contextToWindowHandleMap.put(ac, nativeWindowHandle);
- }
- }
-
- /*
- * removes a virtual window handler to our hash tables
- */
- static private void revokeVirtualFrame(final Accessible a,
- Integer nativeWindowHandle ) {
- AccessibleContext ac = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return a.getAccessibleContext();
- }
- }, a);
- windowHandleToContextMap.remove(nativeWindowHandle);
- contextToWindowHandleMap.remove(ac);
- }
-
- // vector of native window handlers
- private static Vector nativeWindowHandlers = new Vector<>();
-
- /*
- * adds a native window handler to our list
- */
- private static void addNativeWindowHandler(NativeWindowHandler handler) {
- if (handler == null) {
- throw new IllegalArgumentException();
- }
- nativeWindowHandlers.addElement(handler);
- }
-
- /*
- * removes a native window handler to our list
- */
- private static boolean removeNativeWindowHandler(NativeWindowHandler handler) {
- if (handler == null) {
- throw new IllegalArgumentException();
- }
- return nativeWindowHandlers.removeElement(handler);
- }
-
- /**
- * verifies that a native window handle is a Java window
- */
- private boolean isJavaWindow(int nativeHandle) {
- AccessibleContext ac = getContextFromNativeWindowHandle(nativeHandle);
- if (ac != null) {
- saveContextToWindowHandleMapping(ac, nativeHandle);
- return true;
- }
- return false;
- }
-
- /*
- * saves the mapping between an AccessibleContext and a window handle
- */
- private void saveContextToWindowHandleMapping(AccessibleContext ac,
- int nativeHandle) {
- debugString("saveContextToWindowHandleMapping...");
- if (ac == null) {
- return;
- }
- if (! contextToWindowHandleMap.containsKey(ac)) {
- debugString("saveContextToWindowHandleMapping: ac = "+ac+"; handle = "+nativeHandle);
- contextToWindowHandleMap.put(ac, nativeHandle);
- }
- }
-
- /**
- * maps a native window handle to an Accessible Context
- */
- private AccessibleContext getContextFromNativeWindowHandle(int nativeHandle) {
- // First, look for the Accessible in our hash table of
- // virtual window handles.
- AccessibleContext ac = windowHandleToContextMap.get(nativeHandle);
- if(ac!=null) {
- saveContextToWindowHandleMapping(ac, nativeHandle);
- return ac;
- }
-
- // Next, look for the native window handle in our vector
- // of native window handles.
- int numHandlers = nativeWindowHandlers.size();
- for (int i = 0; i < numHandlers; i++) {
- NativeWindowHandler nextHandler = nativeWindowHandlers.elementAt(i);
- final Accessible a = nextHandler.getAccessibleFromNativeWindowHandle(nativeHandle);
- if (a != null) {
- ac = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return a.getAccessibleContext();
- }
- }, a);
- saveContextToWindowHandleMapping(ac, nativeHandle);
- return ac;
- }
- }
- // Not found.
- return null;
- }
-
- /**
- * maps an AccessibleContext to a native window handle
- * returns 0 on error
- */
- private int getNativeWindowHandleFromContext(AccessibleContext ac) {
- debugString("getNativeWindowHandleFromContext: ac = "+ac);
- try {
- return contextToWindowHandleMap.get(ac);
- } catch (Exception ex) {
- return 0;
- }
- }
-
- private class DefaultNativeWindowHandler implements NativeWindowHandler {
- /*
- * returns the Accessible associated with a native window
- */
- public Accessible getAccessibleFromNativeWindowHandle(int nativeHandle) {
- final Component c = jawtGetComponentFromNativeWindowHandle(nativeHandle);
- if (c instanceof Accessible) {
- AccessibleContext ac = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return c.getAccessibleContext();
- }
- }, c);
- saveContextToWindowHandleMapping(ac, nativeHandle);
- return (Accessible)c;
- } else {
- return null;
- }
- }
- }
-
- /* ===== AccessibleContext methods =====*/
-
- /*
- * returns the inner-most AccessibleContext in parent at Point(x, y)
- */
- private AccessibleContext getAccessibleContextAt(int x, int y,
- AccessibleContext parent) {
- if (parent == null) {
- return null;
- }
- if (windowHandleToContextMap != null &&
- windowHandleToContextMap.containsValue(getRootAccessibleContext(parent))) {
- // Path for applications that register their top-level
- // windows with the AccessBridge (e.g., StarOffice 6.1)
- return getAccessibleContextAt_1(x, y, parent);
- } else {
- // Path for applications that do not register
- // their top-level windows with the AccessBridge
- // (e.g., Swing/AWT applications)
- return getAccessibleContextAt_2(x, y, parent);
- }
- }
-
- /*
- * returns the root accessible context
- */
- private AccessibleContext getRootAccessibleContext(final AccessibleContext ac) {
- if (ac == null) {
- return null;
- }
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- Accessible parent = ac.getAccessibleParent();
- if (parent == null) {
- return ac;
- }
- Accessible tmp = parent.getAccessibleContext().getAccessibleParent();
- while (tmp != null) {
- parent = tmp;
- tmp = parent.getAccessibleContext().getAccessibleParent();
- }
- return parent.getAccessibleContext();
- }
- }, ac);
- }
-
- /*
- * StarOffice version that does not use the EventQueueMonitor
- */
- private AccessibleContext getAccessibleContextAt_1(final int x, final int y,
- final AccessibleContext parent) {
- debugString(" : getAccessibleContextAt_1 called");
- debugString(" -> x = " + x + " y = " + y + " parent = " + parent);
-
- if (parent == null) return null;
- final AccessibleComponent acmp = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleComponent call() throws Exception {
- return parent.getAccessibleComponent();
- }
- }, parent);
- if (acmp!=null) {
- final Point loc = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Point call() throws Exception {
- return acmp.getLocation();
- }
- }, parent);
- final Accessible a = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Accessible call() throws Exception {
- return acmp.getAccessibleAt(new Point(x - loc.x, y - loc.y));
- }
- }, parent);
- if (a != null) {
- AccessibleContext foundAC = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return a.getAccessibleContext();
- }
- }, parent);
- if (foundAC != null) {
- if (foundAC != parent) {
- // recurse down into the child
- return getAccessibleContextAt_1(x - loc.x, y - loc.y,
- foundAC);
- } else
- return foundAC;
- }
- }
- }
- return parent;
- }
-
- /*
- * AWT/Swing version
- */
- private AccessibleContext getAccessibleContextAt_2(final int x, final int y,
- AccessibleContext parent) {
- debugString("getAccessibleContextAt_2 called");
- debugString(" -> x = " + x + " y = " + y + " parent = " + parent);
-
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- Accessible a = EventQueueMonitor.getAccessibleAt(new Point(x, y));
- if (a != null) {
- AccessibleContext childAC = a.getAccessibleContext();
- if (childAC != null) {
- debugString(" returning childAC = " + childAC);
- return childAC;
- }
- }
- return null;
- }
- }, parent);
- }
-
- /**
- * returns the Accessible that has focus
- */
- private AccessibleContext getAccessibleContextWithFocus() {
- Component c = AWTEventMonitor.getComponentWithFocus();
- if (c != null) {
- final Accessible a = Translator.getAccessible(c);
- if (a != null) {
- AccessibleContext ac = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return a.getAccessibleContext();
- }
- }, c);
- if (ac != null) {
- return ac;
- }
- }
- }
- return null;
- }
-
- /**
- * returns the AccessibleName from an AccessibleContext
- */
- private String getAccessibleNameFromContext(final AccessibleContext ac) {
- debugString("***** ac = "+ac.getClass());
- if (ac != null) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ac.getAccessibleName();
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- debugString("Returning AccessibleName from Context: " + s);
- return s;
- } else {
- return null;
- }
- } else {
- debugString("getAccessibleNameFromContext; ac = null!");
- return null;
- }
- }
-
- /**
- * Returns an AccessibleName for a component using an algorithm optimized
- * for the JAWS screen reader. This method is only intended for JAWS. All
- * other uses are entirely optional.
- */
- private String getVirtualAccessibleNameFromContext(final AccessibleContext ac) {
- if (null != ac) {
- /*
- Step 1:
- =======
- Determine if we can obtain the Virtual Accessible Name from the
- Accessible Name or Accessible Description of the object.
- */
- String nameString = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ac.getAccessibleName();
- }
- }, ac);
- if ( ( null != nameString ) && ( 0 != nameString.length () ) ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from AccessibleContext::getAccessibleName.");
- references.increment (nameString);
- return nameString;
- }
- String descriptionString = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ac.getAccessibleDescription();
- }
- }, ac);
- if ( ( null != descriptionString ) && ( 0 != descriptionString.length () ) ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from AccessibleContext::getAccessibleDescription.");
- references.increment (descriptionString);
- return descriptionString;
- }
-
- debugString ("The Virtual Accessible Name was not found using AccessibleContext::getAccessibleDescription. or getAccessibleName");
- /*
- Step 2:
- =======
- Decide whether the extended name search algorithm should be
- used for this object.
- */
- boolean bExtendedSearch = false;
- AccessibleRole role = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return ac.getAccessibleRole();
- }
- }, ac);
- AccessibleContext parentContext = null;
- AccessibleRole parentRole = AccessibleRole.UNKNOWN;
-
- if ( extendedVirtualNameSearchRoles.contains (role) ) {
- parentContext = getAccessibleParentFromContext (ac);
- if ( null != parentContext ) {
- final AccessibleContext parentContextInnerTemp = parentContext;
- parentRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return parentContextInnerTemp.getAccessibleRole();
- }
- }, ac);
- if ( AccessibleRole.UNKNOWN != parentRole ) {
- bExtendedSearch = true;
- if ( noExtendedVirtualNameSearchParentRoles.contains (parentRole) ) {
- bExtendedSearch = false;
- }
- }
- }
- }
-
- if (false == bExtendedSearch) {
- debugString ("bk -- getVirtualAccessibleNameFromContext will not use the extended name search algorithm. role = " + role.toDisplayString (Locale.US) );
- /*
- Step 3:
- =======
- We have determined that we should not use the extended name
- search algorithm for this object (we must obtain the name of
- the object from the object itself and not from neighboring
- objects). However the object name cannot be obtained from
- the Accessible Name or Accessible Description of the object.
-
- Handle several special cases here that might yield a value for
- the Virtual Accessible Name. Return null if the object does
- not match the criteria for any of these special cases.
- */
- if (AccessibleRole.LABEL == role) {
- /*
- Does the label support the Accessible Text Interface?
- */
- final AccessibleText at = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleText call() throws Exception {
- return ac.getAccessibleText();
- }
- }, ac);
- if (null != at) {
- int charCount = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- return at.getCharCount();
- }
- }, ac);
- String text = getAccessibleTextRangeFromContext (ac, 0, charCount);
- if (null != text) {
- debugString ("bk -- The Virtual Accessible Name was obtained from the Accessible Text of the LABEL object.");
- references.increment (text);
- return text;
- }
- }
- /*
- Does the label support the Accessible Icon Interface?
- */
- debugString ("bk -- Attempting to obtain the Virtual Accessible Name from the Accessible Icon information.");
- final AccessibleIcon [] ai = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleIcon[] call() throws Exception {
- return ac.getAccessibleIcon();
- }
- }, ac);
- if ( (null != ai) && (ai.length > 0) ) {
- String iconDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ai[0].getAccessibleIconDescription();
- }
- }, ac);
- if (iconDescription != null){
- debugString ("bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the LABEL object.");
- references.increment (iconDescription);
- return iconDescription;
- }
- } else {
- parentContext = getAccessibleParentFromContext (ac);
- if ( null != parentContext ) {
- final AccessibleContext parentContextInnerTemp = parentContext;
- parentRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return parentContextInnerTemp.getAccessibleRole();
- }
- }, ac);
- if ( AccessibleRole.TABLE == parentRole ) {
- int indexInParent = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- return ac.getAccessibleIndexInParent();
- }
- }, ac);
- final AccessibleContext acTableCell = getAccessibleChildFromContext (parentContext, indexInParent);
- debugString ("bk -- Making a second attempt to obtain the Virtual Accessible Name from the Accessible Icon information for the Table Cell.");
- if (acTableCell != null) {
- final AccessibleIcon [] aiRet =InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleIcon[] call() throws Exception {
- return acTableCell.getAccessibleIcon();
- }
- }, ac);
- if ( (null != aiRet) && (aiRet.length > 0) ) {
- String iconDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return aiRet[0].getAccessibleIconDescription();
- }
- }, ac);
- if (iconDescription != null){
- debugString ("bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the Table Cell object.");
- references.increment (iconDescription);
- return iconDescription;
- }
- }
- }
- }
- }
- }
- } else if ( (AccessibleRole.TOGGLE_BUTTON == role) ||
- (AccessibleRole.PUSH_BUTTON == role) ) {
- /*
- Does the button support the Accessible Icon Interface?
- */
- debugString ("bk -- Attempting to obtain the Virtual Accessible Name from the Accessible Icon information.");
- final AccessibleIcon [] ai = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleIcon[] call() throws Exception {
- return ac.getAccessibleIcon();
- }
- }, ac);
- if ( (null != ai) && (ai.length > 0) ) {
- String iconDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ai[0].getAccessibleIconDescription();
- }
- }, ac);
- if (iconDescription != null){
- debugString ("bk -- The Virtual Accessible Name was obtained from the description of the first Accessible Icon found in the TOGGLE_BUTTON or PUSH_BUTTON object.");
- references.increment (iconDescription);
- return iconDescription;
- }
- }
- } else if ( AccessibleRole.CHECK_BOX == role ) {
- /*
- NOTE: The only case I know of in which a check box does not
- have a name is when that check box is contained in a table.
-
- In this case it would be appropriate to use the display string
- of the check box object as the name (in US English the display
- string is typically either "true" or "false").
-
- I am using the AccessibleValue interface to obtain the display
- string of the check box. If the Accessible Value is 1, I am
- returning Boolean.TRUE.toString (), If the Accessible Value is
- 0, I am returning Boolean.FALSE.toString (). If the Accessible
- Value is some other number, I will return the display string of
- the current numerical value of the check box.
- */
- final AccessibleValue av = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleValue call() throws Exception {
- return ac.getAccessibleValue();
- }
- }, ac);
- if ( null != av ) {
- nameString = null;
- Number value = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Number call() throws Exception {
- return av.getCurrentAccessibleValue();
- }
- }, ac);
- if ( null != value ) {
- if ( 1 == value.intValue () ) {
- nameString = Boolean.TRUE.toString ();
- } else if ( 0 == value.intValue () ) {
- nameString = Boolean.FALSE.toString ();
- } else {
- nameString = value.toString ();
- }
- if ( null != nameString ) {
- references.increment (nameString);
- return nameString;
- }
- }
- }
- }
- return null;
- }
-
- /*
- +
- Beginning of the extended name search
- +
- */
- final AccessibleContext parentContextOuterTemp = parentContext;
- String parentName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return parentContextOuterTemp.getAccessibleName();
- }
- }, ac);
- String parentDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return parentContextOuterTemp.getAccessibleDescription();
- }
- }, ac);
-
- /*
- Step 4:
- =======
- Special case for Slider Bar objects.
- */
- if ( (AccessibleRole.SLIDER == role) &&
- (AccessibleRole.PANEL == parentRole) &&
- (null != parentName) ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from the Accessible Name of the SLIDER object's parent object.");
- references.increment (parentName);
- return parentName;
- }
-
- boolean bIsEditCombo = false;
-
- AccessibleContext testContext = ac;
- /*
- Step 5:
- =======
- Special case for Edit Combo Boxes
- */
- if ( (AccessibleRole.TEXT == role) &&
- (AccessibleRole.COMBO_BOX == parentRole) ) {
- bIsEditCombo = true;
- if (null != parentName) {
- debugString ("bk -- The Virtual Accessible Name for this Edit Combo box was obtained from the Accessible Name of the object's parent object.");
- references.increment (parentName);
- return parentName;
- } else if (null != parentDescription) {
- debugString ("bk -- The Virtual Accessible Name for this Edit Combo box was obtained from the Accessible Description of the object's parent object.");
- references.increment (parentDescription);
- return parentDescription;
- }
- testContext = parentContext;
- parentRole = AccessibleRole.UNKNOWN;
- parentContext = getAccessibleParentFromContext (testContext);
- if ( null != parentContext ) {
- final AccessibleContext parentContextInnerTemp = parentContext;
- parentRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return parentContextInnerTemp.getAccessibleRole();
- }
- }, ac);
- }
- }
-
- /*
- Step 6:
- =======
- Attempt to get the Virtual Accessible Name of the object using the
- Accessible Relation Set Info (the LABELED_BY Accessible Relation).
- */
- {
- final AccessibleContext parentContextTempInner = parentContext;
- AccessibleRelationSet ars = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRelationSet call() throws Exception {
- return parentContextTempInner.getAccessibleRelationSet();
- }
- }, ac);
- if ( ars != null && (ars.size () > 0) && (ars.contains (AccessibleRelation.LABELED_BY)) ) {
- AccessibleRelation labeledByRelation = ars.get (AccessibleRelation.LABELED_BY);
- if (labeledByRelation != null) {
- Object [] targets = labeledByRelation.getTarget ();
- Object o = targets [0];
- if (o instanceof Accessible) {
- AccessibleContext labelContext = ((Accessible)o).getAccessibleContext ();
- if (labelContext != null) {
- String labelName = labelContext.getAccessibleName ();
- String labelDescription = labelContext.getAccessibleDescription ();
- if (null != labelName) {
- debugString ("bk -- The Virtual Accessible Name was obtained using the LABELED_BY AccessibleRelation -- Name Case.");
- references.increment (labelName);
- return labelName;
- } else if (null != labelDescription) {
- debugString ("bk -- The Virtual Accessible Name was obtained using the LABELED_BY AccessibleRelation -- Description Case.");
- references.increment (labelDescription);
- return labelDescription;
- }
- }
- }
- }
- }
- }
-
- //Note: add AccessibleContext to use InvocationUtils.invokeAndWait
- /*
- Step 7:
- =======
- Search for a label object that is positioned either just to the left
- or just above the object and get the Accessible Name of the Label
- object.
- */
- int testIndexMax = 0;
- int testX = 0;
- int testY = 0;
- int testWidth = 0;
- int testHeight = 0;
- int targetX = 0;
- int targetY = 0;
- final AccessibleContext tempContext = testContext;
- int testIndex = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- return tempContext.getAccessibleIndexInParent();
- }
- }, ac);
- if ( null != parentContext ) {
- final AccessibleContext parentContextInnerTemp = parentContext;
- testIndexMax = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- return parentContextInnerTemp.getAccessibleChildrenCount() - 1;
- }
- }, ac);
- }
- testX = getAccessibleXcoordFromContext (testContext);
- testY = getAccessibleYcoordFromContext (testContext);
- testWidth = getAccessibleWidthFromContext (testContext);
- testHeight = getAccessibleHeightFromContext (testContext);
- targetX = testX + 2;
- targetY = testY + 2;
-
- int childIndex = testIndex - 1;
- /*Accessible child = null;
- AccessibleContext childContext = null;
- AccessibleRole childRole = AccessibleRole.UNKNOWN;*/
- int childX = 0;
- int childY = 0;
- int childWidth = 0;
- int childHeight = 0;
- String childName = null;
- String childDescription = null;
- while (childIndex >= 0) {
- final int childIndexTemp = childIndex;
- final AccessibleContext parentContextInnerTemp = parentContext;
- final Accessible child = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Accessible call() throws Exception {
- return parentContextInnerTemp.getAccessibleChild(childIndexTemp);
- }
- }, ac);
- if ( null != child ) {
- final AccessibleContext childContext = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return child.getAccessibleContext();
- }
- }, ac);
- if ( null != childContext ) {
- AccessibleRole childRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return childContext.getAccessibleRole();
- }
- }, ac);
- if ( AccessibleRole.LABEL == childRole ) {
- childX = getAccessibleXcoordFromContext (childContext);
- childY = getAccessibleYcoordFromContext (childContext);
- childWidth = getAccessibleWidthFromContext (childContext);
- childHeight = getAccessibleHeightFromContext (childContext);
- if ( (childX < testX) &&
- ((childY <= targetY) && (targetY <= (childY + childHeight))) ) {
- childName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleName();
- }
- }, ac);
- if ( null != childName ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned to the left of the object.");
- references.increment (childName);
- return childName;
- }
- childDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleDescription();
- }
- }, ac);
- if ( null != childDescription ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned to the left of the object.");
- references.increment (childDescription);
- return childDescription;
- }
- } else if ( (childY < targetY) &&
- ((childX <= targetX) && (targetX <= (childX + childWidth))) ) {
- childName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleName();
- }
- }, ac);
- if ( null != childName ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned above the object.");
- references.increment (childName);
- return childName;
- }
- childDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleDescription();
- }
- }, ac);
- if ( null != childDescription ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned above the object.");
- references.increment (childDescription);
- return childDescription;
- }
- }
- }
- }
- }
- childIndex --;
- }
- childIndex = testIndex + 1;
- while (childIndex <= testIndexMax) {
- final int childIndexTemp = childIndex;
- final AccessibleContext parentContextInnerTemp = parentContext;
- final Accessible child = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Accessible call() throws Exception {
- return parentContextInnerTemp.getAccessibleChild(childIndexTemp);
- }
- }, ac);
- if ( null != child ) {
- final AccessibleContext childContext = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return child.getAccessibleContext();
- }
- }, ac);
- if ( null != childContext ) {
- AccessibleRole childRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return childContext.getAccessibleRole();
- }
- }, ac);
- if ( AccessibleRole.LABEL == childRole ) {
- childX = getAccessibleXcoordFromContext (childContext);
- childY = getAccessibleYcoordFromContext (childContext);
- childWidth = getAccessibleWidthFromContext (childContext);
- childHeight = getAccessibleHeightFromContext (childContext);
- if ( (childX < testX) &&
- ((childY <= targetY) && (targetY <= (childY + childHeight))) ) {
- childName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleName();
- }
- }, ac);
- if ( null != childName ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned to the left of the object.");
- references.increment (childName);
- return childName;
- }
- childDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleDescription();
- }
- }, ac);
- if ( null != childDescription ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned to the left of the object.");
- references.increment (childDescription);
- return childDescription;
- }
- } else if ( (childY < targetY) &&
- ((childX <= targetX) && (targetX <= (childX + childWidth))) ) {
- childName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleName();
- }
- }, ac);
- if ( null != childName ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a LABEL object positioned above the object.");
- references.increment (childName);
- return childName;
- }
- childDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleDescription();
- }
- }, ac);
- if ( null != childDescription ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a LABEL object positioned above the object.");
- references.increment (childDescription);
- return childDescription;
- }
- }
- }
- }
- }
- childIndex ++;
- }
- /*
- Step 8:
- =======
- Special case for combo boxes and text objects, based on a
- similar special case I found in some of our internal JAWS code.
-
- Search for a button object that is positioned either just to the left
- or just above the object and get the Accessible Name of the button
- object.
- */
- if ( (AccessibleRole.TEXT == role) ||
- (AccessibleRole.COMBO_BOX == role) ||
- (bIsEditCombo) ) {
- childIndex = testIndex - 1;
- while (childIndex >= 0) {
- final int childIndexTemp = childIndex;
- final AccessibleContext parentContextInnerTemp = parentContext;
- final Accessible child = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Accessible call() throws Exception {
- return parentContextInnerTemp.getAccessibleChild(childIndexTemp);
- }
- }, ac);
- if ( null != child ) {
- final AccessibleContext childContext = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return child.getAccessibleContext();
- }
- }, ac);
- if ( null != childContext ) {
- AccessibleRole childRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return childContext.getAccessibleRole();
- }
- }, ac);
- if ( ( AccessibleRole.PUSH_BUTTON == childRole ) ||
- ( AccessibleRole.TOGGLE_BUTTON == childRole )) {
- childX = getAccessibleXcoordFromContext (childContext);
- childY = getAccessibleYcoordFromContext (childContext);
- childWidth = getAccessibleWidthFromContext (childContext);
- childHeight = getAccessibleHeightFromContext (childContext);
- if ( (childX < testX) &&
- ((childY <= targetY) && (targetY <= (childY + childHeight))) ) {
- childName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleName();
- }
- }, ac);
- if ( null != childName ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object.");
- references.increment (childName);
- return childName;
- }
- childDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleDescription();
- }
- }, ac);
- if ( null != childDescription ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object.");
- references.increment (childDescription);
- return childDescription;
- }
- }
- }
- }
- }
- childIndex --;
- }
- childIndex = testIndex + 1;
- while (childIndex <= testIndexMax) {
- final int childIndexTemp = childIndex;
- final AccessibleContext parentContextInnerTemp = parentContext;
- final Accessible child = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Accessible call() throws Exception {
- return parentContextInnerTemp.getAccessibleChild(childIndexTemp);
- }
- }, ac);
- if ( null != child ) {
- final AccessibleContext childContext = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return child.getAccessibleContext();
- }
- }, ac);
- if ( null != childContext ) {
- AccessibleRole childRole = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return childContext.getAccessibleRole();
- }
- }, ac);
- if ( ( AccessibleRole.PUSH_BUTTON == childRole ) ||
- ( AccessibleRole.TOGGLE_BUTTON == childRole ) ) {
- childX = getAccessibleXcoordFromContext (childContext);
- childY = getAccessibleYcoordFromContext (childContext);
- childWidth = getAccessibleWidthFromContext (childContext);
- childHeight = getAccessibleHeightFromContext (childContext);
- if ( (childX < testX) &&
- ((childY <= targetY) && (targetY <= (childY + childHeight))) ) {
- childName = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleName();
- }
- }, ac);
- if ( null != childName ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Name of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object.");
- references.increment (childName);
- return childName;
- }
- childDescription = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return childContext.getAccessibleDescription();
- }
- }, ac);
- if ( null != childDescription ) {
- debugString ("bk -- The Virtual Accessible Name was obtained from Accessible Description of a PUSH_BUTTON or TOGGLE_BUTTON object positioned to the left of the object.");
- references.increment (childDescription);
- return childDescription;
- }
- }
- }
- }
- }
- childIndex ++;
- }
- }
- return null;
- } else {
- debugString ("AccessBridge::getVirtualAccessibleNameFromContext error - ac == null.");
- return null;
- }
- }
-
- /**
- * returns the AccessibleDescription from an AccessibleContext
- */
- private String getAccessibleDescriptionFromContext(final AccessibleContext ac) {
- if (ac != null) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ac.getAccessibleDescription();
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- debugString("Returning AccessibleDescription from Context: " + s);
- return s;
- }
- } else {
- debugString("getAccessibleDescriptionFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * returns the AccessibleRole from an AccessibleContext
- */
- private String getAccessibleRoleStringFromContext(final AccessibleContext ac) {
- if (ac != null) {
- AccessibleRole role = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleRole call() throws Exception {
- return ac.getAccessibleRole();
- }
- }, ac);
- if (role != null) {
- String s = role.toDisplayString(Locale.US);
- if (s != null) {
- references.increment(s);
- debugString("Returning AccessibleRole from Context: " + s);
- return s;
- }
- }
- } else {
- debugString("getAccessibleRoleStringFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the AccessibleRole from an AccessibleContext in the en_US locale
- */
- private String getAccessibleRoleStringFromContext_en_US(final AccessibleContext ac) {
- return getAccessibleRoleStringFromContext(ac);
- }
-
- /**
- * return the AccessibleStates from an AccessibleContext
- */
- private String getAccessibleStatesStringFromContext(final AccessibleContext ac) {
- if (ac != null) {
- AccessibleStateSet stateSet = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleStateSet call() throws Exception {
- return ac.getAccessibleStateSet();
- }
- }, ac);
- if (stateSet != null) {
- String s = stateSet.toString();
- if (s != null &&
- s.indexOf(AccessibleState.MANAGES_DESCENDANTS.toDisplayString(Locale.US)) == -1) {
- // Indicate whether this component manages its own
- // children
- AccessibleRole role = ac.getAccessibleRole();
- if (role == AccessibleRole.LIST ||
- role == AccessibleRole.TABLE ||
- role == AccessibleRole.TREE) {
- s += ",";
- s += AccessibleState.MANAGES_DESCENDANTS.toDisplayString(Locale.US);
- }
- references.increment(s);
- debugString("Returning AccessibleStateSet from Context: " + s);
- return s;
- }
- }
- } else {
- debugString("getAccessibleStatesStringFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * returns the AccessibleStates from an AccessibleContext in the en_US locale
- */
- private String getAccessibleStatesStringFromContext_en_US(final AccessibleContext ac) {
- if (ac != null) {
- AccessibleStateSet stateSet = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleStateSet call() throws Exception {
- return ac.getAccessibleStateSet();
- }
- }, ac);
- if (stateSet != null) {
- String s = "";
- AccessibleState[] states = stateSet.toArray();
- if (states != null && states.length > 0) {
- s = states[0].toDisplayString(Locale.US);
- for (int i = 1; i < states.length; i++) {
- s = s + "," + states[i].toDisplayString(Locale.US);
- }
- }
- references.increment(s);
- debugString("Returning AccessibleStateSet en_US from Context: " + s);
- return s;
- }
- }
- debugString("getAccessibleStatesStringFromContext; ac = null");
- return null;
- }
-
- /**
- * returns the AccessibleParent from an AccessibleContext
- */
- private AccessibleContext getAccessibleParentFromContext(final AccessibleContext ac) {
- if (ac==null)
- return null;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- Accessible a = ac.getAccessibleParent();
- if (a != null) {
- AccessibleContext apc = a.getAccessibleContext();
- if (apc != null) {
- return apc;
- }
- }
- return null;
- }
- }, ac);
- }
-
- /**
- * returns the AccessibleIndexInParent from an AccessibleContext
- */
- private int getAccessibleIndexInParentFromContext(final AccessibleContext ac) {
- if (ac==null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- return ac.getAccessibleIndexInParent();
- }
- }, ac);
- }
-
- /**
- * returns the AccessibleChild count from an AccessibleContext
- */
- private int getAccessibleChildrenCountFromContext(final AccessibleContext ac) {
- if (ac==null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- return ac.getAccessibleChildrenCount();
- }
- }, ac);
- }
-
- /**
- * returns the AccessibleChild Context from an AccessibleContext
- */
- private AccessibleContext getAccessibleChildFromContext(final AccessibleContext ac, final int index) {
-
- if (ac == null) {
- return null;
- }
-
- final JTable table = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public JTable call() throws Exception {
- // work-around for AccessibleJTable.getCurrentAccessibleContext returning
- // wrong renderer component when cell contains more than one component
- Accessible parent = ac.getAccessibleParent();
- if (parent != null) {
- int indexInParent = ac.getAccessibleIndexInParent();
- Accessible child =
- parent.getAccessibleContext().getAccessibleChild(indexInParent);
- if (child instanceof JTable) {
- return (JTable) child;
- }
- }
- return null;
- }
- }, ac);
-
- if (table == null) {
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- Accessible a = ac.getAccessibleChild(index);
- if (a != null) {
- return a.getAccessibleContext();
- }
- return null;
- }
- }, ac);
- }
-
- final AccessibleTable at = getAccessibleTableFromContext(ac);
-
- final int row = getAccessibleTableRow(at, index);
- final int column = getAccessibleTableColumn(at, index);
-
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- TableCellRenderer renderer = table.getCellRenderer(row, column);
- if (renderer == null) {
- Class> columnClass = table.getColumnClass(column);
- renderer = table.getDefaultRenderer(columnClass);
- }
- Component component =
- renderer.getTableCellRendererComponent(table, table.getValueAt(row, column),
- false, false, row, column);
- if (component instanceof Accessible) {
- return component.getAccessibleContext();
- }
- return null;
- }
- }, ac);
- }
-
- /**
- * returns the AccessibleComponent bounds on screen from an AccessibleContext
- */
- private Rectangle getAccessibleBoundsOnScreenFromContext(final AccessibleContext ac) {
- if(ac==null)
- return null;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Rectangle call() throws Exception {
- AccessibleComponent acmp = ac.getAccessibleComponent();
- if (acmp != null) {
- Rectangle r = acmp.getBounds();
- if (r != null) {
- try {
- Point p = acmp.getLocationOnScreen();
- if (p != null) {
- r.x = p.x;
- r.y = p.y;
- return r;
- }
- } catch (Exception e) {
- return null;
- }
- }
- }
- return null;
- }
- }, ac);
- }
-
- /**
- * returns the AccessibleComponent x-coord from an AccessibleContext
- */
- private int getAccessibleXcoordFromContext(AccessibleContext ac) {
- if (ac != null) {
- Rectangle r = getAccessibleBoundsOnScreenFromContext(ac);
- if (r != null) {
- debugString(" - Returning Accessible x coord from Context: " + r.x);
- return r.x;
- }
- } else {
- debugString("getAccessibleXcoordFromContext ac = null");
- }
- return -1;
- }
-
- /**
- * returns the AccessibleComponent y-coord from an AccessibleContext
- */
- private int getAccessibleYcoordFromContext(AccessibleContext ac) {
- debugString("getAccessibleYcoordFromContext() called");
- if (ac != null) {
- Rectangle r = getAccessibleBoundsOnScreenFromContext(ac);
- if (r != null) {
- return r.y;
- }
- } else {
- debugString("getAccessibleYcoordFromContext; ac = null");
- }
- return -1;
- }
-
- /**
- * returns the AccessibleComponent height from an AccessibleContext
- */
- private int getAccessibleHeightFromContext(AccessibleContext ac) {
- if (ac != null) {
- Rectangle r = getAccessibleBoundsOnScreenFromContext(ac);
- if (r != null) {
- return r.height;
- }
- } else {
- debugString("getAccessibleHeightFromContext; ac = null");
- }
- return -1;
- }
-
- /**
- * returns the AccessibleComponent width from an AccessibleContext
- */
- private int getAccessibleWidthFromContext(AccessibleContext ac) {
- if (ac != null) {
- Rectangle r = getAccessibleBoundsOnScreenFromContext(ac);
- if (r != null) {
- return r.width;
- }
- } else {
- debugString("getAccessibleWidthFromContext; ac = null");
- }
- return -1;
- }
-
-
- /**
- * returns the AccessibleComponent from an AccessibleContext
- */
- private AccessibleComponent getAccessibleComponentFromContext(AccessibleContext ac) {
- if (ac != null) {
- AccessibleComponent acmp = ac.getAccessibleComponent();
- if (acmp != null) {
- debugString("Returning AccessibleComponent Context");
- return acmp;
- }
- } else {
- debugString("getAccessibleComponentFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * returns the AccessibleAction from an AccessibleContext
- */
- private AccessibleAction getAccessibleActionFromContext(final AccessibleContext ac) {
- debugString("Returning AccessibleAction Context");
- return ac == null ? null : InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleAction call() throws Exception {
- return ac.getAccessibleAction();
- }
- }, ac);
- }
-
- /**
- * returns the AccessibleSelection from an AccessibleContext
- */
- private AccessibleSelection getAccessibleSelectionFromContext(final AccessibleContext ac) {
- return ac == null ? null : InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleSelection call() throws Exception {
- return ac.getAccessibleSelection();
- }
- }, ac);
- }
-
- /**
- * return the AccessibleText from an AccessibleContext
- */
- private AccessibleText getAccessibleTextFromContext(final AccessibleContext ac) {
- return ac == null ? null : InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleText call() throws Exception {
- return ac.getAccessibleText();
- }
- }, ac);
- }
-
- /**
- * return the AccessibleComponent from an AccessibleContext
- */
- private AccessibleValue getAccessibleValueFromContext(final AccessibleContext ac) {
- return ac == null ? null : InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleValue call() throws Exception {
- return ac.getAccessibleValue();
- }
- }, ac);
- }
-
- /* ===== AccessibleText methods ===== */
-
- /**
- * returns the bounding rectangle for the text cursor
- * XXX
- */
- private Rectangle getCaretLocation(final AccessibleContext ac) {
- debugString("getCaretLocation");
- if (ac==null)
- return null;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Rectangle call() throws Exception {
- // workaround for JAAPI not returning cursor bounding rectangle
- Rectangle r = null;
- Accessible parent = ac.getAccessibleParent();
- if (parent instanceof Accessible) {
- int indexInParent = ac.getAccessibleIndexInParent();
- Accessible child =
- parent.getAccessibleContext().getAccessibleChild(indexInParent);
-
- if (child instanceof JTextComponent) {
- JTextComponent text = (JTextComponent) child;
- try {
- r = text.modelToView(text.getCaretPosition());
- if (r != null) {
- Point p = text.getLocationOnScreen();
- r.translate(p.x, p.y);
- }
- } catch (BadLocationException ble) {
- }
- }
- }
- return r;
- }
- }, ac);
- }
-
- /**
- * returns the x-coordinate for the text cursor rectangle
- */
- private int getCaretLocationX(AccessibleContext ac) {
- Rectangle r = getCaretLocation(ac);
- if (r != null) {
- return r.x;
- } else {
- return -1;
- }
- }
-
- /**
- * returns the y-coordinate for the text cursor rectangle
- */
- private int getCaretLocationY(AccessibleContext ac) {
- Rectangle r = getCaretLocation(ac);
- if (r != null) {
- return r.y;
- } else {
- return -1;
- }
- }
-
- /**
- * returns the height for the text cursor rectangle
- */
- private int getCaretLocationHeight(AccessibleContext ac) {
- Rectangle r = getCaretLocation(ac);
- if (r != null) {
- return r.height;
- } else {
- return -1;
- }
- }
-
- /**
- * returns the width for the text cursor rectangle
- */
- private int getCaretLocationWidth(AccessibleContext ac) {
- Rectangle r = getCaretLocation(ac);
- if (r != null) {
- return r.width;
- } else {
- return -1;
- }
- }
-
- /**
- * returns the character count from an AccessibleContext
- */
- private int getAccessibleCharCountFromContext(final AccessibleContext ac) {
- if (ac==null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- return at.getCharCount();
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * returns the caret position from an AccessibleContext
- */
- private int getAccessibleCaretPositionFromContext(final AccessibleContext ac) {
- if (ac==null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- return at.getCaretPosition();
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * Return the index at a specific point from an AccessibleContext
- * Point(x, y) is in screen coordinates.
- */
- private int getAccessibleIndexAtPointFromContext(final AccessibleContext ac,
- final int x, final int y) {
- debugString("getAccessibleIndexAtPointFromContext: x = "+x+"; y = "+y);
- if (ac==null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- AccessibleComponent acomp = ac.getAccessibleComponent();
- if (at != null && acomp != null) {
- // Convert x and y from screen coordinates to
- // local coordinates.
- try {
- Point p = acomp.getLocationOnScreen();
- int x1, y1;
- if (p != null) {
- x1 = x - p.x;
- if (x1 < 0) {
- x1 = 0;
- }
- y1 = y - p.y;
- if (y1 < 0) {
- y1 = 0;
- }
-
- Point newPoint = new Point(x1, y1);
- int indexAtPoint = at.getIndexAtPoint(new Point(x1, y1));
- return indexAtPoint;
- }
- } catch (Exception e) {
- }
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * return the letter at a specific point from an AccessibleContext
- */
- private String getAccessibleLetterAtIndexFromContext(final AccessibleContext ac, final int index) {
- if (ac != null) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at == null) return null;
- return at.getAtIndex(AccessibleText.CHARACTER, index);
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getAccessibleLetterAtIndexFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the word at a specific point from an AccessibleContext
- */
- private String getAccessibleWordAtIndexFromContext(final AccessibleContext ac, final int index) {
- if (ac != null) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at == null) return null;
- return at.getAtIndex(AccessibleText.WORD, index);
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getAccessibleWordAtIndexFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the sentence at a specific point from an AccessibleContext
- */
- private String getAccessibleSentenceAtIndexFromContext(final AccessibleContext ac, final int index) {
- if (ac != null) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at == null) return null;
- return at.getAtIndex(AccessibleText.SENTENCE, index);
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getAccessibleSentenceAtIndexFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the text selection start from an AccessibleContext
- */
- private int getAccessibleTextSelectionStartFromContext(final AccessibleContext ac) {
- if (ac == null) return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- return at.getSelectionStart();
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * return the text selection end from an AccessibleContext
- */
- private int getAccessibleTextSelectionEndFromContext(final AccessibleContext ac) {
- if (ac == null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- return at.getSelectionEnd();
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * return the selected text from an AccessibleContext
- */
- private String getAccessibleTextSelectedTextFromContext(final AccessibleContext ac) {
- if (ac != null) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at == null) return null;
- return at.getSelectedText();
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getAccessibleTextSelectedTextFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the attribute string at a given index from an AccessibleContext
- */
- private String getAccessibleAttributesAtIndexFromContext(final AccessibleContext ac,
- final int index) {
- if (ac == null)
- return null;
- AttributeSet as = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AttributeSet call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- return at.getCharacterAttribute(index);
- }
- return null;
- }
- }, ac);
- String s = expandStyleConstants(as);
- if (s != null) {
- references.increment(s);
- return s;
- }
- return null;
- }
-
- /**
- * Get line info: left index of line
- *
- * algorithm: cast back, doubling each time,
- * 'till find line boundaries
- *
- * return -1 if we can't get the info (e.g. index or at passed in
- * is bogus; etc.)
- */
- private int getAccessibleTextLineLeftBoundsFromContext(final AccessibleContext ac,
- final int index) {
- if (ac == null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- int lineStart;
- int offset;
- Rectangle charRect;
- Rectangle indexRect = at.getCharacterBounds(index);
- int textLen = at.getCharCount();
- if (indexRect == null) {
- return -1;
- }
- // find the start of the line
- //
- offset = 1;
- lineStart = index - offset < 0 ? 0 : index - offset;
- charRect = at.getCharacterBounds(lineStart);
- // slouch behind beginning of line
- while (charRect != null
- && charRect.y >= indexRect.y
- && lineStart > 0) {
- offset = offset << 1;
- lineStart = index - offset < 0 ? 0 : index - offset;
- charRect = at.getCharacterBounds(lineStart);
- }
- if (lineStart == 0) { // special case: we're on the first line!
- // we found it!
- } else {
- offset = offset >> 1; // know boundary within last expansion
- // ground forward to beginning of line
- while (offset > 0) {
- charRect = at.getCharacterBounds(lineStart + offset);
- if (charRect.y < indexRect.y) { // still before line
- lineStart += offset;
- } else {
- // leave lineStart alone, it's close!
- }
- offset = offset >> 1;
- }
- // subtract one 'cause we're already too far...
- lineStart += 1;
- }
- return lineStart;
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * Get line info: right index of line
- *
- * algorithm: cast back, doubling each time,
- * 'till find line boundaries
- *
- * return -1 if we can't get the info (e.g. index or at passed in
- * is bogus; etc.)
- */
- private int getAccessibleTextLineRightBoundsFromContext(final AccessibleContext ac, final int index) {
- if(ac == null)
- return -1;
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Integer call() throws Exception {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- int lineEnd;
- int offset;
- Rectangle charRect;
- Rectangle indexRect = at.getCharacterBounds(index);
- int textLen = at.getCharCount();
- if (indexRect == null) {
- return -1;
- }
- // find the end of the line
- //
- offset = 1;
- lineEnd = index + offset > textLen - 1
- ? textLen - 1 : index + offset;
- charRect = at.getCharacterBounds(lineEnd);
- // push past end of line
- while (charRect != null &&
- charRect.y <= indexRect.y &&
- lineEnd < textLen - 1) {
- offset = offset << 1;
- lineEnd = index + offset > textLen - 1
- ? textLen - 1 : index + offset;
- charRect = at.getCharacterBounds(lineEnd);
- }
- if (lineEnd == textLen - 1) { // special case: on the last line!
- // we found it!
- } else {
- offset = offset >> 1; // know boundary within last expansion
- // pull back to end of line
- while (offset > 0) {
- charRect = at.getCharacterBounds(lineEnd - offset);
- if (charRect.y > indexRect.y) { // still beyond line
- lineEnd -= offset;
- } else {
- // leave lineEnd alone, it's close!
- }
- offset = offset >> 1;
- }
- // subtract one 'cause we're already too far...
- lineEnd -= 1;
- }
- return lineEnd;
- }
- return -1;
- }
- }, ac);
- }
-
- /**
- * Get a range of text; null if indicies are bogus
- */
- private String getAccessibleTextRangeFromContext(final AccessibleContext ac,
- final int start, final int end) {
- String s = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- if (ac != null) {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- // start - end is inclusive
- if (start > end) {
- return null;
- }
- if (end >= at.getCharCount()) {
- return null;
- }
- StringBuffer buf = new StringBuffer(end - start + 1);
- for (int i = start; i <= end; i++) {
- buf.append(at.getAtIndex(AccessibleText.CHARACTER, i));
- }
- return buf.toString();
- }
- }
- return null;
- }
- }, ac);
- if (s != null) {
- references.increment(s);
- return s;
- } else {
- return null;
- }
- }
-
- /**
- * return the AttributeSet object at a given index from an AccessibleContext
- */
- private AttributeSet getAccessibleAttributeSetAtIndexFromContext(final AccessibleContext ac,
- final int index) {
- return InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AttributeSet call() throws Exception {
- if (ac != null) {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- AttributeSet as = at.getCharacterAttribute(index);
- if (as != null) {
- AccessBridge.this.references.increment(as);
- return as;
- }
- }
- }
- return null;
- }
- }, ac);
- }
-
-
- /**
- * return the bounding rectangle at index from an AccessibleContext
- */
- private Rectangle getAccessibleTextRectAtIndexFromContext(final AccessibleContext ac,
- final int index) {
- // want to do this in global coords, so need to combine w/ac global coords
- Rectangle r = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Rectangle call() throws Exception {
- // want to do this in global coords, so need to combine w/ac global coords
- if (ac != null) {
- AccessibleText at = ac.getAccessibleText();
- if (at != null) {
- Rectangle rect = at.getCharacterBounds(index);
- if (rect != null) {
- String s = at.getAtIndex(AccessibleText.CHARACTER, index);
- if (s != null && s.equals("\n")) {
- rect.width = 0;
- }
- return rect;
- }
- }
- }
- return null;
- }
- }, ac);
- Rectangle acRect = getAccessibleBoundsOnScreenFromContext(ac);
- if (r != null && acRect != null) {
- r.translate(acRect.x, acRect.y);
- return r;
- }
- return null;
- }
-
- /**
- * return the AccessibleText character x-coord at index from an AccessibleContext
- */
- private int getAccessibleXcoordTextRectAtIndexFromContext(AccessibleContext ac, int index) {
- if (ac != null) {
- Rectangle r = getAccessibleTextRectAtIndexFromContext(ac, index);
- if (r != null) {
- return r.x;
- }
- } else {
- debugString("getAccessibleXcoordTextRectAtIndexFromContext; ac = null");
- }
- return -1;
- }
-
- /**
- * return the AccessibleText character y-coord at index from an AccessibleContext
- */
- private int getAccessibleYcoordTextRectAtIndexFromContext(AccessibleContext ac, int index) {
- if (ac != null) {
- Rectangle r = getAccessibleTextRectAtIndexFromContext(ac, index);
- if (r != null) {
- return r.y;
- }
- } else {
- debugString("getAccessibleYcoordTextRectAtIndexFromContext; ac = null");
- }
- return -1;
- }
-
- /**
- * return the AccessibleText character height at index from an AccessibleContext
- */
- private int getAccessibleHeightTextRectAtIndexFromContext(AccessibleContext ac, int index) {
- if (ac != null) {
- Rectangle r = getAccessibleTextRectAtIndexFromContext(ac, index);
- if (r != null) {
- return r.height;
- }
- } else {
- debugString("getAccessibleHeightTextRectAtIndexFromContext; ac = null");
- }
- return -1;
- }
-
- /**
- * return the AccessibleText character width at index from an AccessibleContext
- */
- private int getAccessibleWidthTextRectAtIndexFromContext(AccessibleContext ac, int index) {
- if (ac != null) {
- Rectangle r = getAccessibleTextRectAtIndexFromContext(ac, index);
- if (r != null) {
- return r.width;
- }
- } else {
- debugString("getAccessibleWidthTextRectAtIndexFromContext; ac = null");
- }
- return -1;
- }
-
- /* ===== AttributeSet methods for AccessibleText ===== */
-
- /**
- * return the bold setting from an AttributeSet
- */
- private boolean getBoldFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.isBold(as);
- } else {
- debugString("getBoldFromAttributeSet; as = null");
- }
- return false;
- }
-
- /**
- * return the italic setting from an AttributeSet
- */
- private boolean getItalicFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.isItalic(as);
- } else {
- debugString("getItalicFromAttributeSet; as = null");
- }
- return false;
- }
-
- /**
- * return the underline setting from an AttributeSet
- */
- private boolean getUnderlineFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.isUnderline(as);
- } else {
- debugString("getUnderlineFromAttributeSet; as = null");
- }
- return false;
- }
-
- /**
- * return the strikethrough setting from an AttributeSet
- */
- private boolean getStrikethroughFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.isStrikeThrough(as);
- } else {
- debugString("getStrikethroughFromAttributeSet; as = null");
- }
- return false;
- }
-
- /**
- * return the superscript setting from an AttributeSet
- */
- private boolean getSuperscriptFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.isSuperscript(as);
- } else {
- debugString("getSuperscriptFromAttributeSet; as = null");
- }
- return false;
- }
-
- /**
- * return the subscript setting from an AttributeSet
- */
- private boolean getSubscriptFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.isSubscript(as);
- } else {
- debugString("getSubscriptFromAttributeSet; as = null");
- }
- return false;
- }
-
- /**
- * return the background color from an AttributeSet
- */
- private String getBackgroundColorFromAttributeSet(AttributeSet as) {
- if (as != null) {
- String s = StyleConstants.getBackground(as).toString();
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getBackgroundColorFromAttributeSet; as = null");
- }
- return null;
- }
-
- /**
- * return the foreground color from an AttributeSet
- */
- private String getForegroundColorFromAttributeSet(AttributeSet as) {
- if (as != null) {
- String s = StyleConstants.getForeground(as).toString();
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getForegroundColorFromAttributeSet; as = null");
- }
- return null;
- }
-
- /**
- * return the font family from an AttributeSet
- */
- private String getFontFamilyFromAttributeSet(AttributeSet as) {
- if (as != null) {
- String s = StyleConstants.getFontFamily(as).toString();
- if (s != null) {
- references.increment(s);
- return s;
- }
- } else {
- debugString("getFontFamilyFromAttributeSet; as = null");
- }
- return null;
- }
-
- /**
- * return the font size from an AttributeSet
- */
- private int getFontSizeFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getFontSize(as);
- } else {
- debugString("getFontSizeFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the alignment from an AttributeSet
- */
- private int getAlignmentFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getAlignment(as);
- } else {
- debugString("getAlignmentFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the BiDi level from an AttributeSet
- */
- private int getBidiLevelFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getBidiLevel(as);
- } else {
- debugString("getBidiLevelFromAttributeSet; as = null");
- }
- return -1;
- }
-
-
- /**
- * return the first line indent from an AttributeSet
- */
- private float getFirstLineIndentFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getFirstLineIndent(as);
- } else {
- debugString("getFirstLineIndentFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the left indent from an AttributeSet
- */
- private float getLeftIndentFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getLeftIndent(as);
- } else {
- debugString("getLeftIndentFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the right indent from an AttributeSet
- */
- private float getRightIndentFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getRightIndent(as);
- } else {
- debugString("getRightIndentFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the line spacing from an AttributeSet
- */
- private float getLineSpacingFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getLineSpacing(as);
- } else {
- debugString("getLineSpacingFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the space above from an AttributeSet
- */
- private float getSpaceAboveFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getSpaceAbove(as);
- } else {
- debugString("getSpaceAboveFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * return the space below from an AttributeSet
- */
- private float getSpaceBelowFromAttributeSet(AttributeSet as) {
- if (as != null) {
- return StyleConstants.getSpaceBelow(as);
- } else {
- debugString("getSpaceBelowFromAttributeSet; as = null");
- }
- return -1;
- }
-
- /**
- * Enumerate all StyleConstants in the AttributeSet
- *
- * We need to check explicitly, 'cause of the HTML package conversion
- * mechanism (they may not be stored as StyleConstants, just translated
- * to them when asked).
- *
- * (Use convenience methods where they are defined...)
- *
- * Not checking the following (which the IBM SNS guidelines says
- * should be defined):
- * - ComponentElementName
- * - IconElementName
- * - NameAttribute
- * - ResolveAttribute
- */
- private String expandStyleConstants(AttributeSet as) {
- Color c;
- Object o;
- String attrString = "";
-
- // ---------- check for various Character Constants
-
- attrString += "BidiLevel = " + StyleConstants.getBidiLevel(as);
-
- final Component comp = StyleConstants.getComponent(as);
- if (comp != null) {
- if (comp instanceof Accessible) {
- final AccessibleContext ac = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public AccessibleContext call() throws Exception {
- return comp.getAccessibleContext();
- }
- }, comp);
- if (ac != null) {
- attrString += "; Accessible Component = " + InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public String call() throws Exception {
- return ac.getAccessibleName();
- }
- }, ac);
- } else {
- attrString += "; Innaccessible Component = " + comp;
- }
- } else {
- attrString += "; Innaccessible Component = " + comp;
- }
- }
-
- Icon i = StyleConstants.getIcon(as);
- if (i != null) {
- if (i instanceof ImageIcon) {
- attrString += "; ImageIcon = " + ((ImageIcon) i).getDescription();
- } else {
- attrString += "; Icon = " + i;
- }
- }
-
- attrString += "; FontFamily = " + StyleConstants.getFontFamily(as);
-
- attrString += "; FontSize = " + StyleConstants.getFontSize(as);
-
- if (StyleConstants.isBold(as)) {
- attrString += "; bold";
- }
-
- if (StyleConstants.isItalic(as)) {
- attrString += "; italic";
- }
-
- if (StyleConstants.isUnderline(as)) {
- attrString += "; underline";
- }
-
- if (StyleConstants.isStrikeThrough(as)) {
- attrString += "; strikethrough";
- }
-
- if (StyleConstants.isSuperscript(as)) {
- attrString += "; superscript";
- }
-
- if (StyleConstants.isSubscript(as)) {
- attrString += "; subscript";
- }
-
- c = StyleConstants.getForeground(as);
- if (c != null) {
- attrString += "; Foreground = " + c;
- }
-
- c = StyleConstants.getBackground(as);
- if (c != null) {
- attrString += "; Background = " + c;
- }
-
- attrString += "; FirstLineIndent = " + StyleConstants.getFirstLineIndent(as);
-
- attrString += "; RightIndent = " + StyleConstants.getRightIndent(as);
-
- attrString += "; LeftIndent = " + StyleConstants.getLeftIndent(as);
-
- attrString += "; LineSpacing = " + StyleConstants.getLineSpacing(as);
-
- attrString += "; SpaceAbove = " + StyleConstants.getSpaceAbove(as);
-
- attrString += "; SpaceBelow = " + StyleConstants.getSpaceBelow(as);
-
- attrString += "; Alignment = " + StyleConstants.getAlignment(as);
-
- TabSet ts = StyleConstants.getTabSet(as);
- if (ts != null) {
- attrString += "; TabSet = " + ts;
- }
-
- return attrString;
- }
-
-
- /* ===== AccessibleValue methods ===== */
-
- /**
- * return the AccessibleValue current value from an AccessibleContext
- * returned using a String 'cause the value is a java Number
- *
- */
- private String getCurrentAccessibleValueFromContext(final AccessibleContext ac) {
- if (ac != null) {
- final Number value = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Number call() throws Exception {
- AccessibleValue av = ac.getAccessibleValue();
- if (av == null) return null;
- return av.getCurrentAccessibleValue();
- }
- }, ac);
- if (value != null) {
- String s = value.toString();
- if (s != null) {
- references.increment(s);
- return s;
- }
- }
- } else {
- debugString("getCurrentAccessibleValueFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the AccessibleValue maximum value from an AccessibleContext
- * returned using a String 'cause the value is a java Number
- *
- */
- private String getMaximumAccessibleValueFromContext(final AccessibleContext ac) {
- if (ac != null) {
- final Number value = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Number call() throws Exception {
- AccessibleValue av = ac.getAccessibleValue();
- if (av == null) return null;
- return av.getMaximumAccessibleValue();
- }
- }, ac);
- if (value != null) {
- String s = value.toString();
- if (s != null) {
- references.increment(s);
- return s;
- }
- }
- } else {
- debugString("getMaximumAccessibleValueFromContext; ac = null");
- }
- return null;
- }
-
- /**
- * return the AccessibleValue minimum value from an AccessibleContext
- * returned using a String 'cause the value is a java Number
- *
- */
- private String getMinimumAccessibleValueFromContext(final AccessibleContext ac) {
- if (ac != null) {
- final Number value = InvocationUtils.invokeAndWait(new Callable() {
- @Override
- public Number call() throws Exception {
- AccessibleValue av = ac.getAccessibleValue();
- if (av == null) return null;
- return av.getMinimumAccessibleValue();
- }
- }, ac);
- if (value != null) {
- String s = value.toString();
- if (s != null) {
- references.increment(s);
- return s;
- }
- }
- } else {
- debugString("getMinimumAccessibleValueFromContext; ac = null");
- }
- return null;
- }
-
-
- /* ===== AccessibleSelection methods ===== */
-
- /**
- * add to the AccessibleSelection of an AccessibleContext child i
- *
- */
- private void addAccessibleSelectionFromContext(final AccessibleContext ac, final int i) {
- try {
- InvocationUtils.invokeAndWait(new Callable