DESY ACOP Beans Home

com.cosylab.gui.components.table
Class TableRowModelSupport

java.lang.Object
  extended by com.cosylab.gui.components.table.TableRowModelSupport
All Implemented Interfaces:
TableRowModel

public class TableRowModelSupport
extends java.lang.Object
implements TableRowModel

TableRowModelSupport support implementation of TableRowModel based on ArrayList.

Note!
This class is not synchronized and is not thread safe.

Since:
May 4, 2004.
Version:
$Id: TableRowModelSupport.java,v 1.14 2008-04-22 12:28:40 jbobnar Exp $
Author:
Igor Kriznar

Constructor Summary
TableRowModelSupport()
          Creates new instance.
 
Method Summary
 void addRow(int index, TableRow row)
          Inserts row at the specified index.
 void addRow(TableRow row)
          Adds row to the end of the row list.
 void addTableRowModelListener(TableRowModelListener l)
          Add listener, which receives notification of changes in the model.
protected  void fireChange(TableRowModelEvent event)
           
protected  void fireRowAdded(TableRow row, int index)
           
protected  void fireRowRemoved(TableRow row, int index)
           
 void fireRowUpdate(TableRow row, int valueIndex)
          This method is called from table row, when wants to notify its parent model about value change.
protected  void fireStructureChange(TableRow r)
           
 int getColumnCount()
          Number of columns inside this model.
 java.lang.String getColumnName(int index)
          Returns name of column.
 java.util.Comparator getComparator()
           
 TableRow getRow(int index)
          Returns row at given index,
 TableRow getRowAt(int rowIndex)
          Returns a row object at row index.
 int getRowCount()
          Returns number of rows contained in this model.
 int getRowIndex(TableRow row)
          Returns index of a row.
 void removeAllRows()
          Removes all rows from this model.
 TableRow removeRow(int index)
          Removes row from this model.
 void removeRow(TableRow row)
          Removes row from this model.
 void removeTableRowModelListener(TableRowModelListener l)
          Removes listener.
 void setColumnCount(int count)
          Sets the number of columns this model presents.
 void setColumnNames(java.lang.String[] names)
          Sets column names.
 void setComparator(java.util.Comparator<TableRow> comparator)
           
 void sortRows(int column, boolean descending)
          Sort rows in ascending or descengin order according to the natural order of cells in specified column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableRowModelSupport

public TableRowModelSupport()
Creates new instance.

Method Detail

getColumnCount

public int getColumnCount()
Description copied from interface: TableRowModel
Number of columns inside this model.

Specified by:
getColumnCount in interface TableRowModel
Returns:
number of columns inside this model

setColumnCount

public void setColumnCount(int count)
Sets the number of columns this model presents.

Parameters:
count - the number of columns

getRowCount

public int getRowCount()
Description copied from interface: TableRowModel
Returns number of rows contained in this model.

Specified by:
getRowCount in interface TableRowModel
Returns:
number of rows

getRowAt

public TableRow getRowAt(int rowIndex)
Description copied from interface: TableRowModel
Returns a row object at row index.

Specified by:
getRowAt in interface TableRowModel
Parameters:
rowIndex - the row index
Returns:
a row at the row index

getRowIndex

public int getRowIndex(TableRow row)
Description copied from interface: TableRowModel
Returns index of a row.

Specified by:
getRowIndex in interface TableRowModel
Parameters:
row - a row form this model
Returns:
the index ot the row

addTableRowModelListener

public void addTableRowModelListener(TableRowModelListener l)
Description copied from interface: TableRowModel
Add listener, which receives notification of changes in the model.

Specified by:
addTableRowModelListener in interface TableRowModel
Parameters:
l - a TableRowModelListener listener

removeTableRowModelListener

public void removeTableRowModelListener(TableRowModelListener l)
Description copied from interface: TableRowModel
Removes listener.

Specified by:
removeTableRowModelListener in interface TableRowModel
Parameters:
l - a TableRowModelListener listener

getColumnName

public java.lang.String getColumnName(int index)
Description copied from interface: TableRowModel
Returns name of column.

Specified by:
getColumnName in interface TableRowModel
Parameters:
index - the index of the colummn
Returns:
the name of the column under provided index
See Also:
TableModel.getColumnName(int)

setColumnNames

public void setColumnNames(java.lang.String[] names)
Sets column names.

Parameters:
names - the column names

addRow

public void addRow(TableRow row)
Adds row to the end of the row list.

Parameters:
row - the row to be added

addRow

public void addRow(int index,
                   TableRow row)
Inserts row at the specified index.

Parameters:
index - the index where to insert
row - the row to be added

getRow

public TableRow getRow(int index)
Returns row at given index,

Parameters:
index - the index of the row
Returns:
the row at the specified index

removeRow

public TableRow removeRow(int index)
Removes row from this model.

Parameters:
index - rowindex to be roemoved
Returns:
the removed row

removeRow

public void removeRow(TableRow row)
Removes row from this model.

Parameters:
row - the row to be removed

fireChange

protected void fireChange(TableRowModelEvent event)

fireStructureChange

protected void fireStructureChange(TableRow r)

fireRowAdded

protected void fireRowAdded(TableRow row,
                            int index)

fireRowRemoved

protected void fireRowRemoved(TableRow row,
                              int index)

fireRowUpdate

public void fireRowUpdate(TableRow row,
                          int valueIndex)
Description copied from interface: TableRowModel
This method is called from table row, when wants to notify its parent model about value change.

Specified by:
fireRowUpdate in interface TableRowModel
Parameters:
row - the row which value has changes
valueIndex - the index of the value, if -1 all values has been changed

removeAllRows

public void removeAllRows()
Removes all rows from this model.


sortRows

public void sortRows(int column,
                     boolean descending)
Description copied from interface: TableRowModel
Sort rows in ascending or descengin order according to the natural order of cells in specified column. Natural order is determined by cells, which implements Comparable.

Specified by:
sortRows in interface TableRowModel
Parameters:
column - the column index, according to which rows are sorted
descending - sorted rows are ordered ascending if false, or descending if true.

getComparator

public java.util.Comparator getComparator()
Returns:
the comparator

setComparator

public void setComparator(java.util.Comparator<TableRow> comparator)
Parameters:
comparator - the comparator to set


Copyright © 2010. All Rights Reserved.