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 enumthe return value ofbuildDataArray(Runnable)static classa builder accepting aTableTargetCellActionand wrapping it to aObjectTableModel.TableTargetCellExecutionAction.static classa menu builder without adding titlesstatic classa menu builder with empty separatorsstatic classrefreshColumns()seems to clear column selection between the first size-obtaining step and the after-step.static classa menu builder for table itemsstatic interfacea menu builder forTableTargetCellActionsstatic classan action for wrappingTableTargetCellAction -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ObjectTableModelColumnsprotected Object[][]cached computed valuesstatic Objectprotected GuiSwingTaskRunnerprotected JTableFields inherited from class javax.swing.table.AbstractTableModel
listenerList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuildDataArray(Runnable delayedAfterInEvent) voidclearRowData(int rowIndex) voidcolumnAdded(ObjectTableColumn column) voidcolumnViewUpdate(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) voidupdate 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) intgetColumnName(int column) getRowAtIndex(int row) intintgetTable()getValueAt(int rowIndex, int columnIndex) getValueAtWithError(int rowIndex, int columnIndex) executed under the event thread.voidvoidinitTableRowHeight(JTable table) voidinitTableRowSorter(JTable table) initTableScrollPane(JComponent table) voidinitTableWithoutScrollPane(JTable table) protected voidinvokeLater(Runnable task) running the task in the event threadbooleanisCellEditable(int rowIndex, int columnIndex) voidofferValueForSource(Object aValue, int rowIndex, int columnIndex) voidoffsetValueForSourceFuture(Object rowObject, Object aValue, int rowIndex, int columnIndex, Future<?> future) voidvoidrefreshColumns(int... columnIndices) executed under event threadvoidrefreshColumns(Collection<Integer> columnIndices) executed under event threadvoidexecuted under event threadvoidrefreshRow(int rowIndex) executed under event threadvoidrefreshRows(int... rowIndices) executed under event threadvoidsetFutureWaiter(Consumer<Runnable> futureWaiter) voidvoidvoidsetValueAt(Object aValue, int rowIndex, int columnIndex) voidsetValueAtWithError(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 aFutureobject, and then it waits completion of the task intakeValueFromSourceFuture(Object[], int, int, Future).voidtakeValueFromSourceFuture(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:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel
-
getColumnModel
-
getColumnAt
-
getColumnClass
- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel
-
getColumns
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCountin 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:
getRowCountin interfaceTableModel
-
getRowCountUpdated
public int getRowCountUpdated() -
getRowAtIndex
-
buildDataArray
-
getValueAt
- Specified by:
getValueAtin interfaceTableModel
-
getValueAtWithError
executed under the event thread.the cell value is obtained via the specified
ObjectTableColumnwith 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 aFutureobject, 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:
setValueAtin interfaceTableModel- Overrides:
setValueAtin 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:
columnAddedin interfaceObjectTableModelColumns.ObjectTableModelColumnsListener
-
columnViewUpdate
- Specified by:
columnViewUpdatein 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:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein 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)
-