|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
ca.odell.glazedlists.swing.DefaultEventTableModel<E>
public class DefaultEventTableModel<E>
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)
and
wrap the source list (or some part of the source list's pipeline) using
GlazedListsSwing#swingThreadProxyList(EventList).
GlazedListsSwing.swingThreadProxyList(EventList)
,
SwingUtilities.invokeAndWait(Runnable)
,
Bug 112,
Bug 146,
Bug 177,
Serialized FormField Summary | |
---|---|
protected EventList<E> |
source
the source of data for this TableModel, which may or may not be #swingThreadSource |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
protected |
DefaultEventTableModel(EventList<E> source,
boolean disposeSource,
TableFormat<? super E> tableFormat)
Creates a new table model that extracts column data from the given source using the the given tableFormat . |
|
DefaultEventTableModel(EventList<E> source,
TableFormat<? super E> tableFormat)
Creates a new table model that extracts column data from the given source using the the given tableFormat . |
Method Summary | |
---|---|
void |
dispose()
Releases the resources consumed by this AdvancedTableModel 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 MutableTableModelEvent |
getMutableTableModelEvent()
|
int |
getRowCount()
The number of rows equals the number of entries in the source event list. |
TableFormat<? super E> |
getTableFormat()
Gets the TableFormat used by this table model. |
Object |
getValueAt(int row,
int column)
Retrieves the value at the specified location of the table. |
protected void |
handleListChange(ListEvent<E> 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<E> listChanges)
For implementing the ListEventListener interface. |
void |
setTableFormat(TableFormat<? super E> 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 . |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, 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 |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, removeTableModelListener |
Field Detail |
---|
protected EventList<E> source
#swingThreadSource
Constructor Detail |
---|
public DefaultEventTableModel(EventList<E> source, TableFormat<? super E> tableFormat)
source
using the the given tableFormat
.
source
- the EventList that provides the row objectstableFormat
- the object responsible for extracting column data
from the row objectsprotected DefaultEventTableModel(EventList<E> source, boolean disposeSource, TableFormat<? super E> tableFormat)
source
using the the given tableFormat
.
source
- the EventList that provides the row objectsdiposeSource
- true
if the source list should be disposed when disposing
this model, false
otherwisetableFormat
- the object responsible for extracting column data
from the row objectsMethod Detail |
---|
public TableFormat<? super E> getTableFormat()
TableFormat
used by this table model.
getTableFormat
in interface AdvancedTableModel<E>
public void setTableFormat(TableFormat<? super E> tableFormat)
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.
setTableFormat
in interface AdvancedTableModel<E>
public E getElementAt(int index)
This may be used by renderers to paint the cells of a row differently based on the entire value for that row.
getElementAt
in interface AdvancedTableModel<E>
TableModel.getValueAt(int,int)
public void listChanged(ListEvent<E> listChanges)
GlazedListsSwing.swingThreadProxyList(ca.odell.glazedlists.EventList)
, all natural
calls to this method are guaranteed to occur on the Swing EDT.
listChanged
in interface ListEventListener<E>
listChanges
- a ListEvent
describing the changes to the listprotected void handleListChange(ListEvent<E> listChanges)
ListEvent
to
TableModelEvents. There will be one TableModelEvent per ListEvent block.
Subclasses may choose to implement a different conversion.
listChanges
- ListEvent to translateprotected final MutableTableModelEvent getMutableTableModelEvent()
public String getColumnName(int column)
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
public int getRowCount()
getRowCount
in interface TableModel
public int getColumnCount()
getColumnCount
in interface TableModel
public Class getColumnClass(int columnIndex)
AdvancedTableFormat
interface.
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
public Object getValueAt(int row, int column)
getValueAt
in interface TableModel
public boolean isCellEditable(int row, int column)
WritableTableFormat
. Otherwise,
the column is assumed to be uneditable.
isCellEditable
in interface TableModel
isCellEditable
in class AbstractTableModel
public void setValueAt(Object editedValue, int row, int column)
editedValue
. This requires the backing TableFormat
be a WritableTableFormat
. WritableTableFormat.setColumnValue(E, java.lang.Object, int)
is expected to contain the logic for updating the object at the given
row
with the editedValue
which was in the
given column
.
setValueAt
in interface TableModel
setValueAt
in class AbstractTableModel
public void dispose()
AdvancedTableModel
so that it
may eventually be garbage collected.
An AdvancedTableModel
will be garbage collected without a call to
AdvancedTableModel.dispose()
, but not before its source EventList
is garbage
collected. By calling AdvancedTableModel.dispose()
, you allow the AdvancedTableModel
to be garbage collected before its source EventList
. This is
necessary for situations where an AdvancedTableModel
is short-lived but
its source EventList
is long-lived.
Warning: It is an error
to call any method on an AdvancedTableModel
after it has been disposed.
As such, this AdvancedTableModel
should be detached from its
corresponding Component before it is disposed.
dispose
in interface AdvancedTableModel<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |