ca.odell.glazedlists.swing
Class EventTableModel<E>
AbstractTableModel
ca.odell.glazedlists.swing.EventTableModel<E>
- EventListener, ListEventListener<E>
public class EventTableModel<E>
extends AbstractTableModel
A
TableModel
that holds an
EventList
. Each element of the list
corresponds to a row in the
TableModel
. The columns of the table are
specified using a
TableFormat
.
The EventTableModel class is
not thread-safe. Unless otherwise
noted, all methods are only safe to be called from the event dispatch thread.
To do this programmatically, use
SwingUtilities.invokeAndWait(Runnable)
.
protected EventList | source - the source of data for this TableModel, which may or may not be
swingThreadSource
|
protected TransformedList | swingThreadSource - the proxy moves events to the Swing Event Dispatch thread
|
EventTableModel(EventList source, E> tableFormat) - Creates a new table model that extracts column data from the given
source using the the given tableFormat .
|
EventTableModel(EventList source, String[] propertyNames, String[] columnLabels, boolean[] writable) - Creates a new table that renders the specified list with an automatically
generated
TableFormat .
|
protected TransformedList | createSwingThreadProxyList(EventList source) - This method exists as a hook for subclasses that may have custom
threading needs within their EventTableModels.
|
void | dispose() - Releases the resources consumed by this
EventTableModel so that it
may eventually be garbage collected.
|
Class | getColumnClass(int columnIndex) - Gets the class of elements in the specified column.
|
int | getColumnCount() - Get the column count as specified by the table format.
|
String | getColumnName(int column) - Fetch the name for the specified column.
|
E | getElementAt(int index) - Retrieves the value at the specified location from the table.
|
protected ca.odell.glazedlists.swing.MutableTableModelEvent | getMutableTableModelEvent()
|
int | getRowCount() - The number of rows equals the number of entries in the source event list.
|
Object | getValueAt(int row, int column) - Retrieves the value at the specified location of the table.
|
protected void | handleListChange(ListEvent listChanges) - Default implementation for converting a
ListEvent to
TableModelEvents.
|
boolean | isCellEditable(int row, int column) - Delegates the question of whether the cell is editable or not to the
backing TableFormat if it is a
WritableTableFormat .
|
void | listChanged(ListEvent listChanges) - For implementing the ListEventListener interface.
|
void | setTableFormat(TableFormat tableFormat) - Sets the
TableFormat that will extract column data from each
element.
|
void | setValueAt(Object editedValue, int row, int column) - Attempts to update the object for the given row with the
editedValue .
|
TableFormat | super E> getTableFormat() - Gets the Table Format.
|
source
protected EventList source
swingThreadSource
protected TransformedList swingThreadSource
the proxy moves events to the Swing Event Dispatch thread
EventTableModel
public EventTableModel(EventList source,
E> tableFormat)
Creates a new table model that extracts column data from the given
source
using the the given tableFormat
.
source
- the EventList that provides the row objectstableFormat
- the object responsible for extracting column data
from the row objects
EventTableModel
public EventTableModel(EventList source,
String[] propertyNames,
String[] columnLabels,
boolean[] writable)
Creates a new table that renders the specified list with an automatically
generated
TableFormat
. It uses JavaBeans and reflection to create
a
TableFormat
as specified.
Note that the classes which will be obfuscated may not work with
reflection. In this case, implement a
TableFormat
manually.
source
- the EventList that provides the row objectspropertyNames
- an array of property names in the JavaBeans format.
For example, if your list contains Objects with the methods getFirstName(),
setFirstName(String), getAge(), setAge(Integer), then this array should
contain the two strings "firstName" and "age". This format is specified
by the JavaBeans java.beans.PropertyDescriptor
.columnLabels
- the corresponding column names for the listed property
names. For example, if your columns are "firstName" and "age", then
your labels might be "First Name" and "Age".writable
- an array of booleans specifying which of the columns in
your table are writable.
createSwingThreadProxyList
protected TransformedList createSwingThreadProxyList(EventList source)
This method exists as a hook for subclasses that may have custom
threading needs within their EventTableModels. By default, this method
will wrap the given source
in a SwingThreadProxyList if it
is not already a SwingThreadProxyList. Subclasses may replace this logic
and return either a custom ThreadProxyEventList of their choosing, or
return null
or the source
unchanged in order
to indicate that NO ThreadProxyEventList is desired.
In these cases it is expected that some external mechanism will ensure
that threading is handled correctly.
source
- the EventList that provides the row objects
- the source wrapped in some sort of ThreadProxyEventList if
Thread-proxying is desired, or either
null
or the
source
unchanged to indicate that NO
Thread-proxying is desired
dispose
public void dispose()
getColumnClass
public Class getColumnClass(int columnIndex)
Gets the class of elements in the specified column. This behaviour can be
customized by implementing the
AdvancedTableFormat
interface.
getColumnCount
public int getColumnCount()
Get the column count as specified by the table format.
getColumnName
public String getColumnName(int column)
Fetch the name for the specified column.
getElementAt
public E getElementAt(int index)
Retrieves the value at the specified location from the table.
This may be used by renderers to paint the cells of a row differently
based on the entire value for that row.
getMutableTableModelEvent
protected final ca.odell.glazedlists.swing.MutableTableModelEvent getMutableTableModelEvent()
- reusable TableModelEvent for broadcasting changes
getRowCount
public int getRowCount()
The number of rows equals the number of entries in the source event list.
getValueAt
public Object getValueAt(int row,
int column)
Retrieves the value at the specified location of the table.
handleListChange
protected void handleListChange(ListEvent listChanges)
Default implementation for converting a
ListEvent
to
TableModelEvents. There will be one TableModelEvent per ListEvent block.
Subclasses may choose to implement a different conversion.
listChanges
- ListEvent to translate
isCellEditable
public boolean isCellEditable(int row,
int column)
Delegates the question of whether the cell is editable or not to the
backing TableFormat if it is a
WritableTableFormat
. Otherwise,
the column is assumed to be uneditable.
listChanged
public void listChanged(ListEvent listChanges)
For implementing the ListEventListener interface. This sends changes
to the table which repaints the table cells. Because this class is
backed by GlazedListsSwing
, all natural
calls to this method are guaranteed to occur on the Swing EDT.
- listChanged in interface ListEventListener<E>
setTableFormat
public void setTableFormat(TableFormat tableFormat)
Sets the
TableFormat
that will extract column data from each
element. This has some very important consequences. Any cell selections
will be lost - this is due to the fact that the TableFormats may have
different numbers of columns, and JTable has no event to specify columns
changing without rows.
setValueAt
public void setValueAt(Object editedValue,
int row,
int column)
super E> getTableFormat
public TableFormat super E> getTableFormat()
Gets the Table Format.
Glazed Lists, Copyright © 2003 publicobject.com, O'Dell Engineering.
Documentation build by pbuilder at 2009-07-14 22:05