protected static class JXTable.TableAdapter extends ComponentAdapter
Modifier and Type | Field and Description |
---|---|
private JXTable |
table |
column, DEFAULT_COLUMN_IDENTIFIER, row, target
Constructor and Description |
---|
TableAdapter(JXTable component)
Constructs a
TableDataAdapter for the specified target
component. |
Modifier and Type | Method and Description |
---|---|
int |
convertColumnIndexToModel(int columnIndex)
For target components that support multiple columns in their model, along
with column reordering in the view, this method transforms the specified
columnIndex from view coordinates to model coordinates.
|
int |
convertColumnIndexToView(int columnIndex)
For target components that support multiple columns in their model,
along with column reordering in the view, this method transforms the
specified columnIndex from model coordinates to view coordinates.
|
int |
convertRowIndexToModel(int rowViewIndex)
Converts a row index in view coordinates to an index in model coordinates.
|
int |
convertRowIndexToView(int rowModelIndex)
Converts a row index in model coordinates to an index in view coordinates.
|
Rectangle |
getCellBounds()
Returns the bounds of the cell identified by this adapter.
|
protected TableColumn |
getColumnByModelIndex(int modelColumn)
Returns the first contained TableColumn with the given model index, or
null if none is found.
|
Class<?> |
getColumnClass(int column)
Returns the common class of all data column identified by the given
column index in model coordinates.
|
int |
getColumnCount()
Returns the number of columns in the target's data model.
|
Object |
getColumnIdentifierAt(int columnIndex)
Returns logical identifier of the column at
columnIndex in model coordinates.
|
int |
getColumnIndex(Object identifier)
Returns the column index in model coordinates for the logical identifier.
|
String |
getColumnName(int columnIndex)
Returns the column's display name (= headerValue) of the column
at columnIndex in model coordinates.
|
int |
getRowCount()
Returns the number of rows in the target's data model.
|
String |
getStringAt(int row,
int column)
Returns the String representation of the value of the cell identified by the row
specified row and column in model coordinates.
|
JXTable |
getTable()
Typesafe accessor for the target component.
|
Object |
getValueAt(int row,
int column)
Returns the value of the target component's cell identified by the
specified row and column in model coordinates.
|
boolean |
hasFocus()
Returns true if the cell identified by this adapter currently has focus.
|
boolean |
isCellEditable(int row,
int column)
Determines whether this cell is editable.
|
boolean |
isEditable()
Returns
true if the cell identified by this adapter is editable,
false otherwise. |
boolean |
isSelected()
Returns true if the cell identified by this adapter is currently selected.
|
boolean |
isTestable(int column)
Returns true if the column should be included in testing.
|
getColumnClass, getComponent, getDepth, getFilteredStringAt, getFilteredValueAt, getString, getString, getValue, getValue, isExpanded, isHierarchical, isLeaf
public TableAdapter(JXTable component)
TableDataAdapter
for the specified target
component.component
- the target componentpublic JXTable getTable()
JTable
public String getColumnName(int columnIndex)
Note: it's up to the implementation to decide for which columns it returns a name - most will do so for the subset with isTestable = true. This implementation delegates to getColumnIdentifierAt and returns it's toString or null.
getColumnName
in class ComponentAdapter
columnIndex
- in model coordinatesprotected TableColumn getColumnByModelIndex(int modelColumn)
modelColumn
- the column index in model coordinates, must be validIllegalArgumentExcetpion
- if model index invalidpublic Object getColumnIdentifierAt(int columnIndex)
This implementation returns DEFAULT_COLUMN_IDENTIFIER. PENDING JW: This method replaces the old getColumnIdentifier(int) which returned a String which is overly restrictive. The only way to gently replace this method was to add this with a different name - which makes this name suboptimal. Probably should rename again once the old has died out ;-)
getColumnIdentifierAt
in class ComponentAdapter
columnIndex
- in model coordinates, must be valid.ComponentAdapter.getColumnIndex(Object)
public int getColumnIndex(Object identifier)
This implementation returns 0 if the identifier is the same as the one known identifier returned from getColumnIdentifierAt(0), or -1 otherwise. So subclasses with one column and a customizable identifier need not override. Subclasses which support multiple columns must override this as well to keep the contract as in (assuming that the lookup succeeded):
Object id = getColumnIdentifierAt(index);
assertEquals(index, getColumnIndex(index);
// and the reverse
int column = getColumnIndex(identifier);
assertEquals(identifier, getColumnIdentifierAt(column));
getColumnIndex
in class ComponentAdapter
identifier
- the column's identifier, must not be nullComponentAdapter.getColumnIdentifierAt(int)
public Class<?> getColumnClass(int column)
ComponentAdapter
This implementation returns Object.class
. Subclasses should
implement as appropriate.
getColumnClass
in class ComponentAdapter
ComponentAdapter.getColumnClass()
public int getColumnCount()
getColumnCount
in class ComponentAdapter
public int getRowCount()
getRowCount
in class ComponentAdapter
public Object getValueAt(int row, int column)
getValueAt
in class ComponentAdapter
row
- in model coordinatescolumn
- in model coordinatespublic boolean isCellEditable(int row, int column)
isCellEditable
in class ComponentAdapter
row
- the row to query in model coordinatescolumn
- the column to query in model coordinatestrue
if the cell is editable, false
otherwisepublic boolean isTestable(int column)
Here: returns true if visible (that is modelToView gives a valid view column coordinate).
isTestable
in class ComponentAdapter
column
- the column index in model coordinatespublic String getStringAt(int row, int column)
This implementation messages the StringValue.TO_STRING with the valueAt, subclasses should re-implement and use the api appropriate for the target component type.
This is implemented to query the table's StringValueRegistry for an appropriate StringValue and use that for getting the string representation.
getStringAt
in class ComponentAdapter
row
- in model coordinatescolumn
- in model coordinatespublic Rectangle getCellBounds()
getCellBounds
in class ComponentAdapter
public boolean isEditable()
true
if the cell identified by this adapter is editable,
false
otherwise.isEditable
in class ComponentAdapter
true
if the cell is editable, false
otherwisepublic boolean isSelected()
isSelected
in class ComponentAdapter
public boolean hasFocus()
hasFocus
in class ComponentAdapter
public int convertColumnIndexToView(int columnIndex)
convertColumnIndexToView
in class ComponentAdapter
columnIndex
- index of a column in model coordinatespublic int convertColumnIndexToModel(int columnIndex)
convertColumnIndexToModel
in class ComponentAdapter
columnIndex
- index of a column in view coordinatespublic int convertRowIndexToView(int rowModelIndex)
convertRowIndexToView
in class ComponentAdapter
rowModelIndex
- index of a row in model coordinatespublic int convertRowIndexToModel(int rowViewIndex)
convertRowIndexToModel
in class ComponentAdapter
rowViewIndex
- index of a row in view coordinatesWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses