com.isti.util.gui
Class IstiTableModel

java.lang.Object
  extended by com.isti.util.gui.IstiTableModel
All Implemented Interfaces:
IstiColumnFilter, IstiRowFilter, java.util.EventListener, javax.swing.event.TableModelListener, javax.swing.table.TableModel

public class IstiTableModel
extends java.lang.Object
implements IstiColumnFilter, IstiRowFilter, javax.swing.table.TableModel, javax.swing.event.TableModelListener

Class IstiTableModel Extends the TableModel.


Constructor Summary
IstiTableModel(javax.swing.table.AbstractTableModel tableModel)
          Creates a default instance.
 
Method Summary
 void addTableModelListener(javax.swing.event.TableModelListener listener)
          Adds a listener to the model.
 void fireTableStructureChanged()
          Notifies all listeners that the table's structure has changed.
 int getActualColumnIndex(int columnIndex)
          Gets the actual column index.
 int getActualRowIndex(int rowIndex)
          Gets the actual row index.
 java.lang.Class getColumnClass(int columnIndex)
          Returns the Class for all Object instances in the specified column.
 int getColumnCount()
          Returns the number of visible columns in the model.
 IstiColumnFilter getColumnFilter()
          Get the column filter.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of a column in the model.
 int getRowCount()
          Returns the number of rows in the model.
 IstiRowFilter getRowFilter()
          Get the row filter.
 javax.swing.table.TableModel getTableModel()
          Gets the underlying table model.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns the value (Object) at a particular cell in the table.
protected  void initColumnInfo()
          Initializes the column information.
protected  void initRowInfo()
          Initializes the row information.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell is editable, and false otherwise.
 boolean isColumnVisible(int columnIndex)
          Determines if the column is visible.
 boolean isRowVisible(int rowIndex)
          Determines if the row is visible.
 void removeTableModelListener(javax.swing.event.TableModelListener listener)
          Removes a listener from the model.
 void setColumnFilter(IstiColumnFilter columnFilter)
          Set the column filter.
 void setColumnVisible(int columnIndex, boolean b)
          Sets if the column is visible or not.
 void setRowFilter(IstiRowFilter rowFilter)
          Set the row filter.
 void setRowVisible(int rowIndex, boolean b)
          Sets if the row is visible or not.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets the value at a particular cell in the table.
 void tableChanged(javax.swing.event.TableModelEvent e)
          This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
protected  void updateColumnInfo()
          Updates the column information.
protected  void updateRowInfo()
          Updates the row information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IstiTableModel

public IstiTableModel(javax.swing.table.AbstractTableModel tableModel)
Creates a default instance.

Parameters:
tableModel - the table model.
Method Detail

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener listener)
Adds a listener to the model. The listener will receive notification of updates to the model.

Specified by:
addTableModelListener in interface javax.swing.table.TableModel
Parameters:
listener - the listener.

fireTableStructureChanged

public void fireTableStructureChanged()
Notifies all listeners that the table's structure has changed.


getActualColumnIndex

public int getActualColumnIndex(int columnIndex)
Gets the actual column index.

Parameters:
columnIndex - the visible column index.
Returns:
the actual column index.

getActualRowIndex

public int getActualRowIndex(int rowIndex)
Gets the actual row index.

Parameters:
rowIndex - the visible row index.
Returns:
the actual row index.

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns the Class for all Object instances in the specified column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Parameters:
columnIndex - the visible column index.
Returns:
The class.

getColumnCount

public int getColumnCount()
Returns the number of visible columns in the model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
The visible column count.

getColumnFilter

public IstiColumnFilter getColumnFilter()
Get the column filter.

Returns:
the column filter or null if none.

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of a column in the model.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Parameters:
columnIndex - the visible column index.
Returns:
The column name.

getRowCount

public int getRowCount()
Returns the number of rows in the model.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
The row count.

getRowFilter

public IstiRowFilter getRowFilter()
Get the row filter.

Returns:
the row filter or null if none.

getTableModel

public javax.swing.table.TableModel getTableModel()
Gets the underlying table model.

Returns:
the table model.

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns the value (Object) at a particular cell in the table.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
rowIndex - the row index.
columnIndex - the visible column index.
Returns:
The value at the specified cell.

initColumnInfo

protected void initColumnInfo()
Initializes the column information. This method should be called if the number of columns changes. All columns will default to visible as a result of calling this method. This will set the current column filter to a new BasicColumnFilter if it is not already.


initRowInfo

protected void initRowInfo()
Initializes the row information. This method should be called if the number of rows changes. All rows will default to visible as a result of calling this method. This will set the current row filter to a new BasicRowFilter if it is not already.


isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns true if the cell is editable, and false otherwise.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Parameters:
rowIndex - the row index.
columnIndex - the visible column index.
Returns:
true if editable, false otherwise.

isColumnVisible

public boolean isColumnVisible(int columnIndex)
Determines if the column is visible.

Specified by:
isColumnVisible in interface IstiColumnFilter
Parameters:
columnIndex - the actual column index.
Returns:
true if the column is visible, false otherwise.

isRowVisible

public boolean isRowVisible(int rowIndex)
Determines if the row is visible.

Specified by:
isRowVisible in interface IstiRowFilter
Parameters:
rowIndex - the actual row index.
Returns:
true if the row is visible, false otherwise.

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener listener)
Removes a listener from the model.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel
Parameters:
listener - the listener.

setColumnFilter

public void setColumnFilter(IstiColumnFilter columnFilter)
Set the column filter.

Parameters:
columnFilter - the column filter or null if none.

setColumnVisible

public void setColumnVisible(int columnIndex,
                             boolean b)
Sets if the column is visible or not. This will set the current column filter to a new BasicColumnFilter if it is not already.

Parameters:
columnIndex - the actual column index.
b - true for visible, false otherwise.

setRowFilter

public void setRowFilter(IstiRowFilter rowFilter)
Set the row filter.

Parameters:
rowFilter - the row filter or null if none.

setRowVisible

public void setRowVisible(int rowIndex,
                          boolean b)
Sets if the row is visible or not. This will set the current row filter to a new BasicRowFilter if it is not already.

Parameters:
rowIndex - the actual row index.
b - true for visible, false otherwise.

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value at a particular cell in the table.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Parameters:
aValue - the value (null permitted).
rowIndex - the row index.
columnIndex - the visible column index.

tableChanged

public void tableChanged(javax.swing.event.TableModelEvent e)
This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.

Specified by:
tableChanged in interface javax.swing.event.TableModelListener
Parameters:
e - the table model event.

updateColumnInfo

protected void updateColumnInfo()
Updates the column information.


updateRowInfo

protected void updateRowInfo()
Updates the row information.