java.lang.Object
javax.swing.table.AbstractTableModel
org.autogui.swing.table.ObjectTableModel
- All Implemented Interfaces:
Serializable
,TableModel
,ObjectTableModelColumns.ObjectTableModelColumnsListener
- Direct Known Subclasses:
GuiSwingTableModelCollection
public class ObjectTableModel
extends AbstractTableModel
implements ObjectTableModelColumns.ObjectTableModelColumnsListener
a table-model based on a list of row objects
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
the return value ofbuildDataArray(Runnable)
static class
a builder accepting aTableTargetCellAction
and wrapping it to aObjectTableModel.TableTargetCellExecutionAction
.static class
a menu builder without adding titlesstatic class
a menu builder with empty separatorsstatic class
refreshColumns()
seems to clear column selection between the first size-obtaining step and the after-step.static class
a menu builder for table itemsstatic interface
a menu builder forTableTargetCellAction
sstatic class
an action for wrappingTableTargetCellAction
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ObjectTableModelColumns
protected Object[][]
cached computed valuesstatic Object
protected GuiSwingTaskRunner
protected JTable
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildDataArray
(Runnable delayedAfterInEvent) void
clearRowData
(int rowIndex) void
columnAdded
(ObjectTableColumn column) void
columnViewUpdate
(ObjectTableColumn column) <RetType> GuiSwingTaskRunner.ContextTaskResult
<RetType> executeContextTask
(Supplier<RetType> task, Consumer<GuiSwingTaskRunner.ContextTaskResult<RetType>> afterTask) <RetType> GuiSwingTaskRunner.ContextTaskResult
<RetType> executeContextTask
(ObjectTableColumn column, Supplier<RetType> task, Consumer<GuiSwingTaskRunner.ContextTaskResult<RetType>> afterTask) void
update existing rows without changing selectiongetBuilderForRowsOrCells
(JTable table, List<ObjectTableColumn> cols, boolean row) getBuildersForRowsOrCells
(JTable table, List<ObjectTableColumn> cols, boolean row) getColumnAt
(int index) Class
<?> getColumnClass
(int columnIndex) int
getColumnName
(int column) getRowAtIndex
(int row) int
int
getTable()
getValueAt
(int rowIndex, int columnIndex) getValueAtWithError
(int rowIndex, int columnIndex) executed under the event thread.void
void
initTableRowHeight
(JTable table) void
initTableRowSorter
(JTable table) initTableScrollPane
(JComponent table) void
initTableWithoutScrollPane
(JTable table) protected void
invokeLater
(Runnable task) running the task in the event threadboolean
isCellEditable
(int rowIndex, int columnIndex) void
offerValueForSource
(Object aValue, int rowIndex, int columnIndex) void
offsetValueForSourceFuture
(Object rowObject, Object aValue, int rowIndex, int columnIndex, Future<?> future) void
void
refreshColumns
(int... columnIndices) executed under event threadvoid
refreshColumns
(Collection<Integer> columnIndices) executed under event threadvoid
executed under event threadvoid
refreshRow
(int rowIndex) executed under event threadvoid
refreshRows
(int... rowIndices) executed under event threadvoid
setFutureWaiter
(Consumer<Runnable> futureWaiter) void
void
void
setValueAt
(Object aValue, int rowIndex, int columnIndex) void
setValueAtWithError
(Object aValue, int rowIndex, int columnIndex) executed under event thread.takeValueFromSource
(Object[] rowData, int rowIndex, int columnIndex) the column'sObjectTableColumn.getCellValue(Object, int, int, GuiReprValue.ObjectSpecifier)
might return aFuture
object, and then it waits completion of the task intakeValueFromSourceFuture(Object[], int, int, Future)
.void
takeValueFromSourceFuture
(Object[] rowData, int rowIndex, int columnIndex, Future<?> future) wait the completion of a task up to 1 sec.taskValueFromSourceAfter
(Object[] rowData, int rowIndex, int columnIndex, Object cellObject) Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
-
Field Details
-
table
-
source
-
columns
-
data
cached computed values -
futureWaiter
-
runner
-
NULL_CELL
-
-
Constructor Details
-
ObjectTableModel
public ObjectTableModel() -
ObjectTableModel
-
-
Method Details
-
initColumns
public void initColumns() -
setFutureWaiter
-
getFutureWaiter
-
setTable
-
getTable
-
getColumnName
- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
-
getColumnModel
-
getColumnAt
-
getColumnClass
- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
-
getColumns
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceTableModel
-
refreshColumns
public void refreshColumns() -
initTableWithScroll
-
initTable
-
initTableWithoutScrollPane
-
initTableRowSorter
-
initTableRowHeight
-
initTableScrollPane
-
executeContextTask
public <RetType> GuiSwingTaskRunner.ContextTaskResult<RetType> executeContextTask(Supplier<RetType> task, Consumer<GuiSwingTaskRunner.ContextTaskResult<RetType>> afterTask) -
executeContextTask
public <RetType> GuiSwingTaskRunner.ContextTaskResult<RetType> executeContextTask(ObjectTableColumn column, Supplier<RetType> task, Consumer<GuiSwingTaskRunner.ContextTaskResult<RetType>> afterTask) - Type Parameters:
RetType
- the task result type- Parameters:
column
- the column related to the tasktask
- executed taskafterTask
- the second task. nullable- Returns:
- result of the task
- Since:
- 1.6
-
setSource
-
getCollectionFromSource
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceTableModel
-
getRowCountUpdated
public int getRowCountUpdated() -
getRowAtIndex
-
buildDataArray
-
getValueAt
- Specified by:
getValueAt
in interfaceTableModel
-
getValueAtWithError
executed under the event thread.the cell value is obtained via the specified
ObjectTableColumn
with the specified row ofgetCollectionFromSource()
. the cell value is cached and obtained bytakeValueFromSource(Object[], int, int)
at the first time.- Parameters:
rowIndex
- the target rowcolumnIndex
- the target column- Returns:
- the cell value, nullable (waiting for obtaining the value)
-
takeValueFromSource
the column'sObjectTableColumn.getCellValue(Object, int, int, GuiReprValue.ObjectSpecifier)
might return aFuture
object, and then it waits completion of the task intakeValueFromSourceFuture(Object[], int, int, Future)
. The method is run ingetFutureWaiter()
(default is just call the method)- Parameters:
rowData
- the row array which the returned cell value will be storedrowIndex
- the row indexcolumnIndex
- the column index- Returns:
- the cell value, nullable
-
taskValueFromSourceAfter
-
takeValueFromSourceFuture
public void takeValueFromSourceFuture(Object[] rowData, int rowIndex, int columnIndex, Future<?> future) wait the completion of a task up to 1 sec. , store the result to the array, and notify the update (as a later event process). If it overs the time, it just throws a runtime-exception.- Parameters:
rowData
- the stored arrayrowIndex
- the row indexcolumnIndex
- the column indexfuture
- the task
-
setValueAt
- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
-
setValueAtWithError
executed under event thread.- Parameters:
aValue
- the column value to be setrowIndex
- the target rowcolumnIndex
- the target column
-
offerValueForSource
-
offsetValueForSourceFuture
-
refreshData
public void refreshData()executed under event thread -
refreshRow
public void refreshRow(int rowIndex) executed under event thread- Parameters:
rowIndex
- the target row index
-
clearRowData
public void clearRowData(int rowIndex) -
refreshRows
public void refreshRows(int... rowIndices) executed under event thread- Parameters:
rowIndices
- the target rows
-
refreshColumns
executed under event thread- Parameters:
columnIndices
- the target columns
-
refreshColumns
public void refreshColumns(int... columnIndices) executed under event thread- Parameters:
columnIndices
- the target columns
-
columnAdded
- Specified by:
columnAdded
in interfaceObjectTableModelColumns.ObjectTableModelColumnsListener
-
columnViewUpdate
- Specified by:
columnViewUpdate
in interfaceObjectTableModelColumns.ObjectTableModelColumnsListener
-
fireTableRowsUpdatedAll
public void fireTableRowsUpdatedAll()update existing rows without changing selection -
invokeLater
running the task in the event thread- Parameters:
task
- the task
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex) - Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
-
getBuilderForRowsOrCells
public PopupExtension.PopupMenuBuilder getBuilderForRowsOrCells(JTable table, List<ObjectTableColumn> cols, boolean row) -
getBuildersForRowsOrCells
public List<PopupCategorized.CategorizedMenuItem> getBuildersForRowsOrCells(JTable table, List<ObjectTableColumn> cols, boolean row)
-