org.knime.core.node.tableview
Class TableRowHeaderModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.knime.core.node.tableview.TableRowHeaderModel
All Implemented Interfaces:
Serializable, TableModel

public class TableRowHeaderModel
extends AbstractTableModel

Model for a Row Header view in a table view that displays a DataTable. This model has exactly one column that contains the keys (type DataCell) of the DataRows in the underlying DataTable. The view to this model is a TableRowHeaderView which can be located, for instance, in a scroll pane's row header view.

An instance of this class always corresponds to an instance of TableContentModel.

Author:
Bernd Wiswedel, University of Konstanz
See Also:
TableContentModel, Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TableRowHeaderModel(TableModel content)
          Instantiates a new TableRowHeaderModel based on a TableModel.
 
Method Summary
 ColorAttr getColorAttr(int row)
          Delegating method to TableContentModel.
 Class<DataCell> getColumnClass(int columnIndex)
          Return DataCell.class since the key of a DataRow is a DataCell.
 int getColumnCount()
          Returns 1.
 String getColumnName(int column)
          Returns "Key" as default row header name.
 int getRowCount()
          Returns row count as in TableContentModel.
 Object getValueAt(int rowIndex, int columnIndex)
          Returns the key of the row with index rowIndex.
 boolean isHiLit(int row)
          Delegating method to TableContentModel.
(package private)  boolean isRowCountFinal()
          Return false if the underlying table is an instance of TableContentModel and its row count is not final (indicating that the table has not been traversed to the very end).
 void setColumnName(String newName)
          Sets a new name for this column.
 void setTableContent(TableModel content)
          Set the table content to which this class will listen and whose content is content of this class.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableRowHeaderModel

TableRowHeaderModel(TableModel content)
Instantiates a new TableRowHeaderModel based on a TableModel. In case the argument is instance of TableContentInterface, this object will delegate to it and retrieve information (row key, hilite status, etc) from it. In case it's an ordinary table model, an adapter is created that always returns default row keys (named "default" and none of the rows will be hilited). This constructor is used in the method TableRowHeaderView.createHeaderView(javax.swing.JTable) and shouldn't be called from anywhere else.

Parameters:
content - the model for the content to this row header
Throws:
NullPointerException - if argument is null
Method Detail

getColumnCount

public int getColumnCount()
Returns 1. A row header model only has one column ... the key.

Returns:
1

getRowCount

public int getRowCount()
Returns row count as in TableContentModel.

Returns:
getContentModel().getRowCount()
See Also:
TableContentModel.getRowCount()

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Returns the key of the row with index rowIndex.

Parameters:
rowIndex - the row of interest
columnIndex - must be 0
Returns:
The key of the DataRow (type DataCell)
Throws:
IndexOutOfBoundsException - if columnIndex is not 0 or rowIndex violates its range

getColumnClass

public Class<DataCell> getColumnClass(int columnIndex)
Return DataCell.class since the key of a DataRow is a DataCell.

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
columnIndex - must be 0
Returns:
DataCell.class

getColumnName

public String getColumnName(int column)
Returns "Key" as default row header name.

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - must be 0
Returns:
"Key"
Throws:
IndexOutOfBoundsException - if column is not 0

setColumnName

public void setColumnName(String newName)
Sets a new name for this column.

Parameters:
newName - the new name or null to have no column name

setTableContent

public void setTableContent(TableModel content)
Set the table content to which this class will listen and whose content is content of this class.
Note: If the passed argument is not an instance of TableContentInterface, this model will be a very dumb model: It will not show any row keys and also no hilighting nor color information.

Parameters:
content - the new model
Throws:
IllegalArgumentException - if argument is null

isRowCountFinal

boolean isRowCountFinal()
Return false if the underlying table is an instance of TableContentModel and its row count is not final (indicating that the table has not been traversed to the very end). In all other cases return true.

Returns:
Whether there are (not) more rows to see.

isHiLit

public boolean isHiLit(int row)
Delegating method to TableContentModel.

Parameters:
row - row index of interest
Returns:
Hilite status of row.
See Also:
TableContentModel.isHiLit(int)

getColorAttr

public ColorAttr getColorAttr(int row)
Delegating method to TableContentModel.

Parameters:
row - row index of interest
Returns:
color information to that row.
See Also:
TableContentModel.getColorAttr(int)


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.