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 Stringm_CheckColNamethe name for the "check" column.protected Tm_Modelthe wrapped table model.protected boolean[]m_Selectedwhether 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 voidcheck(boolean check)Marks all rows with the specified check state.voidcheck(int[] rows)Marks the rows as checked.voidcheckAll()Marks all rows as checked.voidcheckNone()Marks all rows as un-checked.voidclear()Clears the internal model.booleangetCheckedAt(int row)Returns whether the row at the specified position is checked.intgetCheckedCount()Returns how many rows are currently checked.ClassgetColumnClass(int columnIndex)Returns the class type of the column.intgetColumnCount()Returns the number of columns in the table.StringgetColumnName(int column)Returns the name of the column.TgetModel()Returns the underlying model.intgetRowCount()Returns the number of rows in the model.ObjectgetValueAt(int row, int column)Returns the value at the given position.voidinvertChecked()Inverts the checked state.booleanisCellEditable(int rowIndex, int columnIndex)Returns whether the cell is editable.booleanisSearchMatch(SearchParameters params, int row)Tests whether the search matches the specified row.voidsetCheckedAt(int row, boolean checked)Sets the checked state.voidsetValueAt(Object aValue, int rowIndex, int columnIndex)Sets the value of the cell.voiduncheck(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:
getRowCountin interfaceTableModel- Returns:
- the number of rows
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the table.- Specified by:
getColumnCountin interfaceTableModel- Returns:
- the number of columns
-
getColumnName
public String getColumnName(int column)
Returns the name of the column.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein 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:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin 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:
getValueAtin 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:
isCellEditablein interfaceTableModel- Overrides:
isCellEditablein 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:
setValueAtin interfaceTableModel- Overrides:
setValueAtin 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:
clearin interfaceClearableModel
-
isSearchMatch
public boolean isSearchMatch(SearchParameters params, int row)
Tests whether the search matches the specified row.- Specified by:
isSearchMatchin interfaceCustomSearchTableModel- Parameters:
params- the search parametersrow- the row of the underlying, unsorted model- Returns:
- true if the search matches this row
-
-