Method from javax.swing.JTable$AccessibleJTable Detail: |
public void addAccessibleSelection(int i) {
// TIGER - 4495286
int column = getAccessibleColumnAtIndex(i);
int row = getAccessibleRowAtIndex(i);
JTable.this.changeSelection(row, column, true, false);
}
|
public void clearAccessibleSelection() {
JTable.this.clearSelection();
}
Clears the selection in the object, so that no children in the
object are selected. |
public void columnAdded(TableColumnModelEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
// Fire a property change event indicating the table model
// has changed.
int type = AccessibleTableModelChange.INSERT;
AccessibleJTableModelChange change =
new AccessibleJTableModelChange(type,
0,
0,
e.getFromIndex(),
e.getToIndex());
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change);
}
Track changes to the table contents (column insertions) |
public void columnMarginChanged(ChangeEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
}
Track changes of a column moving due to margin changes. |
public void columnMoved(TableColumnModelEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
// Fire property change events indicating the table model
// has changed.
int type = AccessibleTableModelChange.DELETE;
AccessibleJTableModelChange change =
new AccessibleJTableModelChange(type,
0,
0,
e.getFromIndex(),
e.getFromIndex());
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change);
int type2 = AccessibleTableModelChange.INSERT;
AccessibleJTableModelChange change2 =
new AccessibleJTableModelChange(type2,
0,
0,
e.getToIndex(),
e.getToIndex());
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change2);
}
Track changes of a column repositioning. |
public void columnRemoved(TableColumnModelEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
// Fire a property change event indicating the table model
// has changed.
int type = AccessibleTableModelChange.DELETE;
AccessibleJTableModelChange change =
new AccessibleJTableModelChange(type,
0,
0,
e.getFromIndex(),
e.getToIndex());
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change);
}
Track changes to the table contents (column deletions) |
public void columnSelectionChanged(ListSelectionEvent e) {
// we should now re-place our TableColumn listener
}
Track that the selection model of the TableColumnModel changed. |
public void editingCanceled(ChangeEvent e) {
// nothing to report, 'cause nothing changed
}
Invoked when editing is canceled. The editor object is discarded
and the cell is rendered once again. |
public void editingStopped(ChangeEvent e) {
// it'd be great if we could figure out which cell, and pass that
// somehow as a parameter
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
}
Track changes to a cell's contents.
Invoked when editing is finished. The changes are saved, the
editor object is discarded, and the cell is rendered once again. |
public Accessible getAccessibleAt(Point p) {
int column = columnAtPoint(p);
int row = rowAtPoint(p);
if ((column != -1) && (row != -1)) {
TableColumn aColumn = getColumnModel().getColumn(column);
TableCellRenderer renderer = aColumn.getCellRenderer();
if (renderer == null) {
Class< ? > columnClass = getColumnClass(column);
renderer = getDefaultRenderer(columnClass);
}
Component component = renderer.getTableCellRendererComponent(
JTable.this, null, false, false,
row, column);
return new AccessibleJTableCell(JTable.this, row, column,
getAccessibleIndexAt(row, column));
}
return null;
}
Returns the Accessible child, if one exists,
contained at the local coordinate Point . |
public Accessible getAccessibleAt(int r,
int c) {
return getAccessibleChild((r * getAccessibleColumnCount()) + c);
}
|
public Accessible getAccessibleCaption() {
return this.caption;
}
Returns the caption for the table. |
public Accessible getAccessibleChild(int i) {
if (i < 0 || i >= getAccessibleChildrenCount()) {
return null;
} else {
// children increase across, and then down, for tables
// (arbitrary decision)
int column = getAccessibleColumnAtIndex(i);
int row = getAccessibleRowAtIndex(i);
TableColumn aColumn = getColumnModel().getColumn(column);
TableCellRenderer renderer = aColumn.getCellRenderer();
if (renderer == null) {
Class< ? > columnClass = getColumnClass(column);
renderer = getDefaultRenderer(columnClass);
}
Component component = renderer.getTableCellRendererComponent(
JTable.this, null, false, false,
row, column);
return new AccessibleJTableCell(JTable.this, row, column,
getAccessibleIndexAt(row, column));
}
}
Returns the nth Accessible child of the object. |
public int getAccessibleChildrenCount() {
return (JTable.this.getColumnCount() * JTable.this.getRowCount());
}
Returns the number of accessible children in the object. If all
of the children of this object implement Accessible ,
then this method should return the number of children of this object. |
public int getAccessibleColumn(int index) {
return getAccessibleColumnAtIndex(index);
}
Returns the column number of an index in the table. |
public int getAccessibleColumnAtIndex(int i) {
int columnCount = getAccessibleColumnCount();
if (columnCount == 0) {
return -1;
} else {
return (i % columnCount);
}
}
Returns the column at a given index into the table. |
public int getAccessibleColumnCount() {
return JTable.this.getColumnCount();
}
|
public Accessible getAccessibleColumnDescription(int c) {
if (c < 0 || c >= getAccessibleColumnCount()) {
throw new IllegalArgumentException(Integer.toString(c));
}
if (columnDescription == null) {
return null;
} else {
return columnDescription[c];
}
}
Returns the description of the specified column in the table. |
public int getAccessibleColumnExtentAt(int r,
int c) {
return 1;
}
Returns the number of columns occupied by the
Accessible at a given (row, column). |
public AccessibleTable getAccessibleColumnHeader() {
JTableHeader header = JTable.this.getTableHeader();
return header == null ? null : new AccessibleTableHeader(header);
}
Returns the column headers as an AccessibleTable . |
public int getAccessibleIndex(int r,
int c) {
return getAccessibleIndexAt(r, c);
}
Returns the index at a row and column in the table. |
public int getAccessibleIndexAt(int r,
int c) {
return ((r * getAccessibleColumnCount()) + c);
}
Returns the index at a given (row, column) in the table. |
public AccessibleRole getAccessibleRole() {
return AccessibleRole.TABLE;
}
Gets the role of this object. |
public int getAccessibleRow(int index) {
return getAccessibleRowAtIndex(index);
}
Returns the row number of an index in the table. |
public int getAccessibleRowAtIndex(int i) {
int columnCount = getAccessibleColumnCount();
if (columnCount == 0) {
return -1;
} else {
return (i / columnCount);
}
}
Returns the row at a given index into the table. |
public int getAccessibleRowCount() {
return JTable.this.getRowCount();
}
|
public Accessible getAccessibleRowDescription(int r) {
if (r < 0 || r >= getAccessibleRowCount()) {
throw new IllegalArgumentException(Integer.toString(r));
}
if (rowDescription == null) {
return null;
} else {
return rowDescription[r];
}
}
Returns the description of the specified row in the table. |
public int getAccessibleRowExtentAt(int r,
int c) {
return 1;
}
Returns the number of rows occupied by the Accessible
at a specified row and column in the table. |
public AccessibleTable getAccessibleRowHeader() {
// row headers are not supported
return null;
}
Returns the row headers as an AccessibleTable . |
public AccessibleSelection getAccessibleSelection() {
return this;
}
Get the AccessibleSelection associated with this object. In the
implementation of the Java Accessibility API for this class,
return this object, which is responsible for implementing the
AccessibleSelection interface on behalf of itself. |
public Accessible getAccessibleSelection(int i) {
if (i < 0 || i > getAccessibleSelectionCount()) {
return null;
}
int rowsSel = JTable.this.getSelectedRowCount();
int colsSel = JTable.this.getSelectedColumnCount();
int rowIndicies[] = getSelectedRows();
int colIndicies[] = getSelectedColumns();
int ttlCols = JTable.this.getColumnCount();
int ttlRows = JTable.this.getRowCount();
int r;
int c;
if (JTable.this.cellSelectionEnabled) { // a contiguous block
r = rowIndicies[i / colsSel];
c = colIndicies[i % colsSel];
return getAccessibleChild((r * ttlCols) + c);
} else {
// a column swath and a row swath, with a shared block
if (JTable.this.getRowSelectionAllowed() &&
JTable.this.getColumnSelectionAllowed()) {
// Situation:
// We have a table, like the 6x3 table below,
// wherein three colums and one row selected
// (selected cells marked with "*", unselected "0"):
//
// 0 * 0 * * 0
// * * * * * *
// 0 * 0 * * 0
//
// State machine below walks through the array of
// selected rows in two states: in a selected row,
// and not in one; continuing until we are in a row
// in which the ith selection exists. Then we return
// the appropriate cell. In the state machine, we
// always do rows above the "current" selected row first,
// then the cells in the selected row. If we're done
// with the state machine before finding the requested
// selected child, we handle the rows below the last
// selected row at the end.
//
int curIndex = i;
final int IN_ROW = 0;
final int NOT_IN_ROW = 1;
int state = (rowIndicies[0] == 0 ? IN_ROW : NOT_IN_ROW);
int j = 0;
int prevRow = -1;
while (j < rowIndicies.length) {
switch (state) {
case IN_ROW: // on individual row full of selections
if (curIndex < ttlCols) { // it's here!
c = curIndex % ttlCols;
r = rowIndicies[j];
return getAccessibleChild((r * ttlCols) + c);
} else { // not here
curIndex -= ttlCols;
}
// is the next row in table selected or not?
if (j + 1 == rowIndicies.length ||
rowIndicies[j] != rowIndicies[j+1] - 1) {
state = NOT_IN_ROW;
prevRow = rowIndicies[j];
}
j++; // we didn't return earlier, so go to next row
break;
case NOT_IN_ROW: // sparse bunch of rows of selections
if (curIndex <
(colsSel * (rowIndicies[j] -
(prevRow == -1 ? 0 : (prevRow + 1))))) {
// it's here!
c = colIndicies[curIndex % colsSel];
r = (j > 0 ? rowIndicies[j-1] + 1 : 0)
+ curIndex / colsSel;
return getAccessibleChild((r * ttlCols) + c);
} else { // not here
curIndex -= colsSel * (rowIndicies[j] -
(prevRow == -1 ? 0 : (prevRow + 1)));
}
state = IN_ROW;
break;
}
}
// we got here, so we didn't find it yet; find it in
// the last sparse bunch of rows
if (curIndex <
(colsSel * (ttlRows -
(prevRow == -1 ? 0 : (prevRow + 1))))) { // it's here!
c = colIndicies[curIndex % colsSel];
r = rowIndicies[j-1] + curIndex / colsSel + 1;
return getAccessibleChild((r * ttlCols) + c);
} else { // not here
// we shouldn't get to this spot in the code!
// System.out.println("Bug in AccessibleJTable.getAccessibleSelection()");
}
// one or more rows selected
} else if (JTable.this.getRowSelectionAllowed()) {
c = i % ttlCols;
r = rowIndicies[i / ttlCols];
return getAccessibleChild((r * ttlCols) + c);
// one or more columns selected
} else if (JTable.this.getColumnSelectionAllowed()) {
c = colIndicies[i % colsSel];
r = i / colsSel;
return getAccessibleChild((r * ttlCols) + c);
}
}
return null;
}
Returns an Accessible representing the
specified selected child in the object. If there
isn't a selection, or there are fewer children selected
than the integer passed in, the return
value will be null .
Note that the index represents the i-th selected child, which
is different from the i-th child. |
public int getAccessibleSelectionCount() {
int rowsSel = JTable.this.getSelectedRowCount();
int colsSel = JTable.this.getSelectedColumnCount();
if (JTable.this.cellSelectionEnabled) { // a contiguous block
return rowsSel * colsSel;
} else {
// a column swath and a row swath, with a shared block
if (JTable.this.getRowSelectionAllowed() &&
JTable.this.getColumnSelectionAllowed()) {
return rowsSel * JTable.this.getColumnCount() +
colsSel * JTable.this.getRowCount() -
rowsSel * colsSel;
// just one or more rows in selection
} else if (JTable.this.getRowSelectionAllowed()) {
return rowsSel * JTable.this.getColumnCount();
// just one or more rows in selection
} else if (JTable.this.getColumnSelectionAllowed()) {
return colsSel * JTable.this.getRowCount();
} else {
return 0; // JTable doesn't allow selections
}
}
}
Returns the number of Accessible children
currently selected.
If no children are selected, the return value will be 0. |
public Accessible getAccessibleSummary() {
return this.summary;
}
Returns the summary description of the table. |
public AccessibleTable getAccessibleTable() {
return this;
}
Gets the AccessibleTable associated with this
object. In the implementation of the Java Accessibility
API for this class, return this object, which is responsible
for implementing the AccessibleTables interface
on behalf of itself. |
public int[] getSelectedAccessibleColumns() {
return JTable.this.getSelectedColumns();
}
Returns the selected columns in a table. |
public int[] getSelectedAccessibleRows() {
return JTable.this.getSelectedRows();
}
Returns the selected rows in a table. |
public boolean isAccessibleChildSelected(int i) {
int column = getAccessibleColumnAtIndex(i);
int row = getAccessibleRowAtIndex(i);
return JTable.this.isCellSelected(row, column);
}
Determines if the current child of this object is selected. |
public boolean isAccessibleColumnSelected(int c) {
return JTable.this.isColumnSelected(c);
}
Returns a boolean value indicating whether the specified column
is selected. |
public boolean isAccessibleRowSelected(int r) {
return JTable.this.isRowSelected(r);
}
Returns a boolean value indicating whether the specified row
is selected. |
public boolean isAccessibleSelected(int r,
int c) {
return JTable.this.isCellSelected(r, c);
}
Returns a boolean value indicating whether the accessible at a
given (row, column) is selected. |
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
Object oldValue = e.getOldValue();
Object newValue = e.getNewValue();
// re-set tableModel listeners
if (name.compareTo("model") == 0) {
if (oldValue != null && oldValue instanceof TableModel) {
((TableModel) oldValue).removeTableModelListener(this);
}
if (newValue != null && newValue instanceof TableModel) {
((TableModel) newValue).addTableModelListener(this);
}
// re-set selectionModel listeners
} else if (name.compareTo("selectionModel") == 0) {
Object source = e.getSource();
if (source == JTable.this) { // row selection model
if (oldValue != null &&
oldValue instanceof ListSelectionModel) {
((ListSelectionModel) oldValue).removeListSelectionListener(this);
}
if (newValue != null &&
newValue instanceof ListSelectionModel) {
((ListSelectionModel) newValue).addListSelectionListener(this);
}
} else if (source == JTable.this.getColumnModel()) {
if (oldValue != null &&
oldValue instanceof ListSelectionModel) {
((ListSelectionModel) oldValue).removeListSelectionListener(this);
}
if (newValue != null &&
newValue instanceof ListSelectionModel) {
((ListSelectionModel) newValue).addListSelectionListener(this);
}
} else {
// System.out.println("!!! Bug in source of selectionModel propertyChangeEvent");
}
// re-set columnModel listeners
// and column's selection property listener as well
} else if (name.compareTo("columnModel") == 0) {
if (oldValue != null && oldValue instanceof TableColumnModel) {
TableColumnModel tcm = (TableColumnModel) oldValue;
tcm.removeColumnModelListener(this);
tcm.getSelectionModel().removeListSelectionListener(this);
}
if (newValue != null && newValue instanceof TableColumnModel) {
TableColumnModel tcm = (TableColumnModel) newValue;
tcm.addColumnModelListener(this);
tcm.getSelectionModel().addListSelectionListener(this);
}
// re-se cellEditor listeners
} else if (name.compareTo("tableCellEditor") == 0) {
if (oldValue != null && oldValue instanceof TableCellEditor) {
((TableCellEditor) oldValue).removeCellEditorListener(this);
}
if (newValue != null && newValue instanceof TableCellEditor) {
((TableCellEditor) newValue).addCellEditorListener(this);
}
}
}
Track changes to selection model, column model, etc. so as to
be able to re-place listeners on those in order to pass on
information to the Accessibility PropertyChange mechanism |
public void removeAccessibleSelection(int i) {
if (JTable.this.cellSelectionEnabled) {
int column = getAccessibleColumnAtIndex(i);
int row = getAccessibleRowAtIndex(i);
JTable.this.removeRowSelectionInterval(row, row);
JTable.this.removeColumnSelectionInterval(column, column);
}
}
|
public void selectAllAccessibleSelection() {
if (JTable.this.cellSelectionEnabled) {
JTable.this.selectAll();
}
}
Causes every child of the object to be selected, but only
if the JTable supports multiple selections,
and if individual cell selection is enabled. |
public void setAccessibleCaption(Accessible a) {
Accessible oldCaption = caption;
this.caption = a;
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_CAPTION_CHANGED,
oldCaption, this.caption);
}
Sets the caption for the table. |
public void setAccessibleColumnDescription(int c,
Accessible a) {
if (c < 0 || c >= getAccessibleColumnCount()) {
throw new IllegalArgumentException(Integer.toString(c));
}
if (columnDescription == null) {
int numColumns = getAccessibleColumnCount();
columnDescription = new Accessible[numColumns];
}
columnDescription[c] = a;
}
Sets the description text of the specified column of the table. |
public void setAccessibleColumnHeader(AccessibleTable a) {
// XXX not implemented
}
Sets the column headers as an AccessibleTable . |
public void setAccessibleRowDescription(int r,
Accessible a) {
if (r < 0 || r >= getAccessibleRowCount()) {
throw new IllegalArgumentException(Integer.toString(r));
}
if (rowDescription == null) {
int numRows = getAccessibleRowCount();
rowDescription = new Accessible[numRows];
}
rowDescription[r] = a;
}
Sets the description text of the specified row of the table. |
public void setAccessibleRowHeader(AccessibleTable a) {
// row headers are not supported
}
Sets the row headers as an AccessibleTable . |
public void setAccessibleSummary(Accessible a) {
Accessible oldSummary = summary;
this.summary = a;
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_SUMMARY_CHANGED,
oldSummary, this.summary);
}
Sets the summary description of the table. |
public void tableChanged(TableModelEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
if (e != null) {
int firstColumn = e.getColumn();
int lastColumn = e.getColumn();
if (firstColumn == TableModelEvent.ALL_COLUMNS) {
firstColumn = 0;
lastColumn = getColumnCount() - 1;
}
// Fire a property change event indicating the table model
// has changed.
AccessibleJTableModelChange change =
new AccessibleJTableModelChange(e.getType(),
e.getFirstRow(),
e.getLastRow(),
firstColumn,
lastColumn);
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change);
}
}
Track changes to the table contents |
public void tableRowsDeleted(TableModelEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
// Fire a property change event indicating the table model
// has changed.
int firstColumn = e.getColumn();
int lastColumn = e.getColumn();
if (firstColumn == TableModelEvent.ALL_COLUMNS) {
firstColumn = 0;
lastColumn = getColumnCount() - 1;
}
AccessibleJTableModelChange change =
new AccessibleJTableModelChange(e.getType(),
e.getFirstRow(),
e.getLastRow(),
firstColumn,
lastColumn);
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change);
}
Track changes to the table contents (row deletions) |
public void tableRowsInserted(TableModelEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, null);
// Fire a property change event indicating the table model
// has changed.
int firstColumn = e.getColumn();
int lastColumn = e.getColumn();
if (firstColumn == TableModelEvent.ALL_COLUMNS) {
firstColumn = 0;
lastColumn = getColumnCount() - 1;
}
AccessibleJTableModelChange change =
new AccessibleJTableModelChange(e.getType(),
e.getFirstRow(),
e.getLastRow(),
firstColumn,
lastColumn);
firePropertyChange(AccessibleContext.ACCESSIBLE_TABLE_MODEL_CHANGED,
null, change);
}
Track changes to the table contents (row insertions) |
public void valueChanged(ListSelectionEvent e) {
firePropertyChange(AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY,
Boolean.valueOf(false), Boolean.valueOf(true));
int selectedRow = JTable.this.getSelectedRow();
int selectedCol = JTable.this.getSelectedColumn();
if (selectedRow != lastSelectedRow ||
selectedCol != lastSelectedCol) {
Accessible oldA = getAccessibleAt(lastSelectedRow,
lastSelectedCol);
Accessible newA = getAccessibleAt(selectedRow, selectedCol);
firePropertyChange(AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY,
oldA, newA);
lastSelectedRow = selectedRow;
lastSelectedCol = selectedCol;
}
}
Track changes to table cell selections |