Skip to main content

Eclipse introduces IAccessible2 support

Susann Keohane, Brian Cragun, IBM

Introduction

IBM has always been a leader in the advancement of accessibility standards. The company, influenced by earlier collaborative work with Sun® Microsystems on Java® Accessibility, developed IAccessible2 (IA2) to make Open Document Format (ODF) accessible in Lotus® Symphony™ and to fill gaps in Microsoft® Active Accessibility (MSAA) programming interface. IBM donated IAccessible2 to the Free Standards Group which was later merged into the Linux Foundation.

IA2 is an Application Programming Interface (API) that addresses access to features found in documents such as rich text editing, tables, hyperlinks, actions and relationships between document elements. It exposes additional roles and states not provided in the original MSAA and it enables applications to provide more information to assistive technologies (ATs), in turn enabling AT users to gain a fuller understanding of content.

Recently, Eclipse incorporated greater support for IA2, making it easier for developers to create applications that provide richer and more complete information to assistive technologies.

The enhancements in Eclipse 3.6 and 3.7 focus on five functional areas in which there was previously no support: rich text, relations, tables, values and actions. Using these enhancements, developers can create applications for the desktop that provide full function accessibility for users.

And, now for the technical stuff…

Eclipse developers will not have to write to the IA2 API directly. Instead, IA2 implementation may be added to their existing MSAA-enabled applications using Eclipse. Eclipse encapsulates MSAA and IA2 interfaces in object-oriented classes with methods that can be invoked in Java. Eclipse handles the proxy work so that developers can define and set attribute values that are needed in order to support richer functionality.

What Eclipse improvements provide to developers

In Eclipse 3.6 and 3.7, the Standard Widget Toolkit (SWT) provides a new API to support the IA2 standard with the remaining IA2 coverage available in Eclipse 3.7. Eclipse provides accessibility through the package org.eclipse.swt.accessibility. These classes and interfaces encapsulate the IA2 classes and interfaces, allowing Eclipse developers to code to Java classes, set up listeners for related events, and handle accessibility requests in a platform independent manner.

Most of the accessibility support is built right in to the SWT widgets; therefore, in many cases a developer only has to use the widgets correctly to take advantage of the full spectrum of MSAA and IA2 capabilities.

Custom widgets and the few widgets without a corresponding accessible native widget need to add their own accessibility.  For example, the SWT table is only a thin wrapper of a native table widget, which is limited to MSAA support. Thus, developers will need to create their own table class and add the SWT methods (which use IA2) to provide full accessibility support.  Eclipse 3.6 and 3.7 provide the classes and methods necessary to add the needed capability to custom widgets and widgets with insufficient native support.

Eclipse support of IA2 can be used today

Eclipse 3.6 and 3.7 are available now from www.eclipse.org (link resides outside of ibm.com). This article presents two useful coding techniques using Eclipse 3.6.

Using relations to associate labels with controls

Previously, Eclipse had no way to explicitly associate a label with a field. Label association was made based on the creation order, the widget being associated with the label created immediately previous. Developers were required to create the label and then the associated widget, or to directly change the order in the internal control hierarchy tree. 

Now, associations can be made between controls to provide a programmatic structural relationship between two elements. This is useful when making logical controls from groups, or pairings that are not built in. The assistive technology will read the text and content of the associated element. It is important to test the exact behavior of the assistive technology you are supporting.

The following is a code fragment showing the association of a label for a control. It is taken from Snippet350.java (link resides outside of ibm.com) available from the Eclipse.org SWT Snippets (link resides outside of ibm.com) page.

Label nameLabel = newLabel(shell, SWT.NONE);
nameLabel.setText("Name:");
Text nameText = newText(shell, SWT.BORDER);
nameText.setLayoutData(newGridData(GridData.FILL_HORIZONTAL));
Accessible accNameLabel = nameLabel.getAccessible();
Accessible accNameText = nameText.getAccessible();
accNameLabel.addRelation(ACC.RELATION_LABEL_FOR, accNameText);
accNameText.addRelation(ACC.RELATION_LABELLED_BY, accNameLabel);

Here, a label and a text field are created. The accessible objects for the label and field are retrieved, and then each is added as the label for and labeled by element, respectively.

Using relations to provide live updates

Relations can also be used to provide notifications to assistive technology when information changes in another part of the screen.

Snippet340.java (link resides outside of ibm.com) provides an example of using ACC.RELATION_DESCRIBED_BY to associate a region of live text with a field so that the live text is read every time the value of the field is changed. The following code fragment illustrates the live label being associated with a textField.

textField.getAccessible().addRelation(ACC.RELATION_DESCRIBED_BY,
liveLabel.getAccessible());

Then, a text listener is created so that whenever the text is changed, the associated label is updated.

textField.addModifyListener(new ModifyListener() {
  public void modifyText(ModifyEvent e) {
    String textValue = textField.getText();
    String message = textValue + " is not valid input.";
    try {
      int value = Integer.parseInt(textValue);
      switch (value) {
        case 1: message = "One for the money,"; break;
        case 2: message = "Two for the show,"; break;
        case 3: message = "Three to get ready,"; break;
        case 4: message = "And four to go!"; break
      }
    } catch (NumberFormatException ex) {}
    liveLabel.setText(message);
    textField.getAccessible().sendEvent(ACC.EVENT_DESCRIPTION_CHANGED, null);
    textField.setSelection(0, textField.getCharCount());
  }
});

Developer's inspection tool

AccProbe (link resides outside of ibm.com) is an important accessibility test and debug tool for developers who leverage IA2 capabilities in their Eclipse application. AccProbe uses IAccessible2 platform services to assist developers in discovering and correcting code problems. AccProbe can also serve as an event monitor for tracking the events fired by these accessible objects. Currently, it's the only tool available that provides both the MSAA and IA2 hierarchy view of accessible objects and their properties.

Summary

IAccessible2 provides essential capabilities to make desktop applications accessible. Eclipse-based applications can take advantage of IA2 through SWT. Developers and their teams can use the enhancements today to solve some common challenges of Eclipse accessibility enablement.

Resources

Acknowledgements

The authors are appreciative of Carolyn MacLeod for sharing expertise and source materials.

About the authors

Brian Cragun is a Senior Accessibility Consultant with IBM's Human Ability and Accessibility Center. Brian received his undergraduate degree in Computer Science from Utah State University in 1982 and his Masters in Manufacturing Systems Engineering from University of Wisconsin – Madison.

Susann Keohane joined the IBM Human Ability and Accessibility Center's CI 162 technical consulting team in 2006. Her primary role is to provide accessibility guidance in the areas of documentation, software applications, cloud computing and mobile accessibility. She received a BS in Computer Engineering from the University of Florida and earned an MS in Software Engineering from the University of Texas at Austin.

Trademarks

Eclipse is a trademark of Eclipse Foundation, Inc.

IBM, the IBM logo, Lotus and Symphony are trademarks or registered trademarks of IBM in the United States, other countries, or both.

Microsoft is a registered trademark of Microsoft Corporation in the United States and other countries.

Sun Microsystems and Java are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.

Join the conversation