org.crosswire.common.swing
Class RowTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.crosswire.common.swing.RowTableModel
All Implemented Interfaces:
Serializable, TableModel

public class RowTableModel
extends AbstractTableModel

The RowTableModel defines the "model" behaviour for a RowTable.

Distribution Licence:
JSword is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The License is available on the internet here, or by writing to: Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
The copyright to this program is held by it's authors.

Version:
$Id: RowTableModel.java,v 1.3 2005/01/15 12:05:33 joe Exp $
Author:
DM Smith [dmsmith555 at yahoo dot com], Joe Walker [joe at eireneh dot com]
See Also:
Licence, Serialized Form

Field Summary
private  int[] indexes
          Field indexes provides a look-aside for the sorted view of the table to the row list.
private  int[] keys
          Field keys provides the primary or composite key of the table.
private  List list
          Field list contains the objects that can be worked upon
private  RowColumns rowColumnModel
          Field columnModel provides the definition of the structure of the table
private static long serialVersionUID
          Serialization ID
private  int sortColumn
          Field sortColumn indicates the column that was last sorted upon.
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
RowTableModel(List newList, RowColumns aRowColumnModel)
          Builds a RowTable model for the provided (non-null) row list, using the provided row column definition.
 
Method Summary
 void addRow(Object obj)
          Method addRow adds a row to the table.
private  void allocate()
          Method allocate
 void clear()
           
 int compare(int i, int j, int column)
          Method compare
private  int compareKeys(int i, int j, int column)
          Method compareKeys
private  Object getCellValue(int rowIndex, int columnIndex)
          Method getCellValue Translates from a row index to a row object and asks it for the appropriate cell value
 Class getColumnClass(int columnIndex)
          Method getColumnClass returns the class of the column
 int getColumnCount()
          Method getColumnCount returns the number of columns in the table
 String getColumnName(int columnIndex)
          Method getColumnName returns the header name for the column
 String getHeaderToolTip(int columnIndex)
          Method getHeaderToolTip returns the tooltip for the header of the column
 Object getRow(int rowIndex)
          Method getRow retrieves a row from the table
 int getRow(Object obj)
          Method getRow finds the visible row index for a given row
 int getRowCount()
          Method getRowCount returns the number of rows in the list.
 Object getValueAt(int row, int column)
          Method getValueAt returns the contents of a cell.
 void removeRow(Object obj)
          Method removeRow removes a row from the model and causes the display to update itself appropriately
 void reset()
           
 void sort(int modelIndex)
          Method sort
private  void swap(int i, int j)
          Method swap
 void updateRow(Object obj)
          Method updateRow causes the display to update itself appropriately.
 
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
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serialization ID

See Also:
Constant Field Values

list

private List list
Field list contains the objects that can be worked upon


rowColumnModel

private RowColumns rowColumnModel
Field columnModel provides the definition of the structure of the table


indexes

private int[] indexes
Field indexes provides a look-aside for the sorted view of the table to the row list.


keys

private int[] keys
Field keys provides the primary or composite key of the table. It is a local optimization of columnModel.getSortKeys().


sortColumn

private int sortColumn
Field sortColumn indicates the column that was last sorted upon. It is initialized the first value in keys, if present otherwise -1

Constructor Detail

RowTableModel

public RowTableModel(List newList,
                     RowColumns aRowColumnModel)
Builds a RowTable model for the provided (non-null) row list, using the provided row column definition.

Parameters:
newList - List
Method Detail

getRowCount

public int getRowCount()
Method getRowCount returns the number of rows in the list.

Returns:
int
See Also:
TableModel.getRowCount()

getColumnCount

public int getColumnCount()
Method getColumnCount returns the number of columns in the table

Returns:
int
See Also:
TableModel.getColumnCount()

getValueAt

public Object getValueAt(int row,
                         int column)
Method getValueAt returns the contents of a cell.

Parameters:
row - int
column - int
Returns:
Object
See Also:
TableModel.getValueAt(int, int)

getCellValue

private Object getCellValue(int rowIndex,
                            int columnIndex)
Method getCellValue Translates from a row index to a row object and asks it for the appropriate cell value

Parameters:
rowIndex - int
columnIndex - int
Returns:
Object

getColumnClass

public Class getColumnClass(int columnIndex)
Method getColumnClass returns the class of the column

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
columnIndex - int
Returns:
Class
See Also:
TableModel.getColumnClass(int)

getHeaderToolTip

public String getHeaderToolTip(int columnIndex)
Method getHeaderToolTip returns the tooltip for the header of the column

Parameters:
columnIndex - int
Returns:
String

getColumnName

public String getColumnName(int columnIndex)
Method getColumnName returns the header name for the column

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
columnIndex - int
Returns:
String
See Also:
TableModel.getColumnName(int)

addRow

public void addRow(Object obj)
Method addRow adds a row to the table.

Parameters:
obj - the row to add

getRow

public Object getRow(int rowIndex)
Method getRow retrieves a row from the table

Parameters:
rowIndex - int
Returns:
the row

getRow

public int getRow(Object obj)
Method getRow finds the visible row index for a given row

Parameters:
obj - the row
Returns:
int

removeRow

public void removeRow(Object obj)
Method removeRow removes a row from the model and causes the display to update itself appropriately

Parameters:
obj - the row to remove

updateRow

public void updateRow(Object obj)
Method updateRow causes the display to update itself appropriately. Methods on rows are actually used to update the row

Parameters:
obj - the row

reset

public void reset()

clear

public void clear()

sort

public void sort(int modelIndex)
Method sort

Parameters:
modelIndex - int

swap

private void swap(int i,
                  int j)
Method swap

Parameters:
i - int
j - int

compareKeys

private int compareKeys(int i,
                        int j,
                        int column)
Method compareKeys

Parameters:
i - int
j - int
column - int
Returns:
int

compare

public int compare(int i,
                   int j,
                   int column)
Method compare

Parameters:
i - int
j - int
column - int
Returns:
int

allocate

private void allocate()
Method allocate


Copyright ? 2003-2004