de.cbse.jeasy
Class JETableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by javax.swing.table.DefaultTableModel
          extended by de.cbse.jeasy.JETableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class JETableModel
extends javax.swing.table.DefaultTableModel

An enhanced table model for jeasy tables.

Author:
Harry Pfohl
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
JETableModel(JETable jet)
           
 
Method Summary
 void addRow()
          Adds an empty row to the table
 void addRow(int row)
          Inserts an empty row to the table at the given row.
 void addSumColumn(int column)
          Method addSumColumn.
 void addSumColumn(int column, int fromRow, int toRow)
          Method addSumColumn.
 void addSumColumn(int column, int fromRow, int toRow, int columnIndicator, java.lang.Object value)
          Method addSumColumn with checking another column.
 void addSumColumn(int column, int columnIndicator, java.lang.Object value)
          Method addSumColumn with checking another column.
 void addSumRow()
          Adds a the sum row at the end of the table to show column totals.
 void clear()
          Clears the table by removing all data from the table model.
 int compare(int row1, int row2)
          Compares two rows using the value of the the colum to be sorted.
 int compareRowsByColumn(int row1, int row2, int column)
          Compares two cells of one column.
 void filterData()
          Creates a new data array for the TableDataModel using only rows with filtered entries of columns The origin data array will be stored.
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int col)
           
 boolean hasSumRow()
          Returns whether a sumRow was added.
 boolean isCellEditable(int row, int col)
           
 boolean isEditable()
           
 void performMouseClicked(java.awt.event.MouseEvent e)
           
 void performMouseEntered(java.awt.event.MouseEvent e)
           
 void performMouseExited(java.awt.event.MouseEvent e)
           
 void performMouseRelease(java.awt.event.MouseEvent e)
           
 void performPopUpAction(java.awt.event.ActionEvent e)
           
 void removeAllFilter()
          Restores the data array for the TableDataModel
 void removeRow(int row)
          Removes the row of the table and if the table is filtered or sorted removes the row in the origin model too.
 void removeSumRow()
          Removes the sum row showing column totals.
 void setDataVector(java.util.Vector rows)
          Sets the data vector of the table model.
 void setFilter(java.lang.String colName, java.util.Hashtable hs)
          Sets a filter to that column.
 void setValueAt(java.lang.Object aValue, int row, int col)
           
 void shuttlesort(int[] from, int[] to, int low, int high)
          Sorts index of data
 void sort()
           
 void sortByColumn(int column)
           
 void sortByColumn(int column, boolean ascending)
           
 void sortingData()
          Brings the data vector in a sorted order
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, insertRow, insertRow, moveRow, newDataAvailable, newRowsAdded, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JETableModel

public JETableModel(JETable jet)
Method Detail

addRow

public void addRow()
Adds an empty row to the table


addRow

public void addRow(int row)
Inserts an empty row to the table at the given row.


addSumColumn

public void addSumColumn(int column)
Method addSumColumn. Builds and shows a sum row builded from this column for all rows

Parameters:
column -

addSumColumn

public void addSumColumn(int column,
                         int fromRow,
                         int toRow)
Method addSumColumn. Builds and shows a sum row builded from this column

Parameters:
column -
fromRow - from row
toRow - to row

addSumColumn

public void addSumColumn(int column,
                         int fromRow,
                         int toRow,
                         int columnIndicator,
                         java.lang.Object value)
Method addSumColumn with checking another column. This methods enables to sum only marked rows.

Parameters:
column - build the sum from this column
fromRow - from row
toRow - to row
columnIndicator - column to check the values
value - only sum when getValue(row, column) equa value

addSumColumn

public void addSumColumn(int column,
                         int columnIndicator,
                         java.lang.Object value)
Method addSumColumn with checking another column. This methods enables to sum only marked rows.

Parameters:
column -
columnIndicator -
value -

addSumRow

public void addSumRow()
Adds a the sum row at the end of the table to show column totals. If a sum row was added before nothing will be done.


clear

public void clear()
Clears the table by removing all data from the table model. The columns of a table remain unchanged.


compare

public int compare(int row1,
                   int row2)
Compares two rows using the value of the the colum to be sorted. Return -1 if the value of row1 is smaller, 0 if equal, 1 if greater.

Parameters:
row1 -
row2 -
Returns:

compareRowsByColumn

public int compareRowsByColumn(int row1,
                               int row2,
                               int column)
Compares two cells of one column. Return -1 if the value of row1 is smaller, 0 if equal, 1 if greater.

Parameters:
row1 -
row2 -
column -
Returns:

filterData

public void filterData()
Creates a new data array for the TableDataModel using only rows with filtered entries of columns The origin data array will be stored.

Parameters:
b -

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface javax.swing.table.TableModel
Overrides:
getRowCount in class javax.swing.table.DefaultTableModel

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Specified by:
getValueAt in interface javax.swing.table.TableModel
Overrides:
getValueAt in class javax.swing.table.DefaultTableModel

hasSumRow

public boolean hasSumRow()
Returns whether a sumRow was added. A sumRow is added by building sums for columns.

Returns:

isCellEditable

public boolean isCellEditable(int row,
                              int col)
Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.DefaultTableModel

isEditable

public boolean isEditable()

performMouseClicked

public void performMouseClicked(java.awt.event.MouseEvent e)

performMouseEntered

public void performMouseEntered(java.awt.event.MouseEvent e)

performMouseExited

public void performMouseExited(java.awt.event.MouseEvent e)

removeRow

public void removeRow(int row)
Removes the row of the table and if the table is filtered or sorted removes the row in the origin model too.

Overrides:
removeRow in class javax.swing.table.DefaultTableModel

performMouseRelease

public void performMouseRelease(java.awt.event.MouseEvent e)

performPopUpAction

public void performPopUpAction(java.awt.event.ActionEvent e)

removeAllFilter

public void removeAllFilter()
Restores the data array for the TableDataModel

Parameters:
b -

removeSumRow

public void removeSumRow()
Removes the sum row showing column totals.


setFilter

public void setFilter(java.lang.String colName,
                      java.util.Hashtable hs)
Sets a filter to that column. Only the row of the table will be shown, where the entry of the column matches with one of the entries of the Hashtable.

Parameters:
col -
hs -

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int row,
                       int col)
Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.DefaultTableModel

shuttlesort

public void shuttlesort(int[] from,
                        int[] to,
                        int low,
                        int high)
Sorts index of data

Parameters:
from -
to -
low -
high -

sort

public void sort()

sortByColumn

public void sortByColumn(int column)

sortByColumn

public void sortByColumn(int column,
                         boolean ascending)

sortingData

public void sortingData()
Brings the data vector in a sorted order


setDataVector

public void setDataVector(java.util.Vector rows)
Sets the data vector of the table model. Each vector element is a row vector with one element for each column.

Parameters:
rows -