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
           
static int NOT_SORTED
           
 java.util.Comparator rowSortComparitor
           
 
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.
 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.
 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.
 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.
 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.
 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.
 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.
 java.lang.String toString()
           
 
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
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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

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.

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.

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()

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