org.ujoframework.swing
Class UjoTableModel<ROW extends Ujo>

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by org.ujoframework.swing.UjoTableModel<ROW>
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
SingleUjoTabModel

public class UjoTableModel<ROW extends Ujo>
extends javax.swing.table.AbstractTableModel

An Ujo implementation of TableModel.

Author:
Pavel Ponec
See Also:
Serialized Form

Field Summary
protected  UjoProperty[] columns
          Columns definition
static int EVENT_REPAINT_HEADER
          A repaint header event.
protected  java.util.List<ROW> rows
          A data store
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
UjoTableModel(java.lang.Class ujoType)
          Creates a new instance of UjoTableModel for all attributes.
UjoTableModel(UjoProperty... columns)
          Creates a new instance of UjoTableModel
 
Method Summary
 void addRow(ROW row)
          Add a row to end of the model.
 ROW cloneRow(int rowIndex, int depth, java.lang.Object context)
          Clone row.
 ROW deleteRow(int rowIndex)
          Delete row.
 void fireTableAllRowUpdated()
          Fire an sing, that all rows was updated.
 void fireTableColumnUpdated(UjoProperty columnProp)
          Fire an sing, that column was updated.
 void fireTableHeaderRepainted()
          Repaint header
 UjoProperty getColumn(int columnIndex)
          Convert columnIndex to a UjoProperty.
 java.lang.Class getColumnClass(int columnIndex)
          Deprecated. Use a method with column type of UjoProperty instead of.
 java.lang.Class getColumnClass(UjoProperty column)
          Returns the most specific superclass for all the cell values in the column.
 int getColumnCount()
          Count of table columns.
 int getColumnIndex(UjoProperty column)
          Returns a table column index.
 java.lang.String getColumnName(int columnIndex)
          Column Name
 java.lang.String getColumnName(UjoProperty column)
          Column Name
 ROW getRow(int rowIndex)
          Returns a row by a parameter.
 int getRowCount()
          Get Row Count
 int getRowIndex(ROW row)
          Returns a table column index or -1 if the row was not found.
 ROW getRowLast()
          Returns the lastRow of the model or null, if the model have got no rows.
 ROW getRowNullable(int rowIndex)
          Returns a row by a parameter.
protected  UjoManager getUjoManager()
          Returns an UjoManager
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Deprecated. Use a method with column type of UjoProperty instead of.
 java.lang.Object getValueAt(int rowIndex, UjoProperty column)
          Returns a value from the cell.
protected  void initData()
          An Initialization
 boolean isCellEditable(int rowIndex, int columnIndex)
          Deprecated. Use a method with column type of UjoProperty instead of.
 boolean isCellEditable(int rowIndex, UjoProperty column)
          Is the cell editable?
 void setColumns(UjoProperty... columns)
          Set columns into table
 void setRows(java.util.List<ROW> rows)
          Assign a table rows
 void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
          Deprecated. Use a method with column type of UjoProperty instead of.
 void setValueAt(java.lang.Object value, int rowIndex, UjoProperty column)
          Set a value to a cell of table model.
 void sort(java.util.Comparator<Ujo> comparator)
          Sort data by a Comparator object.
 void sort(UjoProperty... properties)
          Sort data by a property list.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVENT_REPAINT_HEADER

public static final int EVENT_REPAINT_HEADER
A repaint header event.

See Also:
Constant Field Values

columns

protected UjoProperty[] columns
Columns definition


rows

protected java.util.List<ROW extends Ujo> rows
A data store

Constructor Detail

UjoTableModel

public UjoTableModel(UjoProperty... columns)
Creates a new instance of UjoTableModel

Parameters:
columns - Columns in a required order.

UjoTableModel

public UjoTableModel(java.lang.Class ujoType)
Creates a new instance of UjoTableModel for all attributes.

Method Detail

initData

protected void initData()
An Initialization


getUjoManager

protected UjoManager getUjoManager()
Returns an UjoManager


setRows

public void setRows(java.util.List<ROW> rows)
Assign a table rows


getRowCount

public int getRowCount()
Get Row Count


getColumnCount

public int getColumnCount()
Count of table columns.


getColumn

public UjoProperty getColumn(int columnIndex)
Convert columnIndex to a UjoProperty.


setColumns

public void setColumns(UjoProperty... columns)
Set columns into table


getValueAt

public final java.lang.Object getValueAt(int rowIndex,
                                         int columnIndex)
Deprecated. Use a method with column type of UjoProperty instead of.

Get value from cell.


setValueAt

public final void setValueAt(java.lang.Object value,
                             int rowIndex,
                             int columnIndex)
Deprecated. Use a method with column type of UjoProperty instead of.

Set value to cell.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getColumnName

public final java.lang.String getColumnName(int columnIndex)
Column Name

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel

isCellEditable

public final boolean isCellEditable(int rowIndex,
                                    int columnIndex)
Deprecated. Use a method with column type of UjoProperty instead of.

Is the Cell Editable?

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

getColumnClass

public final java.lang.Class getColumnClass(int columnIndex)
Deprecated. Use a method with column type of UjoProperty instead of.

Returns the most specific superclass for all the cell values in the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Returns:
the common ancestor class of the object values in the model.

getRow

public ROW getRow(int rowIndex)
                       throws java.lang.IndexOutOfBoundsException
Returns a row by a parameter. The mothod can throw an exception called "IndexOutOfBoundsException"

Parameters:
rowIndex -
Throws:
java.lang.IndexOutOfBoundsException

getRowNullable

public ROW getRowNullable(int rowIndex)
Returns a row by a parameter. The result can be a null value if a rowIndex is out of a range.

Parameters:
rowIndex -

getRowLast

public ROW getRowLast()
Returns the lastRow of the model or null, if the model have got no rows.


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   UjoProperty column)
Returns a value from the cell.


setValueAt

public void setValueAt(java.lang.Object value,
                       int rowIndex,
                       UjoProperty column)
Set a value to a cell of table model.


getColumnName

public java.lang.String getColumnName(UjoProperty column)
Column Name


isCellEditable

public boolean isCellEditable(int rowIndex,
                              UjoProperty column)
Is the cell editable?


getColumnClass

public java.lang.Class getColumnClass(UjoProperty column)
Returns the most specific superclass for all the cell values in the column.

Returns:
the common ancestor class of the object values in the model.

getColumnIndex

public int getColumnIndex(UjoProperty column)
Returns a table column index.


getRowIndex

public int getRowIndex(ROW row)
Returns a table column index or -1 if the row was not found.


deleteRow

public ROW deleteRow(int rowIndex)
Delete row.


addRow

public void addRow(ROW row)
Add a row to end of the model.


cloneRow

public ROW cloneRow(int rowIndex,
                    int depth,
                    java.lang.Object context)
Clone row.


fireTableHeaderRepainted

public void fireTableHeaderRepainted()
Repaint header


sort

public void sort(UjoProperty... properties)
Sort data by a property list.

Parameters:
properties - Array of properties. A property value must be comparable.

sort

public void sort(java.util.Comparator<Ujo> comparator)
Sort data by a Comparator object.


fireTableAllRowUpdated

public void fireTableAllRowUpdated()
Fire an sing, that all rows was updated.


fireTableColumnUpdated

public void fireTableColumnUpdated(UjoProperty columnProp)
Fire an sing, that column was updated.



Copyright © 2010. All Rights Reserved.