TsBiff 1.3


ts.ui
Class TsTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--ts.ui.TsTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
Model

public class TsTableModel
extends javax.swing.table.AbstractTableModel

A Table model with a simple set of methods for handling the model. The internal data structure for the dataset (cells) is a vector of vectors.

Version:
$Id: TsTableModel.java,v 1.4 1999/02/21 08:47:23 hauk Exp $
Author:
Jan-Henrik Haukeland
See Also:
TsTable, Serialized Form

Field Summary
protected  int hiddenColumns
           
protected  boolean isEditable
           
protected  java.util.Vector myColumnTitles
           
protected  java.util.Vector myDataSet
           
protected  int numColumns
           
protected  int numRows
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
TsTableModel()
          Create a new empty TsTableModel
TsTableModel(java.lang.Object[] titles)
          Create a new TsTableModel with titles and a empty dataset
TsTableModel(java.lang.Object[] titles, java.lang.Object[][] data)
          Create a new TsTableModel with column titles and a dataset
TsTableModel(java.util.Vector titles, java.util.Vector data)
          Create a new TsTableModel with column titles and a dataset
 
Method Summary
 void clear()
          Clear the dataset and notify any listeners of changes in the model.
protected static java.lang.Object[] convertToArray(java.util.Vector aVector)
           
protected static java.util.Vector convertToVector(java.lang.Object[] anArray)
           
protected static java.util.Vector convertToVector(java.lang.Object[][] anArray)
           
static javax.swing.table.TableModel createTsTableDataModel()
          TsTableModel factory method
 void deleteRow(int rowIndex)
          Remove the row with row index from the dataset and notify any TableModel listeners of changes in the model.
 java.lang.Class getColumnClass(int c)
          Get the lowest common denominator Class in the column.
 int getColumnCount()
          Returns the number of columns managed by the data source object.
 java.lang.String getColumnName(int col)
          Get the name of the column at columnIndex.
 int getHiddenColumnsCount()
          Returns the number of hidden columns
 java.lang.Object[] getRow(int rowIndex)
          Returns the row at the given index as an array of objects
 int getRowCount()
          Returns the number of records in the dataset.
 java.util.Vector getRowVector(int rowIndex)
          Returns the row at the given index as a Vector
 java.lang.Object getValueAt(int row, int col)
          Get an attribute value for the cell at columnIndex and rowIndex.
 void insertRow(java.lang.Object[] row)
          Insert a row as the first row in the dataset.
 void insertRow(java.lang.Object[] row, int rowIndex)
          Insert a row in the dataset at the given row index.
 void insertRow(java.util.Vector row)
          Insert a row as the first row in the dataset.
 void insertRow(java.util.Vector row, int rowIndex)
          Insert a row in the dataset at the given row index.
 void insertRows(java.lang.Object[][] rows)
          Insert several rows at the begining of the dataset.
 void insertRows(java.lang.Object[][] rows, int rowIndex)
          Insert several rows into the dataset at the given row index.
 void insertRows(java.util.Vector rows)
          Insert several rows at the begining of the dataset.
 void insertRows(java.util.Vector rows, int rowIndex)
          Insert several rows into the dataset at the given row index.
 boolean isCellEditable(int row, int col)
          Allow edit in cell if edit is turned on
 void setData(java.lang.Object[][] data)
          Set a new dataset for the model
 void setData(java.util.Vector data)
          Set a new dataset for the model
 void setEditable(boolean b)
          Set if cells in the table could be edited.
 void setHiddenColumns(int hidden)
          Set number of hidden columns in the model
 void setTitles(java.lang.Object[] titles)
          Set new column titles in the model
 void setTitles(java.util.Vector titles)
          Set new column titles in the model
 void setValueAt(java.lang.Object value, int row, int col)
          Set a new value in a cell
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myColumnTitles

protected java.util.Vector myColumnTitles

myDataSet

protected java.util.Vector myDataSet

hiddenColumns

protected int hiddenColumns

isEditable

protected boolean isEditable

numColumns

protected volatile int numColumns

numRows

protected volatile int numRows
Constructor Detail

TsTableModel

public TsTableModel(java.util.Vector titles,
                    java.util.Vector data)
Create a new TsTableModel with column titles and a dataset
Parameters:
titles - Column titles
data - A dataset (vector of vector)

TsTableModel

public TsTableModel(java.lang.Object[] titles,
                    java.lang.Object[][] data)
Create a new TsTableModel with column titles and a dataset
Parameters:
titles - Column titles
data - A dataset

TsTableModel

public TsTableModel(java.lang.Object[] titles)
Create a new TsTableModel with titles and a empty dataset
Parameters:
titles - Column titles

TsTableModel

public TsTableModel()
Create a new empty TsTableModel
Method Detail

createTsTableDataModel

public static javax.swing.table.TableModel createTsTableDataModel()
TsTableModel factory method

setEditable

public void setEditable(boolean b)
Set if cells in the table could be edited.
Parameters:
true - if the table will allow edit in cells else false

setTitles

public void setTitles(java.util.Vector titles)
Set new column titles in the model
Parameters:
titles - Column titles

setTitles

public void setTitles(java.lang.Object[] titles)
Set new column titles in the model
Parameters:
titles - Column titles

setData

public void setData(java.util.Vector data)
Set a new dataset for the model
Parameters:
data - The new dataset for this table model

setData

public void setData(java.lang.Object[][] data)
Set a new dataset for the model
Parameters:
data - The new dataset for this table model

getHiddenColumnsCount

public int getHiddenColumnsCount()
Returns the number of hidden columns

getColumnCount

public int getColumnCount()
Returns the number of columns managed by the data source object. The TsTable uses this method to determine how many columns it should create and display on initialization.
Overrides:
getColumnCount in class javax.swing.table.AbstractTableModel
Returns:
the number of columns in the dataset

getRowCount

public int getRowCount()
Returns the number of records in the dataset. The TsTable uses this method to determine how many rows it should create and display. This method should be quick, as it is called by TsTable quite frequently.
Overrides:
getRowCount in class javax.swing.table.AbstractTableModel
Returns:
number of rows in the dataset

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Get an attribute value for the cell at columnIndex and rowIndex.
Overrides:
getValueAt in class javax.swing.table.AbstractTableModel
Returns:
The object at the given row and column

getColumnName

public java.lang.String getColumnName(int col)
Get the name of the column at columnIndex.
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Returns:
the name of the specified column index

getColumnClass

public java.lang.Class getColumnClass(int c)
Get the lowest common denominator Class in the column.
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Returns:
the common ancestor class of the object values in the model.

getRowVector

public java.util.Vector getRowVector(int rowIndex)
Returns the row at the given index as a Vector
Returns:
the row at row index

getRow

public java.lang.Object[] getRow(int rowIndex)
Returns the row at the given index as an array of objects
Returns:
the row at row index

deleteRow

public void deleteRow(int rowIndex)
Remove the row with row index from the dataset and notify any TableModel listeners of changes in the model.
Parameters:
rowIndex - The index of the row to remove

insertRow

public void insertRow(java.util.Vector row)
Insert a row as the first row in the dataset. Notfies any TableModel listeners of changes in the model.
Parameters:
row - The row to insert at the start of the list

insertRow

public void insertRow(java.lang.Object[] row)
Insert a row as the first row in the dataset. Notfies any TableModel listeners of changes in the model.
Parameters:
row - The row to insert at the start of the list

insertRow

public void insertRow(java.util.Vector row,
                      int rowIndex)
Insert a row in the dataset at the given row index. Notify any listeners of changes in the model.
Parameters:
row - The row to insert
index - Where to insert the row in the dataset

insertRow

public void insertRow(java.lang.Object[] row,
                      int rowIndex)
Insert a row in the dataset at the given row index. Notify any listeners of changes in the model.
Parameters:
row - The row to insert
index - Where to insert the row in the dataset

insertRows

public void insertRows(java.util.Vector rows)
Insert several rows at the begining of the dataset. Notify any listeners of changes in the model.
Parameters:
row - A dataset (vector of vector)

insertRows

public void insertRows(java.lang.Object[][] rows)
Insert several rows at the begining of the dataset. Notify any listeners of changes in the model.
Parameters:
row - A dataset (vector of vector)

insertRows

public void insertRows(java.util.Vector rows,
                       int rowIndex)
Insert several rows into the dataset at the given row index. Listeners on this model is notified of the changes.
Parameters:
rows - A dataset (vector of vector)
index - The row index to start adding the new rows from

insertRows

public void insertRows(java.lang.Object[][] rows,
                       int rowIndex)
Insert several rows into the dataset at the given row index. Listeners on this model is notified of the changes.
Parameters:
rows - A dataset (vector of vector)
index - The row index to start adding the new rows from

clear

public void clear()
Clear the dataset and notify any listeners of changes in the model.

setHiddenColumns

public void setHiddenColumns(int hidden)
Set number of hidden columns in the model
Parameters:
hidden - Number of columns that should be hidden

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Allow edit in cell if edit is turned on
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

setValueAt

public void setValueAt(java.lang.Object value,
                       int row,
                       int col)
Set a new value in a cell
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
aValue - - the new value
row - - the row whose value is to be changed
column - - the column whose value is to be changed

convertToArray

protected static java.lang.Object[] convertToArray(java.util.Vector aVector)
Returns:
an Object array that contains the same objects as the vector

convertToVector

protected static java.util.Vector convertToVector(java.lang.Object[] anArray)
Returns:
a Vector that contains the same objects as the array

convertToVector

protected static java.util.Vector convertToVector(java.lang.Object[][] anArray)
Returns:
a Vector of Vectors that contains the same objects as the array

TsBiff 1.3