/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
import javax.accessibility.*;
/*
* The AccessibleHTML class provide information about the contents
* of a HTML document to assistive technologies.
*
* @author Lynn Monsanto
*/
/**
* The editor.
*/
/**
* Current model.
*/
/**
* DocumentListener installed on the current model.
*/
/**
* PropertyChangeListener installed on the editor
*/
/**
* The root ElementInfo for the document
*/
/*
* The root accessible context for the document
*/
propChangeListener = new PropertyChangeHandler();
docListener = new DocumentHandler();
}
/**
* Sets the document.
*/
}
}
if (rootElementInfo != null) {
rootElementInfo.invalidate(false);
}
buildInfo();
}
else {
}
}
}
/**
* Returns the Document currently presenting information for.
*/
return model;
}
/**
* Returns the JEditorPane providing information for.
*/
return editor;
}
/**
* Returns the ElementInfo representing the root Element.
*/
return rootElementInfo;
}
/**
* Returns the root <code>View</code> associated with the current text
* component.
*/
}
/**
* Returns the bounds the root View will be rendered in.
*/
return alloc;
}
return null;
}
/**
* If possible acquires a lock on the Document. If a lock has been
* obtained a key will be retured that should be passed to
* <code>unlock</code>.
*/
if (document instanceof AbstractDocument) {
return document;
}
return null;
}
/**
* Releases a lock previously obtained via <code>lock</code>.
*/
}
}
/**
* Rebuilds the information from the current info.
*/
private void buildInfo() {
try {
} finally {
}
}
/*
* Create an ElementInfo subclass based on the passed in Element.
*/
return new IconElementInfo(e, parent);
}
return new TextElementInfo(e, parent);
}
return new TableElementInfo(e, parent);
}
}
return null;
}
/**
* Returns the root AccessibleContext for the document
*/
if (rootHTMLAccessibleContext == null) {
}
return rootHTMLAccessibleContext;
}
/*
* The roow AccessibleContext for the document
*/
super(elementInfo);
}
/**
* Gets the accessibleName property of this object. The accessibleName
* property of an object is a localized String that designates the purpose
* of the object. For example, the accessibleName property of a label
* or button might be the text of the label or button itself. In the
* case of an object that doesn't display its name, the accessibleName
* should still be set. For example, in the case of a text field used
* to enter the name of a city, the accessibleName for the en_US locale
* could be 'city.'
*
* @return the localized name of the object; null if this
* object does not have a name
*
* @see #setAccessibleName
*/
} else {
return null;
}
}
/**
* Gets the accessibleDescription property of this object. If this
* property isn't set, returns the content type of this
*
* @return the localized description of the object; <code>null</code>
* if this object does not have a description
*
* @see #setAccessibleName
*/
return editor.getContentType();
}
/**
* Gets the role of this object. The role of the object is the generic
* purpose or use of the class of this object. For example, the role
* of a push button is AccessibleRole.PUSH_BUTTON. The roles in
* AccessibleRole are provided so component developers can pick from
* a set of predefined roles. This enables assistive technologies to
* provide a consistent interface to various tweaked subclasses of
* components (e.g., use AccessibleRole.PUSH_BUTTON for all components
* that act like a push button) as well as distinguish between sublasses
* that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes
* and AccessibleRole.RADIO_BUTTON for radio buttons).
* <p>Note that the AccessibleRole class is also extensible, so
* custom component developers can define their own AccessibleRole's
* if the set of predefined roles is inadequate.
*
* @return an instance of AccessibleRole describing the role of the object
* @see AccessibleRole
*/
return AccessibleRole.TEXT;
}
}
/*
* Base AccessibleContext class for HTML elements
*/
implements Accessible, AccessibleComponent {
this.elementInfo = elementInfo;
}
// begin AccessibleContext implementation ...
return this;
}
/**
* Gets the state set of this object.
*
* @return an instance of AccessibleStateSet describing the states
* of the object
* @see AccessibleStateSet
*/
}
if (comp instanceof JTextComponent &&
}
}
}
return states;
}
/**
* Gets the 0-based index of this object in its accessible parent.
*
* @return the 0-based index of this object in its parent; -1 if this
* object does not have an accessible parent.
*
* @see #getAccessibleParent
* @see #getAccessibleChildrenCount
* @see #getAccessibleChild
*/
public int getAccessibleIndexInParent() {
return elementInfo.getIndexInParent();
}
/**
* Returns the number of accessible children of the object.
*
* @return the number of accessible children of the object.
*/
public int getAccessibleChildrenCount() {
return elementInfo.getChildCount();
}
/**
* Returns the specified Accessible child of the object. The Accessible
* children of an Accessible object are zero-based, so the first child
* of an Accessible child is at index 0, the second child is at index 1,
* and so on.
*
* @param i zero-based index of child
* @return the Accessible child of the object
* @see #getAccessibleChildrenCount
*/
return (Accessible)childInfo;
} else {
return null;
}
}
/**
* Gets the locale of the component. If the component does not have a
* locale, then the locale of its parent is returned.
*
* @return this component's locale. If this component does not have
* a locale, the locale of its parent is returned.
*
* @exception IllegalComponentStateException
* If the Component does not have its own locale and has not yet been
* added to a containment hierarchy such that the locale can be
* determined from the containing parent.
*/
}
// ... end AccessibleContext implementation
// begin AccessibleComponent implementation ...
return this;
}
/**
* Gets the background color of this object.
*
* @return the background color, if supported, of the object;
* otherwise, null
* @see #setBackground
*/
return getTextComponent().getBackground();
}
/**
* Sets the background color of this object.
*
* @param c the new Color for the background
* @see #setBackground
*/
}
/**
* Gets the foreground color of this object.
*
* @return the foreground color, if supported, of the object;
* otherwise, null
* @see #setForeground
*/
return getTextComponent().getForeground();
}
/**
* Sets the foreground color of this object.
*
* @param c the new Color for the foreground
* @see #getForeground
*/
}
/**
* Gets the Cursor of this object.
*
* @return the Cursor, if supported, of the object; otherwise, null
* @see #setCursor
*/
return getTextComponent().getCursor();
}
/**
* Sets the Cursor of this object.
*
* @param cursor the new Cursor for the object
* @see #getCursor
*/
}
/**
* Gets the Font of this object.
*
* @return the Font,if supported, for the object; otherwise, null
* @see #setFont
*/
return getTextComponent().getFont();
}
/**
* Sets the Font of this object.
*
* @param f the new Font for the object
* @see #getFont
*/
getTextComponent().setFont(f);
}
/**
* Gets the FontMetrics of this object.
*
* @param f the Font
* @return the FontMetrics, if supported, the object; otherwise, null
* @see #getFont
*/
return getTextComponent().getFontMetrics(f);
}
/**
* Determines if the object is enabled. Objects that are enabled
* will also have the AccessibleState.ENABLED state set in their
* AccessibleStateSets.
*
* @return true if object is enabled; otherwise, false
* @see #setEnabled
* @see AccessibleContext#getAccessibleStateSet
* @see AccessibleState#ENABLED
* @see AccessibleStateSet
*/
public boolean isEnabled() {
return getTextComponent().isEnabled();
}
/**
* Sets the enabled state of the object.
*
* @param b if true, enables this object; otherwise, disables it
* @see #isEnabled
*/
public void setEnabled(boolean b) {
getTextComponent().setEnabled(b);
}
/**
* Determines if the object is visible. Note: this means that the
* object intends to be visible; however, it may not be
* showing on the screen because one of the objects that this object
* is contained by is currently not visible. To determine if an object
* is showing on the screen, use isShowing().
* <p>Objects that are visible will also have the
* AccessibleState.VISIBLE state set in their AccessibleStateSets.
*
* @return true if object is visible; otherwise, false
* @see #setVisible
* @see AccessibleContext#getAccessibleStateSet
* @see AccessibleState#VISIBLE
* @see AccessibleStateSet
*/
public boolean isVisible() {
return getTextComponent().isVisible();
}
/**
* Sets the visible state of the object.
*
* @param b if true, shows this object; otherwise, hides it
* @see #isVisible
*/
public void setVisible(boolean b) {
getTextComponent().setVisible(b);
}
/**
* Determines if the object is showing. This is determined by checking
* the visibility of the object and its ancestors.
* Note: this
* will return true even if the object is obscured by another (for
* example, it is underneath a menu that was pulled down).
*
* @return true if object is showing; otherwise, false
*/
public boolean isShowing() {
return getTextComponent().isShowing();
}
/**
* Checks whether the specified point is within this object's bounds,
* where the point's x and y coordinates are defined to be relative
* to the coordinate system of the object.
*
* @param p the Point relative to the coordinate system of the object
* @return true if object contains Point; otherwise false
* @see #getBounds
*/
if (r != null) {
return r.contains(p.x, p.y);
} else {
return false;
}
}
/**
* Returns the location of the object on the screen.
*
* @return the location of the object on screen; null if this object
* is not on the screen
* @see #getBounds
* @see #getLocation
*/
if (r != null) {
return new Point(editorLocation.x + r.x,
editorLocation.y + r.y);
} else {
return null;
}
}
/**
* Gets the location of the object relative to the parent in the form
* of a point specifying the object's top-left corner in the screen's
* coordinate space.
*
* @return An instance of Point representing the top-left corner of the
* object's bounds in the coordinate space of the screen; null if
* this object or its parent are not on the screen
* @see #getBounds
* @see #getLocationOnScreen
*/
if (r != null) {
return new Point(r.x, r.y);
} else {
return null;
}
}
/**
* Sets the location of the object relative to the parent.
* @param p the new position for the top-left corner
* @see #getLocation
*/
}
/**
* 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.
*
* @return A rectangle indicating this component's bounds; null if
* this object is not on the screen.
* @see #contains
*/
return elementInfo.getBounds();
}
/**
* Sets 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.
*
* @param r rectangle indicating this component's bounds
* @see #getBounds
*/
}
/**
* Returns the size of this object in the form of a Dimension object.
* The height field of the Dimension object contains this object's
* height, and the width field of the Dimension object contains this
* object's width.
*
* @return A Dimension object that indicates the size of this component;
* null if this object is not on the screen
* @see #setSize
*/
if (r != null) {
} else {
return null;
}
}
/**
* Resizes this object so that it has width and height.
*
* @param d The dimension specifying the new size of the object.
* @see #getSize
*/
}
/**
* Returns the Accessible child, if one exists, contained at the local
* coordinate Point.
*
* @param p The point relative to the coordinate system of this object.
* @return the Accessible, if it exists, at the specified location;
* otherwise null
*/
if (innerMostElement instanceof Accessible) {
return (Accessible)innerMostElement;
} else {
return null;
}
}
return null;
}
return elementInfo;
} else {
if (elementInfo instanceof TableElementInfo) {
// Handle table caption as a special case since it's the
// only table child that is not a table row.
if (captionInfo != null) {
return captionInfo;
}
}
}
{
return retValue;
}
}
}
return null;
}
/**
* Returns whether this object can accept focus or not. Objects that
* can accept focus will also have the AccessibleState.FOCUSABLE state
* set in their AccessibleStateSets.
*
* @return true if object can accept focus; otherwise false
* @see AccessibleContext#getAccessibleStateSet
* @see AccessibleState#FOCUSABLE
* @see AccessibleState#FOCUSED
* @see AccessibleStateSet
*/
public boolean isFocusTraversable() {
if (comp instanceof JTextComponent) {
return true;
}
}
return false;
}
/**
* Requests focus for this object. If this object cannot accept focus,
* nothing will happen. Otherwise, the object will attempt to take
* focus.
* @see #isFocusTraversable
*/
public void requestFocus() {
// TIGER - 4856191
if (! isFocusTraversable()) {
return;
}
if (comp instanceof JTextComponent) {
try {
if (elementInfo.validateIfNecessary()) {
// set the caret position to the start of this component
// fire a AccessibleState.FOCUSED property change event
}
} catch (IllegalArgumentException e) {
// don't fire property change event
}
}
}
/**
* Adds the specified focus listener to receive focus events from this
* component.
*
* @param l the focus listener
* @see #removeFocusListener
*/
}
/**
* Removes the specified focus listener so it no longer receives focus
* events from this component.
*
* @param l the focus listener
* @see #addFocusListener
*/
}
// ... end AccessibleComponent implementation
} // ... end HTMLAccessibleContext
/*
* ElementInfo for text
*/
}
// begin AccessibleText implementation ...
if (accessibleContext == null) {
accessibleContext = new TextAccessibleContext(this);
}
return accessibleContext;
}
/*
* AccessibleContext for text elements
*/
implements AccessibleText {
super(elementInfo);
}
return this;
}
/**
* Gets the accessibleName property of this object. The accessibleName
* property of an object is a localized String that designates the purpose
* of the object. For example, the accessibleName property of a label
* or button might be the text of the label or button itself. In the
* case of an object that doesn't display its name, the accessibleName
* should still be set. For example, in the case of a text field used
* to enter the name of a city, the accessibleName for the en_US locale
* could be 'city.'
*
* @return the localized name of the object; null if this
* object does not have a name
*
* @see #setAccessibleName
*/
} else {
return null;
}
}
/**
* Gets the accessibleDescription property of this object. If this
* property isn't set, returns the content type of this
*
* @return the localized description of the object; <code>null</code>
* if this object does not have a description
*
* @see #setAccessibleName
*/
return editor.getContentType();
}
/**
* Gets the role of this object. The role of the object is the generic
* purpose or use of the class of this object. For example, the role
* of a push button is AccessibleRole.PUSH_BUTTON. The roles in
* AccessibleRole are provided so component developers can pick from
* a set of predefined roles. This enables assistive technologies to
* provide a consistent interface to various tweaked subclasses of
* components (e.g., use AccessibleRole.PUSH_BUTTON for all components
* that act like a push button) as well as distinguish between sublasses
* that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes
* and AccessibleRole.RADIO_BUTTON for radio buttons).
* <p>Note that the AccessibleRole class is also extensible, so
* custom component developers can define their own AccessibleRole's
* if the set of predefined roles is inadequate.
*
* @return an instance of AccessibleRole describing the role of the object
* @see AccessibleRole
*/
return AccessibleRole.TEXT;
}
/**
* Given a point in local coordinates, return the zero-based index
* of the character under that Point. If the point is invalid,
* this method returns -1.
*
* @param p the Point in local coordinates
* @return the zero-based index of the character under Point p; if
* Point is invalid returns -1.
*/
if (v != null) {
return v.viewToModel(p.x, p.y, getBounds());
} else {
return -1;
}
}
/**
* Determine the bounding box of the character at the given
* index into the string. The bounds are returned in local
* coordinates. If the index is invalid an empty rectangle is
* returned.
*
* @param i the index into the String
* @return the screen coordinates of the character's the bounding box,
* if index is invalid returns an empty rectangle.
*/
try {
} catch (BadLocationException e) {
return null;
}
}
/**
* Return the number of characters (valid indicies)
*
* @return the number of characters
*/
public int getCharCount() {
if (validateIfNecessary()) {
}
return 0;
}
/**
* Return the zero-based offset of the caret.
*
* Note: That to the right of the caret will have the same index
* value as the offset (the caret is between two characters).
* @return the zero-based offset of the caret.
*/
public int getCaretPosition() {
if (v == null) {
return -1;
}
Container c = v.getContainer();
if (c == null) {
return -1;
}
if (c instanceof JTextComponent) {
return ((JTextComponent)c).getCaretPosition();
} else {
return -1;
}
}
/**
* IndexedSegment extends Segment adding the offset into the
* the model the <code>Segment</code> was asked for.
*/
/**
* Offset into the model that the position represents.
*/
public int modelOffset;
}
}
}
}
/**
* Gets the word, sentence, or character at <code>index</code>.
* If <code>direction</code> is non-null this will find the
*/
if (model instanceof AbstractDocument) {
}
try {
return null;
}
switch (part) {
case AccessibleText.CHARACTER:
}
break;
case AccessibleText.WORD:
case AccessibleText.SENTENCE:
if (direction != 0) {
int next;
if (direction < 0) {
}
else {
}
}
else {
}
}
}
}
break;
default:
break;
}
} catch (BadLocationException e) {
} finally {
if (model instanceof AbstractDocument) {
}
}
return null;
}
/*
* Returns the paragraph element for the specified index.
*/
if (model instanceof PlainDocument ) {
} else if (model instanceof StyledDocument) {
} else {
}
return null;
}
return para.getParentElement();
}
}
/*
* Returns a <code>Segment</code> containing the paragraph text
* at <code>index</code>, or null if <code>index</code> isn't
* valid.
*/
throws BadLocationException {
try {
} catch (BadLocationException e) {
return null;
}
return segment;
}
return null;
}
/**
* Returns the Segment at <code>index</code> representing either
* the paragraph or sentence as identified by <code>part</code>, or
* in the model.
*/
throws BadLocationException {
return null;
}
switch (part) {
case AccessibleText.WORD:
break;
case AccessibleText.SENTENCE:
break;
default:
return null;
}
return null;
}
return null;
}
return null;
}
return seg;
}
/**
* Return the AttributeSet for a given character at a given index
*
* @param i the zero-based index into the text
* @return the AttributeSet of the character
*/
if (model instanceof StyledDocument) {
return elem.getAttributes();
}
}
return null;
}
/**
* Returns the start offset within the selected text.
* If there is no selection, but there is
* a caret, the start and end offsets will be the same.
*
* @return the index into the text of the start of the selection
*/
public int getSelectionStart() {
return editor.getSelectionStart();
}
/**
* Returns the end offset within the selected text.
* If there is no selection, but there is
* a caret, the start and end offsets will be the same.
*
* @return the index into teh text of the end of the selection
*/
public int getSelectionEnd() {
return editor.getSelectionEnd();
}
/**
* Returns the portion of the text that is selected.
*
* @return the String portion of the text that is selected
*/
return editor.getSelectedText();
}
/*
* Returns the text substring starting at the specified
* offset with the specified length.
*/
throws BadLocationException {
} else {
return null;
}
}
}
}
/*
* ElementInfo for images
*/
}
super.invalidate(first);
}
if (validateIfNecessary()) {
if (size == -1) {
size = 0;
if (v instanceof ImageView) {
}
else {
}
}
}
}
return size;
}
return 0;
}
// begin AccessibleIcon implementation ...
if (accessibleContext == null) {
accessibleContext = new IconAccessibleContext(this);
}
return accessibleContext;
}
/*
* AccessibleContext for images
*/
implements AccessibleIcon {
super(elementInfo);
}
/**
* Gets the accessibleName property of this object. The accessibleName
* property of an object is a localized String that designates the purpose
* of the object. For example, the accessibleName property of a label
* or button might be the text of the label or button itself. In the
* case of an object that doesn't display its name, the accessibleName
* should still be set. For example, in the case of a text field used
* to enter the name of a city, the accessibleName for the en_US locale
* could be 'city.'
*
* @return the localized name of the object; null if this
* object does not have a name
*
* @see #setAccessibleName
*/
return getAccessibleIconDescription();
}
/**
* Gets the accessibleDescription property of this object. If this
* property isn't set, returns the content type of this
*
* @return the localized description of the object; <code>null</code>
* if this object does not have a description
*
* @see #setAccessibleName
*/
return editor.getContentType();
}
/**
* Gets the role of this object. The role of the object is the generic
* purpose or use of the class of this object. For example, the role
* of a push button is AccessibleRole.PUSH_BUTTON. The roles in
* AccessibleRole are provided so component developers can pick from
* a set of predefined roles. This enables assistive technologies to
* provide a consistent interface to various tweaked subclasses of
* components (e.g., use AccessibleRole.PUSH_BUTTON for all components
* that act like a push button) as well as distinguish between sublasses
* that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes
* and AccessibleRole.RADIO_BUTTON for radio buttons).
* <p>Note that the AccessibleRole class is also extensible, so
* custom component developers can define their own AccessibleRole's
* if the set of predefined roles is inadequate.
*
* @return an instance of AccessibleRole describing the role of the object
* @see AccessibleRole
*/
return AccessibleRole.ICON;
}
icons[0] = this;
return icons;
}
/**
* Gets the description of the icon. This is meant to be a brief
* textual description of the object. For example, it might be
* presented to a blind user to give an indication of the purpose
* of the icon.
*
* @return the description of the icon
*/
}
/**
* Sets the description of the icon. This is meant to be a brief
* textual description of the object. For example, it might be
* presented to a blind user to give an indication of the purpose
* of the icon.
*
* @param description the description of the icon
*/
}
/**
* Gets the width of the icon
*
* @return the width of the icon.
*/
public int getAccessibleIconWidth() {
if (width == -1) {
}
return width;
}
/**
* Gets the height of the icon
*
* @return the height of the icon.
*/
public int getAccessibleIconHeight() {
if (height == -1) {
}
return height;
}
}
// ... end AccessibleIconImplementation
}
/**
* TableElementInfo encapsulates information about a HTML.Tag.TABLE.
* To make access fast it crates a grid containing the children to
* allow for access by row, column. TableElementInfo will contain
* TableRowElementInfos, which will contain TableCellElementInfos.
* Any time one of the rows or columns becomes invalid the table is
* invalidated. This is because any time one of the child attributes
* changes the size of the grid may have changed.
*/
implements Accessible {
/**
* Allocation of the table by row x column. There may be holes (eg
* > 1 will be contained multiple times in the grid.
*/
super(e, parent);
}
return caption;
}
/**
* Overriden to update the grid when validating.
*/
protected void validate() {
super.validate();
updateGrid();
}
/**
* Overriden to only alloc instances of TableRowElementInfos.
*/
// Handle captions as a special case since all other
// children are table rows.
}
}
}
/**
* Updates the grid.
*/
private void updateGrid() {
int delta = 0;
int maxCols = 0;
int rows;
int prev = 0;
for (int y = 0; y < delta; y++) {
getColumnCount(y + 2));
}
delta--;
}
// Alloc
}
// Update
}
}
/**
* Returns the TableCellElementInfo at the specified index.
*/
}
/**
* Returns the TableCellElementInfo by row and column.
*/
return grid[r][c];
}
return null;
}
/**
* Returns the rowspan of the specified entry.
*/
public int getRowExtentAt(int r, int c) {
int delta = 1;
delta++;
}
}
return 0;
}
/**
* Returns the colspan of the specified entry.
*/
public int getColumnExtentAt(int r, int c) {
int delta = 1;
delta++;
}
}
return 0;
}
/**
* Returns the number of rows in the table.
*/
public int getRowCount() {
if (validateIfNecessary()) {
}
return 0;
}
/**
* Returns the number of columns in the table.
*/
public int getColumnCount() {
}
return 0;
}
// begin AccessibleTable implementation ...
if (accessibleContext == null) {
accessibleContext = new TableAccessibleContext(this);
}
return accessibleContext;
}
/*
* AccessibleContext for tables
*/
implements AccessibleTable {
super(elementInfo);
}
/**
* Gets the accessibleName property of this object. The accessibleName
* property of an object is a localized String that designates the purpose
* of the object. For example, the accessibleName property of a label
* or button might be the text of the label or button itself. In the
* case of an object that doesn't display its name, the accessibleName
* should still be set. For example, in the case of a text field used
* to enter the name of a city, the accessibleName for the en_US locale
* could be 'city.'
*
* @return the localized name of the object; null if this
* object does not have a name
*
* @see #setAccessibleName
*/
// return the role of the object
return getAccessibleRole().toString();
}
/**
* Gets the accessibleDescription property of this object. If this
* property isn't set, returns the content type of this
*
* @return the localized description of the object; <code>null</code>
* if this object does not have a description
*
* @see #setAccessibleName
*/
return editor.getContentType();
}
/**
* Gets the role of this object. The role of the object is the generic
* purpose or use of the class of this object. For example, the role
* of a push button is AccessibleRole.PUSH_BUTTON. The roles in
* AccessibleRole are provided so component developers can pick from
* a set of predefined roles. This enables assistive technologies to
* provide a consistent interface to various tweaked subclasses of
* components (e.g., use AccessibleRole.PUSH_BUTTON for all components
* that act like a push button) as well as distinguish between sublasses
* that behave differently (e.g., AccessibleRole.CHECK_BOX for check boxes
* and AccessibleRole.RADIO_BUTTON for radio buttons).
* <p>Note that the AccessibleRole class is also extensible, so
* custom component developers can define their own AccessibleRole's
* if the set of predefined roles is inadequate.
*
* @return an instance of AccessibleRole describing the role of the object
* @see AccessibleRole
*/
return AccessibleRole.TABLE;
}
/**
* Gets the 0-based index of this object in its accessible parent.
*
* @return the 0-based index of this object in its parent; -1 if this
* object does not have an accessible parent.
*
* @see #getAccessibleParent
* @see #getAccessibleChildrenCount
* @gsee #getAccessibleChild
*/
public int getAccessibleIndexInParent() {
return elementInfo.getIndexInParent();
}
/**
* Returns the number of accessible children of the object.
*
* @return the number of accessible children of the object.
*/
public int getAccessibleChildrenCount() {
}
/**
* Returns the specified Accessible child of the object. The Accessible
* children of an Accessible object are zero-based, so the first child
* of an Accessible child is at index 0, the second child is at index 1,
* and so on.
*
* @param i zero-based index of child
* @return the Accessible child of the object
* @see #getAccessibleChildrenCount
*/
int r = i / rowCount;
int c = i % columnCount;
return null;
} else {
return getAccessibleAt(r, c);
}
}
return this;
}
/**
* Returns the caption for the table.
*
* @return the caption for the table
*/
if (captionInfo instanceof Accessible) {
return (Accessible)caption;
} else {
return null;
}
}
/**
* Sets the caption for the table.
*
* @param a the caption for the table
*/
}
/**
* Returns the summary description of the table.
*
* @return the summary description of the table
*/
return null;
}
/**
* Sets the summary description of the table
*
* @param a the summary description of the table
*/
}
/**
* Returns the number of rows in the table.
*
* @return the number of rows in the table
*/
public int getAccessibleRowCount() {
}
/**
* Returns the number of columns in the table.
*
* @return the number of columns in the table
*/
public int getAccessibleColumnCount() {
}
/**
* Returns the Accessible at a specified row and column
* in the table.
*
* @param r zero-based row of the table
* @param c zero-based column of the table
* @return the Accessible at the specified row and column
*/
return cellInfo.getAccessible();
} else {
return null;
}
}
/**
* Returns the number of rows occupied by the Accessible at
* a specified row and column in the table.
*
* @return the number of rows occupied by the Accessible at a
* given specified (row, column)
*/
public int getAccessibleRowExtentAt(int r, int c) {
}
/**
* Returns the number of columns occupied by the Accessible at
* a specified row and column in the table.
*
* @return the number of columns occupied by the Accessible at a
* given specified row and column
*/
public int getAccessibleColumnExtentAt(int r, int c) {
}
/**
* Returns the row headers as an AccessibleTable.
*
* @return an AccessibleTable representing the row
* headers
*/
return rowHeadersTable;
}
/**
* Sets the row headers.
*
* @param table an AccessibleTable representing the
* row headers
*/
}
/**
* Returns the column headers as an AccessibleTable.
*
* @return an AccessibleTable representing the column
* headers
*/
return null;
}
/**
* Sets the column headers.
*
* @param table an AccessibleTable representing the
* column headers
*/
}
/**
* Returns the description of the specified row in the table.
*
* @param r zero-based row of the table
* @return the description of the row
*/
return null;
}
/**
* Sets the description text of the specified row of the table.
*
* @param r zero-based row of the table
* @param a the description of the row
*/
}
/**
* Returns the description text of the specified column in the table.
*
* @param c zero-based column of the table
* @return the text description of the column
*/
return null;
}
/**
* Sets the description text of the specified column in the table.
*
* @param c zero-based column of the table
* @param a the text description of the column
*/
}
/**
* Returns a boolean value indicating whether the accessible at
* a specified row and column is selected.
*
* @param r zero-based row of the table
* @param c zero-based column of the table
* @return the boolean value true if the accessible at the
* row and column is selected. Otherwise, the boolean value
* false
*/
public boolean isAccessibleSelected(int r, int c) {
if (validateIfNecessary()) {
if (r < 0 || r >= getAccessibleRowCount() ||
c < 0 || c >= getAccessibleColumnCount()) {
return false;
}
}
}
return false;
}
/**
* Returns a boolean value indicating whether the specified row
* is selected.
*
* @param r zero-based row of the table
* @return the boolean value true if the specified row is selected.
* Otherwise, false.
*/
public boolean isAccessibleRowSelected(int r) {
if (validateIfNecessary()) {
if (r < 0 || r >= getAccessibleRowCount()) {
return false;
}
int nColumns = getAccessibleColumnCount();
return false;
}
return false;
}
}
return false;
}
/**
* Returns a boolean value indicating whether the specified column
* is selected.
*
* @param c zero-based column of the table
* @return the boolean value true if the specified column is selected.
* Otherwise, false.
*/
public boolean isAccessibleColumnSelected(int c) {
if (validateIfNecessary()) {
if (c < 0 || c >= getAccessibleColumnCount()) {
return false;
}
int nRows = getAccessibleRowCount();
return false;
}
return false;
}
}
return false;
}
/**
* Returns the selected rows in a table.
*
* @return an array of selected rows where each element is a
* zero-based row of the table
*/
public int [] getSelectedAccessibleRows() {
if (validateIfNecessary()) {
int nRows = getAccessibleRowCount();
for (int i = 0; i < nRows; i++) {
if (isAccessibleRowSelected(i)) {
}
}
}
return retval;
}
return new int[0];
}
/**
* Returns the selected columns in a table.
*
* @return an array of selected columns where each element is a
* zero-based column of the table
*/
public int [] getSelectedAccessibleColumns() {
if (validateIfNecessary()) {
int nColumns = getAccessibleRowCount();
for (int i = 0; i < nColumns; i++) {
if (isAccessibleColumnSelected(i)) {
}
}
}
return retval;
}
return new int[0];
}
// begin AccessibleExtendedTable implementation -------------
/**
* Returns the row number of an index in the table.
*
* @param index the zero-based index in the table
* @return the zero-based row of the table if one exists;
* otherwise -1.
*/
if (validateIfNecessary()) {
int numCells = getAccessibleColumnCount() *
return -1;
} else {
return index / getAccessibleColumnCount();
}
}
return -1;
}
/**
* Returns the column number of an index in the table.
*
* @param index the zero-based index in the table
* @return the zero-based column of the table if one exists;
* otherwise -1.
*/
if (validateIfNecessary()) {
int numCells = getAccessibleColumnCount() *
return -1;
} else {
return index % getAccessibleColumnCount();
}
}
return -1;
}
/**
* Returns the index at a row and column in the table.
*
* @param r zero-based row of the table
* @param c zero-based column of the table
* @return the zero-based index in the table if one exists;
* otherwise -1.
*/
public int getAccessibleIndex(int r, int c) {
if (validateIfNecessary()) {
if (r >= getAccessibleRowCount() ||
c >= getAccessibleColumnCount()) {
return -1;
} else {
return r * getAccessibleColumnCount() + c;
}
}
return -1;
}
/**
* Returns the row header at a row in a table.
* @param r zero-based row of the table
*
* @return a String representing the row header
* if one exists; otherwise null.
*/
if (validateIfNecessary()) {
if (cellInfo.isHeaderCell()) {
try {
v.getEndOffset() -
v.getStartOffset());
} catch (BadLocationException e) {
return null;
}
}
}
}
return null;
}
/**
* Returns the column header at a column in a table.
* @param c zero-based column of the table
*
* @return a String representing the column header
* if one exists; otherwise null.
*/
if (validateIfNecessary()) {
if (cellInfo.isHeaderCell()) {
try {
v.getEndOffset() -
v.getStartOffset());
} catch (BadLocationException e) {
return null;
}
}
}
}
return null;
}
if (rowHeadersTable == null) {
rowHeadersTable = new AccessibleHeadersTable();
}
}
// end of AccessibleExtendedTable implementation ------------
// Header information is modeled as a Hashtable of
// ArrayLists where each Hashtable entry represents
// a row containing one or more headers.
}
}
/**
* Returns the caption for the table.
*
* @return the caption for the table
*/
return null;
}
/**
* Sets the caption for the table.
*
* @param a the caption for the table
*/
}
/**
* Returns the summary description of the table.
*
* @return the summary description of the table
*/
return null;
}
/**
* Sets the summary description of the table
*
* @param a the summary description of the table
*/
}
/**
* Returns the number of rows in the table.
*
* @return the number of rows in the table
*/
public int getAccessibleRowCount() {
return rowCount;
}
/**
* Returns the number of columns in the table.
*
* @return the number of columns in the table
*/
public int getAccessibleColumnCount() {
return columnCount;
}
} else {
return null;
}
}
/**
* Returns the Accessible at a specified row and column
* in the table.
*
* @param r zero-based row of the table
* @param c zero-based column of the table
* @return the Accessible at the specified row and column
*/
if (elementInfo instanceof Accessible) {
return (Accessible)elementInfo;
} else {
return null;
}
}
/**
* Returns the number of rows occupied by the Accessible at
* a specified row and column in the table.
*
* @return the number of rows occupied by the Accessible at a
* given specified (row, column)
*/
public int getAccessibleRowExtentAt(int r, int c) {
if (elementInfo != null) {
return elementInfo.getRowCount();
} else {
return 0;
}
}
/**
* Returns the number of columns occupied by the Accessible at
* a specified row and column in the table.
*
* @return the number of columns occupied by the Accessible at a
* given specified row and column
*/
public int getAccessibleColumnExtentAt(int r, int c) {
if (elementInfo != null) {
return elementInfo.getRowCount();
} else {
return 0;
}
}
/**
* Returns the row headers as an AccessibleTable.
*
* @return an AccessibleTable representing the row
* headers
*/
return null;
}
/**
* Sets the row headers.
*
* @param table an AccessibleTable representing the
* row headers
*/
}
/**
* Returns the column headers as an AccessibleTable.
*
* @return an AccessibleTable representing the column
* headers
*/
return null;
}
/**
* Sets the column headers.
*
* @param table an AccessibleTable representing the
* column headers
*/
}
/**
* Returns the description of the specified row in the table.
*
* @param r zero-based row of the table
* @return the description of the row
*/
return null;
}
/**
* Sets the description text of the specified row of the table.
*
* @param r zero-based row of the table
* @param a the description of the row
*/
}
/**
* Returns the description text of the specified column in the table.
*
* @param c zero-based column of the table
* @return the text description of the column
*/
return null;
}
/**
* Sets the description text of the specified column in the table.
*
* @param c zero-based column of the table
* @param a the text description of the column
*/
}
/**
* Returns a boolean value indicating whether the accessible at
* a specified row and column is selected.
*
* @param r zero-based row of the table
* @param c zero-based column of the table
* @return the boolean value true if the accessible at the
* row and column is selected. Otherwise, the boolean value
* false
*/
public boolean isAccessibleSelected(int r, int c) {
return false;
}
/**
* Returns a boolean value indicating whether the specified row
* is selected.
*
* @param r zero-based row of the table
* @return the boolean value true if the specified row is selected.
* Otherwise, false.
*/
public boolean isAccessibleRowSelected(int r) {
return false;
}
/**
* Returns a boolean value indicating whether the specified column
* is selected.
*
* @param c zero-based column of the table
* @return the boolean value true if the specified column is selected.
* Otherwise, false.
*/
public boolean isAccessibleColumnSelected(int c) {
return false;
}
/**
* Returns the selected rows in a table.
*
* @return an array of selected rows where each element is a
* zero-based row of the table
*/
public int [] getSelectedAccessibleRows() {
return new int [0];
}
/**
* Returns the selected columns in a table.
*
* @return an array of selected columns where each element is a
* zero-based column of the table
*/
public int [] getSelectedAccessibleColumns() {
return new int [0];
}
}
} // ... end AccessibleHeadersTable
/*
* ElementInfo for table rows
*/
private int rowNumber;
super(e, parent);
}
for (int x = 0; x < e.getElementCount(); x++) {
new TableCellElementInfo(e.getElement(x), this, true);
false));
}
}
}
/**
* Returns the max of the rowspans of the cells in this row.
*/
public int getRowCount() {
int rowCount = 1;
if (validateIfNecessary()) {
counter++) {
if (cell.validateIfNecessary()) {
}
}
}
return rowCount;
}
/**
* Returns the sum of the column spans of the individual
* cells in this row.
*/
public int getColumnCount() {
int colCount = 0;
if (validateIfNecessary()) {
counter++) {
if (cell.validateIfNecessary()) {
}
}
}
return colCount;
}
/**
* Overriden to invalidate the table as well as
* TableRowElementInfo.
*/
super.invalidate(first);
getParent().invalidate(true);
}
/**
* Places the TableCellElementInfos for this element in
* the grid.
*/
if (validateIfNecessary()) {
boolean emptyRow = false;
while (!emptyRow) {
counter++) {
emptyRow = true;
break;
}
}
if (!emptyRow) {
row++;
}
}
counter++) {
col++;
}
}
}
}
}
}
/**
* Returns the column count of the number of columns that have
* a rowcount >= rowspan.
*/
if (validateIfNecessary()) {
int cols = 0;
counter++) {
}
}
return cols;
}
return 0;
}
}
/**
* TableCellElementInfo is used to represents the cells of
* the table.
*/
private boolean isHeaderCell;
super(e, parent);
this.isHeaderCell = false;
}
boolean isHeaderCell) {
super(e, parent);
this.isHeaderCell = isHeaderCell;
}
/*
* Returns whether this table cell is a header
*/
public boolean isHeaderCell() {
return this.isHeaderCell;
}
/*
* Returns the Accessible representing this table cell
*/
accessible = null;
getAccessible(this);
return accessible;
}
/*
* Gets the outermost Accessible in the table cell
*/
if (elementInfo instanceof Accessible) {
} else {
}
}
}
/**
* Returns the rowspan attribute.
*/
public int getRowCount() {
if (validateIfNecessary()) {
}
return 0;
}
/**
* Returns the colspan attribute.
*/
public int getColumnCount() {
if (validateIfNecessary()) {
}
return 0;
}
/**
* Overriden to invalidate the TableRowElementInfo as well as
* the TableCellElementInfo.
*/
super.invalidate(first);
getParent().invalidate(true);
}
}
}
/**
* ElementInfo provides a slim down view of an Element. Each ElementInfo
* can have any number of child ElementInfos that are not necessarily
* direct children of the Element. As the Document changes various
* ElementInfos become invalidated. Before accessing a particular portion
* of an ElementInfo you should make sure it is valid by invoking
* <code>validateIfNecessary</code>, this will return true if
* successful, on the other hand a false return value indicates the
* ElementInfo is not valid and can never become valid again (usually
* the result of the Element the ElementInfo encapsulates being removed).
*/
private class ElementInfo {
/**
* The children of this ElementInfo.
*/
/**
* The Element this ElementInfo is providing information for.
*/
/**
* The parent ElementInfo, will be null for the root.
*/
/**
* Indicates the validity of the ElementInfo.
*/
private boolean isValid;
/**
* Indicates if the ElementInfo can become valid.
*/
private boolean canBeValid;
/**
* Creates the root ElementInfo.
*/
}
/**
* Creates an ElementInfo representing <code>element</code> with
* the specified parent.
*/
isValid = false;
canBeValid = true;
}
/**
* Validates the receiver. This recreates the children as well. This
* will be invoked within a <code>readLock</code>. If this is overriden
* it MUST invoke supers implementation first!
*/
protected void validate() {
isValid = true;
}
/**
* Recreates the direct children of <code>info</code>.
*/
}
else {
loadChildren(e);
}
}
}
}
/**
* Returns the index of the child in the parent, or -1 for the
* root or if the parent isn't valid.
*/
public int getIndexInParent() {
return -1;
}
}
/**
* Returns the Element this <code>ElementInfo</code> represents.
*/
return element;
}
/**
* Returns the parent of this Element, or null for the root.
*/
return parent;
}
/**
* Returns the index of the specified child, or -1 if
* <code>child</code> isn't a valid child.
*/
}
return -1;
}
/**
* Returns the child ElementInfo at <code>index</code>, or null
* if <code>index</code> isn't a valid index.
*/
if (validateIfNecessary()) {
}
}
return null;
}
/**
* Returns the number of children the ElementInfo contains.
*/
public int getChildCount() {
}
/**
* Adds a new child to this ElementInfo.
*/
}
}
/**
* Returns the View corresponding to this ElementInfo, or null
* if the ElementInfo can't be validated.
*/
if (!validateIfNecessary()) {
return null;
}
try {
Element e = getElement();
int start = e.getStartOffset();
}
return null;
} finally {
}
}
/**
* Returns the Bounds for this ElementInfo, or null
* if the ElementInfo can't be validated.
*/
if (!validateIfNecessary()) {
return null;
}
try {
Element e = getElement();
try {
e.getEndOffset(),
} catch (BadLocationException ble) { }
}
} finally {
}
return null;
}
/**
* Returns true if this ElementInfo is valid.
*/
protected boolean isValid() {
return isValid;
}
/**
* Returns the AttributeSet associated with the Element, this will
* return null if the ElementInfo can't be validated.
*/
if (validateIfNecessary()) {
return getElement().getAttributes();
}
return null;
}
/**
* Returns the AttributeSet associated with the View that is
* representing this Element, this will
* return null if the ElementInfo can't be validated.
*/
if (validateIfNecessary()) {
}
return getElement().getAttributes();
}
return null;
}
/**
* Convenience method for getting an integer attribute from the passed
* in AttributeSet.
*/
int i;
i = deflt;
}
else {
try {
} catch (NumberFormatException x) {
i = deflt;
}
}
return i;
}
return deflt;
}
/**
* Validates the ElementInfo if necessary. Some ElementInfos may
* never be valid again. You should check <code>isValid</code> before
* using one. This will reload the children and invoke
* <code>validate</code> if the ElementInfo is invalid and can become
* valid again. This will return true if the receiver is valid.
*/
protected boolean validateIfNecessary() {
if (!isValid() && canBeValid) {
try {
validate();
} finally {
}
}
return isValid();
}
/**
* Invalidates the ElementInfo. Subclasses should override this
* if they need to reset state once invalid.
*/
if (!isValid()) {
if (canBeValid && !first) {
canBeValid = false;
}
return;
}
isValid = false;
canBeValid = first;
child.invalidate(false);
}
}
}
if (parent.getElement() == e) {
return parent;
}
}
return null;
}
return counter;
}
}
return -1;
}
if (!isValid()) {
return;
}
do {
if (element == getElement()) {
// One of our children changed.
invalidate(true);
}
}
return;
}
if (getChildCount() > 0) {
if (index0 == -1 &&
// Event beyond our offsets. We may have represented this,
// that is the remove may have removed one of our child
// Elements that represented this, so, we should foward
// to last element.
}
// If at a boundary, forward the event to the previous
// ElementInfo too.
}
int index1;
if (index1 < 0) {
}
}
else {
// A remove may result in empty elements.
index1++;
}
}
// The check for isValid is here as in the process of
// forwarding update our child may invalidate us.
}
}
}
}
/**
* DocumentListener installed on the current Document. Will invoke
* <code>update</code> on the <code>RootInfo</code> in response to
* any event.
*/
getRootInfo().update(e);
}
getRootInfo().update(e);
}
getRootInfo().update(e);
}
}
/*
* PropertyChangeListener installed on the editor.
*/
// handle the document change
}
}
}
}