Class JXTree.TreeAdapter
- java.lang.Object
-
- org.jdesktop.swingx.decorator.ComponentAdapter
-
- org.jdesktop.swingx.JXTree.TreeAdapter
-
- Enclosing class:
- JXTree
protected static class JXTree.TreeAdapter extends ComponentAdapter
-
-
Field Summary
-
Fields inherited from class org.jdesktop.swingx.decorator.ComponentAdapter
column, DEFAULT_COLUMN_IDENTIFIER, row, target
-
-
Constructor Summary
Constructors Constructor Description TreeAdapter(JXTree component)
Constructs aTableCellRenderContext
for the specified target component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getDepth()
Returns the depth of this row in the hierarchy where the root is 0.java.lang.String
getFilteredStringAt(int row, int column)
Returns the String representation of the filtered value of the cell identified by the row in view coordinate and the column in model coordinates.java.lang.Object
getFilteredValueAt(int row, int column)
Returns the filtered value of the cell identified by the row in view coordinate and the column in model coordinates.java.lang.String
getString()
Returns the String representation of the value of the cell identified by this adapter.java.lang.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.JXTree
getTree()
java.lang.Object
getValue()
Returns the value of the cell identified by this adapter.java.lang.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()
Returnstrue
if the cell identified by this adapter is editable,false
otherwise.boolean
isExpanded()
Returns true if the cell identified by this adapter is currently expanded.boolean
isLeaf()
Returns true if the cell identified by this adapter is a leaf node.boolean
isSelected()
Returns true if the cell identified by this adapter is currently selected.void
setValueAt(java.lang.Object aValue, int row, int column)
Sets the value of the target component's cell identified by the specified row and column in model coordinates.-
Methods inherited from class org.jdesktop.swingx.decorator.ComponentAdapter
getColumnCount, getColumnIdentifierAt, getColumnIndex, getColumnName, getComponent, getRowCount, getString, getValue, isHierarchical, isTestable, modelToView, refresh, viewToModel
-
-
-
-
Constructor Detail
-
TreeAdapter
public TreeAdapter(JXTree component)
Constructs aTableCellRenderContext
for the specified target component.- Parameters:
component
- the target component
-
-
Method Detail
-
getTree
public JXTree getTree()
-
hasFocus
public boolean hasFocus()
Returns true if the cell identified by this adapter currently has focus. Otherwise, it returns false.- Specified by:
hasFocus
in classComponentAdapter
- Returns:
- true if the cell identified by this adapter currently has focus; Otherwise, return false
-
getValueAt
public java.lang.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.- Specified by:
getValueAt
in classComponentAdapter
- Parameters:
row
- in model coordinatescolumn
- in model coordinates- Returns:
- the value of the target component's cell identified by the specified row and column
-
getFilteredValueAt
public java.lang.Object getFilteredValueAt(int row, int column)
Returns the filtered value of the cell identified by the row in view coordinate and the column in model coordinates. Note: the asymetry of the coordinates is intentional - clients like Highlighters are interested in view values but might need to access non-visible columns for testing. While it is possible to access row coordinates different from the current (that is this.row) it is not safe to do so for row > this.row because the adapter doesn't allow to query the count of visible rows.JXTree doesn't support filtering/sorting. This implies that model and view coordinates are the same. So this method is implemented to call getValueAt(row, column).
- Specified by:
getFilteredValueAt
in classComponentAdapter
- Parameters:
row
- the row of the cell in view coordinatescolumn
- the column of the cell in model coordinates.- Returns:
- the filtered value of the cell identified by the row in view coordinate and the column in model coordiantes
-
getValue
public java.lang.Object getValue()
Returns the value of the cell identified by this adapter. That is, for the at position (adapter.row, adapter.column) in view coordinates.NOTE: this implementation assumes that view coordinates == model coordinates, that is simply calls getValueAt(this.row, this.column). It is up to subclasses to override appropriately is they support model/view coordinate transformation.
JXTree doesn't support filtering/sorting. This implies that model and view coordinates are the same. So this method is implemented to call getValueAt(row, column).
- Overrides:
getValue
in classComponentAdapter
- Returns:
- the value of the cell identified by this adapter
- See Also:
ComponentAdapter.getValueAt(int, int)
,ComponentAdapter.getFilteredValueAt(int, int)
,ComponentAdapter.getValue(int)
-
getFilteredStringAt
public java.lang.String getFilteredStringAt(int row, int column)
Returns the String representation of the filtered value of the cell identified by the row in view coordinate and the column in model coordinates.Note: the asymetry of the coordinates is intentional - clients like Highlighters are interested in view values but might need to access non-visible columns for testing. While it is possible to access row coordinates different from the current (that is this.row) it is not safe to do so for row > this.row because the adapter doesn't allow to query the count of visible rows.
This implementation messages the StringValue.TO_STRING with the filteredValue, subclasses should re-implement and use the api appropriate for the target component type.
PENDING JW: what about null cell values? StringValue has a contract to return a empty string then, would that be okay here as well?
- Overrides:
getFilteredStringAt
in classComponentAdapter
- Parameters:
row
- the row of the cell in view coordinatescolumn
- the column of the cell in model coordinates.- Returns:
- the String representation of the filtered value of the cell identified by the row in view coordinate and the column in model coordiantes
-
getString
public java.lang.String getString()
Returns the String representation of the value of the cell identified by this adapter. That is, for the at position (adapter.row, adapter.column) in view coordinates.NOTE: this implementation assumes that view coordinates == model coordinates, that is simply calls getValueAt(this.row, this.column). It is up to subclasses to override appropriately is they support model/view coordinate transformation.
This implementation messages the StringValue.TO_STRING with the getValue, subclasses should re-implement and use the api appropriate for the target component type.
- Overrides:
getString
in classComponentAdapter
- Returns:
- the String representation of value of the cell identified by this adapter
- See Also:
ComponentAdapter.getValueAt(int, int)
,ComponentAdapter.getFilteredValueAt(int, int)
,ComponentAdapter.getValue(int)
-
getStringAt
public java.lang.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.This implementation messages the StringValue.TO_STRING with the valueAt, subclasses should re-implement and use the api appropriate for the target component type.
- Overrides:
getStringAt
in classComponentAdapter
- Parameters:
row
- in model coordinatescolumn
- in model coordinates- Returns:
- the value of the target component's cell identified by the specified row and column
-
isEditable
public boolean isEditable()
Returnstrue
if the cell identified by this adapter is editable,false
otherwise.- Specified by:
isEditable
in classComponentAdapter
- Returns:
true
if the cell is editable,false
otherwise
-
isSelected
public boolean isSelected()
Returns true if the cell identified by this adapter is currently selected. Otherwise, it returns false.- Specified by:
isSelected
in classComponentAdapter
- Returns:
- true if the cell identified by this adapter is currently selected; Otherwise, return false
-
isExpanded
public boolean isExpanded()
Returns true if the cell identified by this adapter is currently expanded. Otherwise, it returns false. For components that do not support hierarchical data, this method always returns true because the cells in such components can never be collapsed.- Overrides:
isExpanded
in classComponentAdapter
- Returns:
- true if the cell identified by this adapter is currently expanded; Otherwise, return false
-
getDepth
public int getDepth()
Returns the depth of this row in the hierarchy where the root is 0. For components that do not contain hierarchical data, this method returns 1.- Overrides:
getDepth
in classComponentAdapter
- Returns:
- the depth for this adapter
-
isLeaf
public boolean isLeaf()
Returns true if the cell identified by this adapter is a leaf node. Otherwise, it returns false. For components that do not support hierarchical data, this method always returns true because the cells in such components can never have children.- Overrides:
isLeaf
in classComponentAdapter
- Returns:
- true if the cell identified by this adapter is a leaf node; Otherwise, return false
-
isCellEditable
public boolean isCellEditable(int row, int column)
Determines whether this cell is editable.- Specified by:
isCellEditable
in classComponentAdapter
- Parameters:
row
- the row to query in model coordinatescolumn
- the column to query in model coordinates- Returns:
true
if the cell is editable,false
otherwise
-
setValueAt
public void setValueAt(java.lang.Object aValue, int row, int column)
Sets the value of the target component's cell identified by the specified row and column in model coordinates.- Specified by:
setValueAt
in classComponentAdapter
- Parameters:
aValue
- the value to setrow
- in model coordinatescolumn
- in model coordinates
-
-