org.eclipse.actf.accservice.core.win32.msaa
Class MsaaAccessible

java.lang.Object
  extended by org.eclipse.actf.accservice.core.win32.msaa.MsaaAccessible
All Implemented Interfaces:
IAccessibleElement
Direct Known Subclasses:
IA2Accessible

public class MsaaAccessible
extends Object
implements IAccessibleElement

implementation of IAccessibleElement for GUI controls that implement Microsoft Active Accessibility (MSAA) interfaces.

This class is a wrapper for an IAccessible pointer, a pointer that Provides access to a native Windows object that provides assistive technologies (ATs) with properties of GUI components that allow the AT to offer an alternative interface to the control. This class relies upon actf-msaa.dll for most of its implementation. The documentation for the Microsoft COM library and, in particular, for MSAA will be helpful.

Author:
Mike Squillace, Barry Feigenbaum
See Also:
The MSDN MSAA Documentation

Field Summary
protected  int accRef
           
protected  int childId
           
static int childId_self
           
protected  Object element
           
protected static boolean highLightEnabled
           
protected  int hwnd
           
protected  int indexInParent
           
protected static String SWT_ACC_TYPENAME
           
protected static String SWT_CTRL_TYPENAME
           
protected static String SWT_WIDGET_TYPENAME
           
 
Constructor Summary
MsaaAccessible(int ref)
          create a MsaaAccessible from an IAccessible pointer.
MsaaAccessible(int hwnd, int childID)
          wrap the given object as an ACTF IAccessibleElement.
MsaaAccessible(Object elem)
          wrap the given object as a ACTF IAccessibleElement.
MsaaAccessible(Point location)
          create an MsaaAccessible element by utilizing the MSAA function AccessibleObjectFromPoint.
 
Method Summary
 void checkIsValid()
          tests whether or not this MsaaAccessible is in a valid state.
protected  void dispose()
          dispose the native resources
 boolean doDefaultAction()
           
 boolean drawRectangle()
           
 Object element()
          get the element associated with this accessible element
 boolean equals(Object other)
           
static boolean eraseDesktop()
           
 boolean eraseRectangle(Rectangle drawRef)
           
protected  void finalize()
           
 Object getAccessibleAction()
          return the default action
 int getAccessibleAddress()
           
 IAccessibleElement getAccessibleChild(int index)
          return the accessible that has the given index in its parent.
 int getAccessibleChildCount()
          return the number of children.
 IAccessibleElement[] getAccessibleChildren()
          return all of the children of this MsaaAccessible.
 String getAccessibleDescription()
          return description or use of control
 String getAccessibleHelp()
          return help info (usually a tool tip)
 String getAccessibleHelpTopic()
           
 int getAccessibleIndexInParent()
          retreave the index of this accessible within its parent accessible
 String getAccessibleKeyboardShortcut()
          return the keyboard shortcut or mnemonic
 Rectangle getAccessibleLocation()
          Gets the bounds of this object in the form of a Rectangle object.
 String getAccessibleName()
          return the name or short description of this element
 IAccessibleElement getAccessibleParent()
          returns the parent accessible object.
 String getAccessibleRole()
          return role or function of control.
 IAccessibleElement[] getAccessibleSelection()
          get the list of selected accessibles.
 Set getAccessibleState()
          return the state of the control.
 Object getAccessibleValue()
          return the value (e.g. of a scroll bar or combo)
 int getChildId()
          get the child ID for this MsaaAccessible, if any.
static String getClassNameFromHwnd(int hwnd)
          gets the class name for the given handle
 int getWindowHandle()
           
 String getWindowHandleAsHex()
          get the handle value as a hex string
 boolean hasFocus()
          returns whether the accessible object has the keyboard focus
 int hashCode()
           
protected  void initFromHtmlElement(int htmlElemRef)
           
protected  void initFromHwnd(int hwnd, int childID)
           
protected  void initFromPoint(int x, int y)
           
protected  void internalDispose()
           
protected  boolean internalDoDefaultAction()
           
protected  boolean internalDrawRectangle()
           
protected static boolean internalEraseDesktop()
           
protected  boolean internalEraseRectangle(int left, int top, int right, int bottom)
           
protected  String internalGetAccessibleAction()
           
protected  int internalGetAccessibleChild(int childID)
           
protected  int internalGetAccessibleChildCount()
           
protected  int[] internalGetAccessibleChildren()
           
protected  String internalGetAccessibleDescription()
           
protected  String internalGetAccessibleHelp()
           
protected  String internalGetAccessibleHelpTopic()
           
protected  String internalGetAccessibleKeyboardShortcut()
           
protected  Rectangle internalGetAccessibleLocation()
           
protected  String internalGetAccessibleName()
           
protected  int internalGetAccessibleParent()
           
protected  String internalGetAccessibleRole()
           
protected  int internalGetAccessibleRoleAsInt()
           
protected  int[] internalGetAccessibleSelection()
           
protected  int internalGetAccessibleState()
           
protected  String internalGetAccessibleValue()
           
protected  int internalGetAddress()
           
protected  int internalGetChildId()
           
protected static String internalGetClassNameFromHwnd(int hwnd)
           
protected  int internalGetWindowHandle()
           
protected  boolean internalHasFocus()
           
protected static int internalInitFromHtmlElement(int htmlElemRef)
           
protected static int internalInitFromHwnd(int hwnd, int childID)
           
protected static int internalInitFromPoint(int x, int y)
           
protected  int internalRef()
          used by native code only.
protected  boolean internalSelect(int flag)
           
protected  boolean isDisposed(Object control)
           
static boolean isHighlightEnabled()
           
protected  boolean isSimpleChild()
          returns whether or not this MsaaAccessible is a simple child.
 boolean select(int flag)
           
static void setHighlightEnabled(boolean val)
           
 MsaaAccessible testAndConvertToIA2(MsaaAccessible acc)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SWT_CTRL_TYPENAME

protected static final String SWT_CTRL_TYPENAME
See Also:
Constant Field Values

SWT_WIDGET_TYPENAME

protected static final String SWT_WIDGET_TYPENAME
See Also:
Constant Field Values

SWT_ACC_TYPENAME

protected static final String SWT_ACC_TYPENAME
See Also:
Constant Field Values

childId_self

public static int childId_self

highLightEnabled

protected static boolean highLightEnabled

accRef

protected int accRef

hwnd

protected int hwnd

childId

protected int childId

element

protected Object element

indexInParent

protected int indexInParent
Constructor Detail

MsaaAccessible

public MsaaAccessible(int hwnd,
                      int childID)
wrap the given object as an ACTF IAccessibleElement. The ACTF engine will invoke this constructor using a registered adaptor factory. Clients do not typically call this constructor.

Note: To create a MsaaAccessible from a handle for an SWT control, use a child id of ACC.CHILDID_SELF.

Parameters:
hwnd - - window handle for an SWT control
childID - - child ID (if any)

MsaaAccessible

public MsaaAccessible(Object elem)
wrap the given object as a ACTF IAccessibleElement. The ACTF engine will invoke this constructor using a registered adaptor factory. Clients do not typically call this constructor.

Currently, supported controls include:

Parameters:
elem -

MsaaAccessible

public MsaaAccessible(Point location)
create an MsaaAccessible element by utilizing the MSAA function AccessibleObjectFromPoint.

Parameters:
location - - any location on the current display device

MsaaAccessible

public MsaaAccessible(int ref)
create a MsaaAccessible from an IAccessible pointer.

Parameters:
ref - - pointer value
Method Detail

element

public Object element()
get the element associated with this accessible element

Specified by:
element in interface IAccessibleElement
Returns:
original element associated with this accessible or null if this object was not initialized in such a way that the original element is available

internalRef

protected int internalRef()
used by native code only. Clients should not call directly.

Returns:
ptr address for native object

getAccessibleAddress

public int getAccessibleAddress()

internalGetAddress

protected int internalGetAddress()

getWindowHandle

public int getWindowHandle()

getWindowHandleAsHex

public String getWindowHandleAsHex()
get the handle value as a hex string

Returns:
handle value as a hex string

getChildId

public int getChildId()
get the child ID for this MsaaAccessible, if any. Child IDs are associated with "simple" (i.e. non-IAccessible) children starting at 0. The child ID for a control (rather than any of its children) is ACC.CHILDID_SELF

Returns:
child ID

checkIsValid

public void checkIsValid()
                  throws InvalidComponentException
tests whether or not this MsaaAccessible is in a valid state. Validity consists of:

Specified by:
checkIsValid in interface IAccessibleElement
Throws:
InvalidComponentException

isDisposed

protected boolean isDisposed(Object control)

equals

public boolean equals(Object other)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

finalize

protected void finalize()
                 throws Throwable
Overrides:
finalize in class Object
Throws:
Throwable

toString

public String toString()
Overrides:
toString in class Object

initFromHwnd

protected void initFromHwnd(int hwnd,
                            int childID)

initFromPoint

protected void initFromPoint(int x,
                             int y)

initFromHtmlElement

protected void initFromHtmlElement(int htmlElemRef)

internalGetWindowHandle

protected int internalGetWindowHandle()

internalGetChildId

protected int internalGetChildId()

internalInitFromHwnd

protected static int internalInitFromHwnd(int hwnd,
                                          int childID)

internalInitFromHtmlElement

protected static int internalInitFromHtmlElement(int htmlElemRef)

internalInitFromPoint

protected static int internalInitFromPoint(int x,
                                           int y)

dispose

protected void dispose()
                throws InvalidComponentException
dispose the native resources

Throws:
InvalidComponentException

internalDispose

protected void internalDispose()

getClassNameFromHwnd

public static String getClassNameFromHwnd(int hwnd)
gets the class name for the given handle

Parameters:
hwnd - - window handle
Returns:
name of class

internalGetClassNameFromHwnd

protected static String internalGetClassNameFromHwnd(int hwnd)

getAccessibleParent

public IAccessibleElement getAccessibleParent()
                                       throws InvalidComponentException
returns the parent accessible object.

Specified by:
getAccessibleParent in interface IAccessibleElement
Returns:
parent accessible element or null if no parent for this element exists
Throws:
InvalidComponentException

internalGetAccessibleParent

protected int internalGetAccessibleParent()

getAccessibleChildCount

public int getAccessibleChildCount()
                            throws InvalidComponentException
return the number of children. Note that children include either MsaaAccessible objects that represent MsaaAccessible wrappers of IAccessible pointers or MsaaAccessible objects that wrap "simple" children, children that share their properties with their IAccessible parent.

Specified by:
getAccessibleChildCount in interface IAccessibleElement
Returns:
number of child MsaaAccessible objects
Throws:
InvalidComponentException

internalGetAccessibleChildCount

protected int internalGetAccessibleChildCount()

getAccessibleChild

public IAccessibleElement getAccessibleChild(int index)
                                      throws InvalidComponentException
return the accessible that has the given index in its parent. Note that this is not the same value as its childID, though children are typically numbered consecutively starting with 0.

Parameters:
index - index of desired child in parent
Returns:
child with the given index or null if the index is invalid
Throws:
InvalidComponentException

internalGetAccessibleChild

protected int internalGetAccessibleChild(int childID)

getAccessibleIndexInParent

public int getAccessibleIndexInParent()
                               throws InvalidComponentException
retreave the index of this accessible within its parent accessible

Specified by:
getAccessibleIndexInParent in interface IAccessibleElement
Returns:
index of this accessible in its parent or -1 if not available
Throws:
InvalidComponentException

getAccessibleChildren

public IAccessibleElement[] getAccessibleChildren()
                                           throws InvalidComponentException
return all of the children of this MsaaAccessible. Note that children include either MsaaAccessible objects that represent MsaaAccessible wrappers of IAccessible pointers or MsaaAccessible objects that wrap "simple" children, children that share their properties with their IAccessible parent.

Specified by:
getAccessibleChildren in interface IAccessibleElement
Returns:
children of this MsaaAccessible
Throws:
InvalidComponentException

internalGetAccessibleChildren

protected int[] internalGetAccessibleChildren()

isSimpleChild

protected boolean isSimpleChild()
returns whether or not this MsaaAccessible is a simple child. Simple children obtain their properties from their parent IAccessible object. The parent IAccessible object has a child ID of ACC.CHILDID_SELF.

Returns:
true if this is a simple child, false otherwise

hasFocus

public boolean hasFocus()
                 throws InvalidComponentException
returns whether the accessible object has the keyboard focus

Returns:
whether or not this object has keyboard focus
Throws:
InvalidComponentException

internalHasFocus

protected boolean internalHasFocus()

getAccessibleName

public String getAccessibleName()
                         throws InvalidComponentException
return the name or short description of this element

Specified by:
getAccessibleName in interface IAccessibleElement
Returns:
name or an empty string if no name is provided
Throws:
InvalidComponentException

internalGetAccessibleName

protected String internalGetAccessibleName()

getAccessibleValue

public Object getAccessibleValue()
                          throws InvalidComponentException
return the value (e.g. of a scroll bar or combo)

Specified by:
getAccessibleValue in interface IAccessibleElement
Returns:
value or an empty string if no value is provided
Throws:
InvalidComponentException

internalGetAccessibleValue

protected String internalGetAccessibleValue()

getAccessibleHelp

public String getAccessibleHelp()
                         throws InvalidComponentException
return help info (usually a tool tip)

Returns:
help or "" if no help is provided
Throws:
InvalidComponentException

internalGetAccessibleHelp

protected String internalGetAccessibleHelp()

getAccessibleKeyboardShortcut

public String getAccessibleKeyboardShortcut()
                                     throws InvalidComponentException
return the keyboard shortcut or mnemonic

Specified by:
getAccessibleKeyboardShortcut in interface IAccessibleElement
Returns:
keyboard shortcut or an empty string if no shortcut is provided
Throws:
InvalidComponentException

internalGetAccessibleKeyboardShortcut

protected String internalGetAccessibleKeyboardShortcut()

getAccessibleAction

public Object getAccessibleAction()
                           throws InvalidComponentException
return the default action

Specified by:
getAccessibleAction in interface IAccessibleElement
Returns:
default action or null if no default action is provided
Throws:
InvalidComponentException

internalGetAccessibleAction

protected String internalGetAccessibleAction()

getAccessibleDescription

public String getAccessibleDescription()
                                throws InvalidComponentException
return description or use of control

Specified by:
getAccessibleDescription in interface IAccessibleElement
Returns:
description of control or an empty string if no description is provided
Throws:
InvalidComponentException

internalGetAccessibleDescription

protected String internalGetAccessibleDescription()

getAccessibleRole

public String getAccessibleRole()
                         throws InvalidComponentException
return role or function of control.

Note: All attempts will be made to return one of the pre-defined role constants in AccessibleConstants. Should the role be unknown or not match one of the pre-defined constants, the original role string from the underlying accessibility model will be returned.

Specified by:
getAccessibleRole in interface IAccessibleElement
Returns:
role of control or an empty string if no role is provided
Throws:
InvalidComponentException
See Also:
AccessibleConstants

internalGetAccessibleRoleAsInt

protected int internalGetAccessibleRoleAsInt()

internalGetAccessibleRole

protected String internalGetAccessibleRole()

getAccessibleState

public Set getAccessibleState()
                       throws InvalidComponentException
return the state of the control. Note that the returned string may contain several states separated by commas.

Note: All attempts will be made to return one of the pre-defined state constants in AccessibleConstants. Should the state be unknown or not match one of the pre-defined constants, the original state from the underlying accessibility model will be returned.

Specified by:
getAccessibleState in interface IAccessibleElement
Returns:
state of control or an empty set if no state is provided
Throws:
InvalidComponentException
See Also:
AccessibleConstants

internalGetAccessibleState

protected int internalGetAccessibleState()

getAccessibleSelection

public IAccessibleElement[] getAccessibleSelection()
                                            throws InvalidComponentException
get the list of selected accessibles. Currently this method will only return a single selected item, although MSAA supports multiple selection in some controls. If a control supports multiple selection and multiple selections are present, this method will return an empty array.

Specified by:
getAccessibleSelection in interface IAccessibleElement
Returns:
selections or empty array if no selection
Throws:
InvalidComponentException

internalGetAccessibleSelection

protected int[] internalGetAccessibleSelection()

getAccessibleLocation

public Rectangle getAccessibleLocation()
                                throws InvalidComponentException
Gets the bounds of this object in the form of a Rectangle object. The bounds specify this object's width, height, and location relative to its parent.

Specified by:
getAccessibleLocation in interface IAccessibleElement
Returns:
A rectangle indicating this component's bounds; null if this object is not on the screen.
Throws:
InvalidComponentException

internalGetAccessibleLocation

protected Rectangle internalGetAccessibleLocation()

drawRectangle

public boolean drawRectangle()

internalDrawRectangle

protected boolean internalDrawRectangle()

eraseRectangle

public boolean eraseRectangle(Rectangle drawRef)

eraseDesktop

public static boolean eraseDesktop()

internalEraseDesktop

protected static boolean internalEraseDesktop()

internalEraseRectangle

protected boolean internalEraseRectangle(int left,
                                         int top,
                                         int right,
                                         int bottom)

isHighlightEnabled

public static boolean isHighlightEnabled()

setHighlightEnabled

public static void setHighlightEnabled(boolean val)

testAndConvertToIA2

public MsaaAccessible testAndConvertToIA2(MsaaAccessible acc)
                                   throws Exception
Throws:
Exception

doDefaultAction

public boolean doDefaultAction()
                        throws InvalidComponentException
Throws:
InvalidComponentException

internalDoDefaultAction

protected boolean internalDoDefaultAction()

getAccessibleHelpTopic

public String getAccessibleHelpTopic()
                              throws InvalidComponentException
Throws:
InvalidComponentException

internalGetAccessibleHelpTopic

protected String internalGetAccessibleHelpTopic()

select

public boolean select(int flag)
               throws InvalidComponentException
Throws:
InvalidComponentException

internalSelect

protected boolean internalSelect(int flag)