Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

ledestin.swing
Class CollectionTableModel  view CollectionTableModel download CollectionTableModel.java

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byledestin.swing.CollectionTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class CollectionTableModel
extends javax.swing.table.AbstractTableModel

Allows to show a Collection in a JEditableTable. It wraps your data source Collection that allows it to be shown in a table. There is always one column and getValueAt() always returns appropriate Collection item (should have toString() implemented).
If you'd like to change this behavior you'll have to implement the following methods: public int getColumnCount(); public Object getValueAt(int row, int column);


Field Summary
private  java.lang.Object[] data
           
protected  boolean dataChanged
           
protected  java.util.Collection ds
           
protected  java.lang.Class rowClass
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CollectionTableModel(java.util.Collection ds)
           
CollectionTableModel(java.util.Collection ds, java.lang.Class rowClass)
           
 
Method Summary
 java.lang.Object createNewRow()
          Creates a new object/row for the table model.
 void fireTableChanged(javax.swing.event.TableModelEvent e)
          Sends the specified event to all registered listeners.
 void fireTableDataChanged()
          Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that the table data has changed.
 void fireTableRowsDeleted(int firstRow, int lastRow)
          Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that some rows have been deleted from the model.
 void fireTableRowsInserted(int firstRow, int lastRow)
          Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that some rows have been inserted into the model.
 void fireTableStructureChanged()
          Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that the table structure has changed.
 int getColumnCount()
          Returns the number of columns in the model.
protected  java.lang.Object[] getData()
           
 java.util.Collection getDataSource()
           
 int getRowCount()
          Returns the number of rows in the model.
 java.lang.Object getValueAt(int row, int column)
          Returns an object representing row in a table, i.e.
 void setDataSource(java.util.Collection ds)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableRowsUpdated, getColumnClass, getColumnName, 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

ds

protected java.util.Collection ds

rowClass

protected java.lang.Class rowClass

dataChanged

protected boolean dataChanged

data

private java.lang.Object[] data
Constructor Detail

CollectionTableModel

public CollectionTableModel(java.util.Collection ds)
                     throws java.lang.IllegalArgumentException

CollectionTableModel

public CollectionTableModel(java.util.Collection ds,
                            java.lang.Class rowClass)
                     throws java.lang.IllegalArgumentException
Method Detail

getRowCount

public int getRowCount()
Description copied from interface: javax.swing.table.TableModel
Returns the number of rows in the model.


getDataSource

public java.util.Collection getDataSource()

setDataSource

public void setDataSource(java.util.Collection ds)

createNewRow

public java.lang.Object createNewRow()
                              throws java.lang.InstantiationException
Creates a new object/row for the table model. The faculty is wanted for JEditableTable's ability to add rows to a table. When request for inserting comes to the table it shows a dialog for editing a new object.


getData

protected java.lang.Object[] getData()

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Returns an object representing row in a table, i.e. always return the same object for any column given. Descendants will have to redefine this behaviour if necessary, for example, returning ((SampleObject)o).col1() for 1st column and col2() for the second.


getColumnCount

public int getColumnCount()
Description copied from interface: javax.swing.table.TableModel
Returns the number of columns in the model.


fireTableChanged

public void fireTableChanged(javax.swing.event.TableModelEvent e)
Description copied from class: javax.swing.table.AbstractTableModel
Sends the specified event to all registered listeners.


fireTableDataChanged

public void fireTableDataChanged()
Description copied from class: javax.swing.table.AbstractTableModel
Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that the table data has changed.


fireTableRowsDeleted

public void fireTableRowsDeleted(int firstRow,
                                 int lastRow)
Description copied from class: javax.swing.table.AbstractTableModel
Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that some rows have been deleted from the model.


fireTableRowsInserted

public void fireTableRowsInserted(int firstRow,
                                  int lastRow)
Description copied from class: javax.swing.table.AbstractTableModel
Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that some rows have been inserted into the model.


fireTableStructureChanged

public void fireTableStructureChanged()
Description copied from class: javax.swing.table.AbstractTableModel
Sends a javax.swing.event.TableModelEvent to all registered listeners to inform them that the table structure has changed.