Package adams.gui.core
Class CheckableTableModel<T extends TableModel>
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.core.CheckableTableModel<T>
-
- All Implemented Interfaces:
LoggingLevelHandler
,LoggingSupporter
,SpreadSheetSupporter
,ClearableModel
,CustomSearchTableModel
,Serializable
,TableModel
public class CheckableTableModel<T extends TableModel> extends AbstractBaseTableModel implements ClearableModel, CustomSearchTableModel
Meta-model that wraps another table model and allows "ticking" of rows.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_CheckColName
the name for the "check" column.protected T
m_Model
the wrapped table model.protected boolean[]
m_Selected
whether a row got checked.-
Fields inherited from class adams.gui.core.AbstractBaseTableModel
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description CheckableTableModel(T model, String checkColName)
Initializes the model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
check(boolean check)
Marks all rows with the specified check state.void
check(int[] rows)
Marks the rows as checked.void
checkAll()
Marks all rows as checked.void
checkNone()
Marks all rows as un-checked.void
clear()
Clears the internal model.boolean
getCheckedAt(int row)
Returns whether the row at the specified position is checked.int
getCheckedCount()
Returns how many rows are currently checked.Class
getColumnClass(int columnIndex)
Returns the class type of the column.int
getColumnCount()
Returns the number of columns in the table.String
getColumnName(int column)
Returns the name of the column.T
getModel()
Returns the underlying model.int
getRowCount()
Returns the number of rows in the model.Object
getValueAt(int row, int column)
Returns the value at the given position.void
invertChecked()
Inverts the checked state.boolean
isCellEditable(int rowIndex, int columnIndex)
Returns whether the cell is editable.boolean
isSearchMatch(SearchParameters params, int row)
Tests whether the search matches the specified row.void
setCheckedAt(int row, boolean checked)
Sets the checked state.void
setValueAt(Object aValue, int rowIndex, int columnIndex)
Sets the value of the cell.void
uncheck(int[] rows)
Marks the rows as unchecked.-
Methods inherited from class adams.gui.core.AbstractBaseTableModel
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, setLoggingLevel, toSpreadSheet, toString
-
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, wait, wait, wait
-
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, removeTableModelListener
-
-
-
-
Field Detail
-
m_Model
protected T extends TableModel m_Model
the wrapped table model.
-
m_Selected
protected boolean[] m_Selected
whether a row got checked.
-
m_CheckColName
protected String m_CheckColName
the name for the "check" column.
-
-
Method Detail
-
getModel
public T getModel()
Returns the underlying model.- Returns:
- the model
-
getRowCount
public int getRowCount()
Returns the number of rows in the model.- Specified by:
getRowCount
in interfaceTableModel
- Returns:
- the number of rows
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Specified by:
getColumnCount
in interfaceTableModel
- Returns:
- the number of columns
-
getColumnName
public String getColumnName(int column)
Returns the name of the column.- Specified by:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in classAbstractTableModel
- Parameters:
column
- the column to get the name for- Returns:
- the name of the column
-
getColumnClass
public Class getColumnClass(int columnIndex)
Returns the class type of the column.- Specified by:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- the column to get the class for- Returns:
- the class for the column
-
getValueAt
public Object getValueAt(int row, int column)
Returns the value at the given position.- Specified by:
getValueAt
in interfaceTableModel
- Parameters:
row
- the rowcolumn
- the column- Returns:
- the value
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
Returns whether the cell is editable.- Specified by:
isCellEditable
in interfaceTableModel
- Overrides:
isCellEditable
in classAbstractTableModel
- Parameters:
rowIndex
- the rowcolumnIndex
- the column- Returns:
- true if editable
-
setValueAt
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
Sets the value of the cell.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in classAbstractTableModel
- Parameters:
aValue
- the value to setrowIndex
- the rowcolumnIndex
- the column
-
getCheckedAt
public boolean getCheckedAt(int row)
Returns whether the row at the specified position is checked.- Parameters:
row
- the (actual, not visible) position of the row- Returns:
- true if checked
-
setCheckedAt
public void setCheckedAt(int row, boolean checked)
Sets the checked state.- Parameters:
row
- the row to updatechecked
- the checked state
-
checkAll
public void checkAll()
Marks all rows as checked.
-
checkNone
public void checkNone()
Marks all rows as un-checked.
-
check
protected void check(boolean check)
Marks all rows with the specified check state.
-
check
public void check(int[] rows)
Marks the rows as checked.
-
uncheck
public void uncheck(int[] rows)
Marks the rows as unchecked.
-
invertChecked
public void invertChecked()
Inverts the checked state.
-
getCheckedCount
public int getCheckedCount()
Returns how many rows are currently checked.- Returns:
- the number of checked
-
clear
public void clear()
Clears the internal model.- Specified by:
clear
in interfaceClearableModel
-
isSearchMatch
public boolean isSearchMatch(SearchParameters params, int row)
Tests whether the search matches the specified row.- Specified by:
isSearchMatch
in interfaceCustomSearchTableModel
- Parameters:
params
- the search parametersrow
- the row of the underlying, unsorted model- Returns:
- true if the search matches this row
-
-