Package  Use  Tree  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD


 

 

jve.generated
Class SwingTableBinder

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byjve.generated.SwingTableBinder

All Implemented Interfaces:
IBoundObject, IDataObject, ITableBinder, java.io.Serializable, javax.swing.table.TableModel

Direct Known Subclasses:
JObjectTableBinder, JRowTableBinder


public abstract class SwingTableBinder
extends javax.swing.table.AbstractTableModel
implements ITableBinder

Swing implementation of the ITableBinder interface. This class acts as a model for a Swing JTable. It allows the sorting and filtering of JTable's contents. The SwingTableBinder also exports the selected row's element as a DataObject.

The SwingTableBinder cannot be used directly, rather its subclasses JRowTableBinder or JObjectTableBinder should be used depending on the source of array data the table is bound to.

See Also:
Serialized Form


Nested Class Summary
 class SwingTableBinder.SwingTableSelectionChangedEvent
          The type of event that is fired when the table's selection changes.
 

Nested classes inherited from class jve.generated.ITableBinder
ITableBinder.SelectionChangedEvent, ITableBinder.SelectionChangedListener
 

Field Summary
static int ASCENDING
           
static int DESCENDING
           
protected  java.util.List listeners
           
protected  java.lang.String[] modelHeaders
           
protected  java.util.List modelProperties
           
protected  java.lang.Object[] modelRows
           
protected  java.util.HashMap modelToSourceIndex
           
static int NOT_SORTED
           
 java.util.Comparator rowSortComparitor
           
protected  java.util.HashMap rowToValue
           
protected  IDataObject selectedRowDataObject
           
protected  java.util.HashMap sourceToModelIndex
           
protected  IFilterBinder tableFilter
           
protected  java.lang.Object[] unSortedModelRows
           
protected  javax.swing.JTable visualTable
           
 

Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 

Fields inherited from interface jve.generated.IBoundObject
DELIMITER, PROPERTY_OBJ_CHANGED
 

Constructor Summary
SwingTableBinder()
           
 

Method Summary
 void actionPerformed(IActionBinder action)
          Respond to an action occuring.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Add a PropertyChangeListener to the selected data object.
 void addSelectionChangedListener(ITableBinder.SelectionChangedListener l)
          Add a listener for table selection changes
 void addTableModelListener(javax.swing.event.TableModelListener l)
          Add a table model listener to the listener list.
protected  void clearModel()
          Clear out all cached information stored in the binder.
protected  void fireSelectionChanged(ITableBinder.SelectionChangedEvent e)
          Notify all SelectionChangedListeners that the selection on the table has changed.
protected abstract  IBoundObject getBoundObject()
          Get the object this table is bound to.
 int getColumnCount()
          Get the number of columns available for the table.
 java.lang.String getColumnName(int column)
          Get the default name of the column at the given index.
 int getDataIndexFromVisualIndex(int index)
          Get the index of the row data associated with this table binder that corresponds to the given index in the visual table.
 IFilterBinder getFilter()
          Get the filter used by this table.
protected  javax.swing.Icon getHeaderRendererIcon(int column, int size)
          Get the sorting icon for the given column.
 java.lang.Object getObject()
          Get the selected row in the visual table.
 java.lang.String getProperty()
          There is no bound property on a SwingTableBinder.
 int getRowCount()
          Get the number of rows in the table.
protected  java.lang.Object[] getRows()
          Get the row data to display in the table.
 int getSelectedIndex()
          This returns the index of the selected row in the visual table.
 java.lang.Object getSelectedObject()
          Get the selected object for the currently selected row in the visual table.
protected  java.lang.String getSortedProperty()
           
 java.lang.Object getSourceObject()
          Get the source object that is used to reference the bound object.
 java.lang.Class getType()
          Get the class type of the referenced object.
 java.lang.Object getValue(java.lang.String property)
          Get the value of the given property from the row object that is selected in the visual table.
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Get the value of the cell at the given row and column index.
 java.lang.Object getValueAt(int rowIndex, java.lang.String property)
          Get the value of the cell specified by the given row and column property
 int getVisualIndexFromDataIndex(int index)
          Get the index of the visual table row that corresponds to the given index in the row data associated with this table binder.
 boolean isPrimitive(java.lang.String property)
          Get to see if the type of the given property is a Java primitive type.
 boolean isReadOnly(java.lang.String property)
          Check if the given property has a setter method.
protected  void log(java.lang.String s)
           
protected  void log(java.lang.Throwable t)
          The log(xxx) methods are called in case of a failure.
protected  void performFilter()
          Filter the rows of the table if a filter is set on this binder.
protected  void performSort()
          Sort the rows of the table.
protected abstract  java.lang.Object[] primGetRows()
          Get the data rows from the bound object.
 void refresh()
          Refresh model data, and re-drive the current selection.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Remove a PropertyChangeListener from the selected data object.
 void removeSelectionChangedListener(ITableBinder.SelectionChangedListener l)
          Remove an existing table selection listener
 void removeTableModelListener(javax.swing.event.TableModelListener l)
          Remove a table model listener from the list.
protected  void reset(boolean hard)
          Respond to the change of the table model (such as changing target rows data source).
 void setFilter(IFilterBinder filter)
          Set a filter to attatch to this table.
 void setProperty(java.lang.String property)
          This method should not be called on a SwingTableBinder.
 void setSourceObject(java.lang.Object obj)
          This method should not be called on a SwingTableBinder.
 void setSourceObject(java.lang.Object obj, java.lang.String property)
          This method should not be called on a SwingTableBinder.
 void setValue(java.lang.String property, java.lang.Object value)
          Change the value of the given property on the selected row object in the table.
protected  void setVisualTable(javax.swing.JTable table)
          Hook up the table binder to work with the given visual table.
 java.lang.String toString()
           
protected  void updateAllTableColumnIndexes()
          Update the table column indexes to match the Z-order of the properties used to define the columns of the table.
protected  void updateColumnModelIndex(javax.swing.table.TableColumn tc)
          Update the modelIndex propert on the table's columns.
protected  void updateRowInformation()
          Cache information regarding the table rows.
 

Methods inherited from class javax.swing.table.AbstractTableModel
findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, setValueAt
 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

 

Field Detail

 

 

visualTable

protected javax.swing.JTable visualTable


 

 

tableFilter

protected IFilterBinder tableFilter


 

 

modelRows

protected java.lang.Object[] modelRows


 

 

unSortedModelRows

protected java.lang.Object[] unSortedModelRows


 

 

modelToSourceIndex

protected java.util.HashMap modelToSourceIndex


 

 

sourceToModelIndex

protected java.util.HashMap sourceToModelIndex


 

 

rowToValue

protected java.util.HashMap rowToValue


 

 

modelHeaders

protected java.lang.String[] modelHeaders


 

 

modelProperties

protected java.util.List modelProperties


 

 

listeners

protected java.util.List listeners


 

 

selectedRowDataObject

protected IDataObject selectedRowDataObject


 

 

NOT_SORTED

public static final int NOT_SORTED

See Also:
Constant Field Values


 

 

DESCENDING

public static final int DESCENDING

See Also:
Constant Field Values


 

 

ASCENDING

public static final int ASCENDING

See Also:
Constant Field Values


 

 

rowSortComparitor

public java.util.Comparator rowSortComparitor

Constructor Detail

 

 

SwingTableBinder

public SwingTableBinder()

Method Detail

 

 

log

protected void log(java.lang.Throwable t)

The log(xxx) methods are called in case of a failure. Data Objects and binders do not intend to provide any error validation framework. The default logging support will use the error stream if the -Djve.debug system property is defined. One can override these methods to hook up to a particular error validation/framework

Parameters:
t - Exceptions


 

 

log

protected void log(java.lang.String s)


 

 

getSortedProperty

protected java.lang.String getSortedProperty()


 

 

performSort

protected void performSort()

Sort the rows of the table.


 

 

getHeaderRendererIcon

protected javax.swing.Icon getHeaderRendererIcon(int column,
                                                 int size)

Get the sorting icon for the given column.


 

 

fireSelectionChanged

protected void fireSelectionChanged(ITableBinder.SelectionChangedEvent e)

Notify all SelectionChangedListeners that the selection on the table has changed.

Parameters:
e - event detailing the change in selection


 

 

performFilter

protected void performFilter()

Filter the rows of the table if a filter is set on this binder.


 

 

getBoundObject

protected abstract IBoundObject getBoundObject()

Get the object this table is bound to.

Returns:
the source IBoundObject for the table array.


 

 

primGetRows

protected abstract java.lang.Object[] primGetRows()

Get the data rows from the bound object.

Returns:
array of data provided by the bound object.


 

 

clearModel

protected void clearModel()

Clear out all cached information stored in the binder.


 

 

updateRowInformation

protected void updateRowInformation()
                             throws java.beans.IntrospectionException

Cache information regarding the table rows.

Throws:
java.beans.IntrospectionException - if introspection fails on the data rows' type.


 

 

getRows

protected java.lang.Object[] getRows()

Get the row data to display in the table. This list will be filtered and sorted if necessary.

Returns:
an array of row elements


 

 

addSelectionChangedListener

public void addSelectionChangedListener(ITableBinder.SelectionChangedListener l)

Description copied from interface: ITableBinder
Add a listener for table selection changes

Specified by:
addSelectionChangedListener in interface ITableBinder

Parameters:
l - the SelectionChangedListener


 

 

removeSelectionChangedListener

public void removeSelectionChangedListener(ITableBinder.SelectionChangedListener l)

Description copied from interface: ITableBinder
Remove an existing table selection listener

Specified by:
removeSelectionChangedListener in interface ITableBinder

Parameters:
l - the listener to remove


 

 

getColumnCount

public int getColumnCount()

Description copied from interface: ITableBinder
Get the number of columns available for the table. If the binder is initialized properly, this will reflect the number of properties available on the row object type.

Specified by:
getColumnCount in interface ITableBinder

Returns:
the number of available rows.


 

 

updateColumnModelIndex

protected void updateColumnModelIndex(javax.swing.table.TableColumn tc)

Update the modelIndex propert on the table's columns. Swing's JTable is based on the modelIndex property to drive column content. This binder will force the index to match the Z-order of the property the column is associated with the "identifier" property.


 

 

updateAllTableColumnIndexes

protected void updateAllTableColumnIndexes()

Update the table column indexes to match the Z-order of the properties used to define the columns of the table.


 

 

getRowCount

public int getRowCount()

Description copied from interface: ITableBinder
Get the number of rows in the table. This number reflects the number of rows after filtering, if filtering is enabled.

Specified by:
getRowCount in interface ITableBinder

Returns:
number of rows


 

 

getSelectedIndex

public int getSelectedIndex()

Description copied from interface: ITableBinder
This returns the index of the selected row in the visual table.

Specified by:
getSelectedIndex in interface ITableBinder

Returns:
the index, or -1 if no selection.


 

 

getSelectedObject

public java.lang.Object getSelectedObject()

Description copied from interface: ITableBinder
Get the selected object for the currently selected row in the visual table.

Specified by:
getSelectedObject in interface ITableBinder

Returns:
the selected object, null if there's no selection.


 

 

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)

Get the value of the cell at the given row and column index. This will return error strings if the table binder is not properly setup.

Specified by:
getValueAt in interface ITableBinder

Parameters:
rowIndex - the row index
columnIndex - the column index
Returns:
the value of the cell


 

 

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   java.lang.String property)

Get the value of the cell specified by the given row and column property

Specified by:
getValueAt in interface ITableBinder

Parameters:
rowIndex - the row index
property - the property of the object at the target row
Returns:
value of the given property


 

 

getColumnName

public java.lang.String getColumnName(int column)

Get the default name of the column at the given index. This will be the row object property set for the given column.

Specified by:
getColumnName in interface ITableBinder

Parameters:
column - the index of the column to get
Returns:
the name of the column.


 

 

setVisualTable

protected void setVisualTable(javax.swing.JTable table)

Hook up the table binder to work with the given visual table. This table binder should be the model for the target visual table.

Parameters:
table - the table that uses this table binder.


 

 

addTableModelListener

public void addTableModelListener(javax.swing.event.TableModelListener l)

Add a table model listener to the listener list. We override this method to automaticaly setup this binder to use the target JTable.

Specified by:
addTableModelListener in interface javax.swing.table.TableModel

Parameters:
l - the listener to add


 

 

removeTableModelListener

public void removeTableModelListener(javax.swing.event.TableModelListener l)

Remove a table model listener from the list. If the target listener is the JTable associated with this binder, the binder unhooks itself from the table.

Specified by:
removeTableModelListener in interface javax.swing.table.TableModel


 

 

refresh

public void refresh()

Refresh model data, and re-drive the current selection.

Specified by:
refresh in interface IBoundObject


 

 

actionPerformed

public void actionPerformed(IActionBinder action)

Respond to an action occuring. This implementation will refresh the table's contents.

Specified by:
actionPerformed in interface IBoundObject

Parameters:
action - the action that used the referenced object


 

 

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)

Add a PropertyChangeListener to the selected data object.

Specified by:
addPropertyChangeListener in interface IBoundObject

Parameters:
l - the listener to add.


 

 

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)

Remove a PropertyChangeListener from the selected data object.

Specified by:
removePropertyChangeListener in interface IBoundObject

Parameters:
l - the listener to remove.


 

 

getObject

public java.lang.Object getObject()

Get the selected row in the visual table.

Specified by:
getObject in interface IBoundObject

Returns:
the selected row object, null if there is no selection in the table.


 

 

getSourceObject

public java.lang.Object getSourceObject()

Description copied from interface: IBoundObject
Get the source object that is used to reference the bound object.

Specified by:
getSourceObject in interface IBoundObject

Returns:
the source object


 

 

getValue

public java.lang.Object getValue(java.lang.String property)

Get the value of the given property from the row object that is selected in the visual table.

Specified by:
getValue in interface IDataObject

Parameters:
property - the property of the row object
Returns:
the value, null if there is no selection in the table.


 

 

setSourceObject

public void setSourceObject(java.lang.Object obj)

This method should not be called on a SwingTableBinder. Use the visual table to change the selected object on the table.

Specified by:
setSourceObject in interface IBoundObject

Parameters:
obj - the source object


 

 

setSourceObject

public void setSourceObject(java.lang.Object obj,
                            java.lang.String property)

This method should not be called on a SwingTableBinder.

Specified by:
setSourceObject in interface IBoundObject

Parameters:
obj - the source object
property - the target property


 

 

setProperty

public void setProperty(java.lang.String property)

This method should not be called on a SwingTableBinder.

Specified by:
setProperty in interface IBoundObject

Parameters:
property - the property of the source object


 

 

getProperty

public java.lang.String getProperty()

There is no bound property on a SwingTableBinder.

Specified by:
getProperty in interface IBoundObject

Returns:
this will always return null


 

 

setValue

public void setValue(java.lang.String property,
                     java.lang.Object value)

Change the value of the given property on the selected row object in the table.

Specified by:
setValue in interface IDataObject

Parameters:
property - the target property of the row object
value - the value to set


 

 

toString

public java.lang.String toString()


 

 

reset

protected void reset(boolean hard)

Respond to the change of the table model (such as changing target rows data source). This will clear out any cached table information and update the visual table.

Parameters:
hard - if true the assumption is that the source rows object has changed else, sorting, or filtering has changed.


 

 

getFilter

public IFilterBinder getFilter()

Description copied from interface: ITableBinder
Get the filter used by this table.

Specified by:
getFilter in interface ITableBinder

Returns:
the filter, null if none is set.


 

 

setFilter

public void setFilter(IFilterBinder filter)

Description copied from interface: ITableBinder
Set a filter to attatch to this table. This is optional.

Specified by:
setFilter in interface ITableBinder

Parameters:
filter - the filter to use with this table.


 

 

getType

public java.lang.Class getType()

Description copied from interface: IBoundObject
Get the class type of the referenced object. This is necessary to enable design time visual support through introspection.

Specified by:
getType in interface IBoundObject

Returns:
the Class type of the configured object. If it is an array or a List, it will return the type of the elements that comprises the array or List rather than the type array or List type.


 

 

getDataIndexFromVisualIndex

public int getDataIndexFromVisualIndex(int index)

Description copied from interface: ITableBinder
Get the index of the row data associated with this table binder that corresponds to the given index in the visual table. These values may not be equal due to filtering and sorting of the rows on the visual table.

Specified by:
getDataIndexFromVisualIndex in interface ITableBinder

Parameters:
index - the row index from the visual table
Returns:
the corresponding row index from the row data


 

 

getVisualIndexFromDataIndex

public int getVisualIndexFromDataIndex(int index)

Description copied from interface: ITableBinder
Get the index of the visual table row that corresponds to the given index in the row data associated with this table binder. These values may not be equal due to filtering and sorting of the rows on the visual table.

Specified by:
getVisualIndexFromDataIndex in interface ITableBinder

Parameters:
index - the row index from the row data
Returns:
the corresponding row index from the visual table


 

 

isReadOnly

public boolean isReadOnly(java.lang.String property)

Description copied from interface: IDataObject
Check if the given property has a setter method.

Specified by:
isReadOnly in interface IDataObject

Parameters:
property - the property to check
Returns:
true, if the property does not have a setter method, false otherwise


 

 

isPrimitive

public boolean isPrimitive(java.lang.String property)

Description copied from interface: IDataObject
Get to see if the type of the given property is a Java primitive type.

Specified by:
isPrimitive in interface IDataObject

Parameters:
property - the property to check
Returns:
true if the property is a primitive type, false otherwise


Package  Use  Tree  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES  
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD