Class DataTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.core.AbstractMoveableTableModel
-
- adams.gui.tools.wekainvestigator.datatable.DataTableModel
-
- All Implemented Interfaces:
adams.core.logging.LoggingLevelHandler,adams.core.logging.LoggingSupporter,adams.data.spreadsheet.SpreadSheetSupporter,adams.gui.core.MoveableTableModel,Serializable,TableModel
public class DataTableModel extends adams.gui.core.AbstractMoveableTableModelModel for displaying the loaded data.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected List<DataContainer>m_Datathe underlying data.protected booleanm_ReadOnlywhether the model is read-only.-
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 DataTableModel(List<DataContainer> data, boolean readOnly)Initializes the model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Class<?>getColumnClass(int columnIndex)Returns the class type for the column.intgetColumnCount()The number of columns.StringgetColumnName(int column)Returns the column name.List<DataContainer>getData()Returns the underlying data.intgetRowCount()The number of datasets loaded.ObjectgetValueAt(int rowIndex, int columnIndex)Returns the value at the specified position.booleanisCellEditable(int rowIndex, int columnIndex)Returns whether a cell is editable.booleanisReadOnly()Returns whether the model is readonly.voidsetData(List<DataContainer> value)Sets the underlying data and notifies listeners of change.voidsetData(List<DataContainer> value, boolean notify)Sets the underlying data.voidsetValueAt(Object aValue, int rowIndex, int columnIndex)Sets the value at the specified position, if possible.protected voidswap(int firstIndex, int secondIndex)Swaps the two rows.-
Methods inherited from class adams.gui.core.AbstractMoveableTableModel
canMoveDown, canMoveUp, moveBottom, moveDown, moveItems, moveTop, moveUp
-
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_Data
protected List<DataContainer> m_Data
the underlying data.
-
m_ReadOnly
protected boolean m_ReadOnly
whether the model is read-only.
-
-
Constructor Detail
-
DataTableModel
public DataTableModel(List<DataContainer> data, boolean readOnly)
Initializes the model.- Parameters:
data- the data to usereadOnly- whether the model is readonly
-
-
Method Detail
-
isReadOnly
public boolean isReadOnly()
Returns whether the model is readonly.- Returns:
- true if readonly
-
getRowCount
public int getRowCount()
The number of datasets loaded.- Returns:
- the number of datasets
-
getColumnCount
public int getColumnCount()
The number of columns.- Returns:
- the number of columns
-
getColumnName
public String getColumnName(int column)
Returns the column name.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel- Parameters:
column- the index of the column- Returns:
- the name
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
Returns the value at the specified position.- Parameters:
rowIndex- the rowcolumnIndex- the column- Returns:
- the value
-
getColumnClass
public Class<?> getColumnClass(int columnIndex)
Returns the class type for the column.- Specified by:
getColumnClassin interfaceTableModel- Overrides:
getColumnClassin classAbstractTableModel- Parameters:
columnIndex- the column- Returns:
- the class
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)Returns whether a 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 at the specified position, if possible.- Specified by:
setValueAtin interfaceTableModel- Overrides:
setValueAtin classAbstractTableModel- Parameters:
aValue- the value to setrowIndex- the rowcolumnIndex- the column
-
setData
public void setData(List<DataContainer> value)
Sets the underlying data and notifies listeners of change.- Parameters:
value- the data to use
-
setData
public void setData(List<DataContainer> value, boolean notify)
Sets the underlying data.- Parameters:
value- the data to usenotify- whether to notify listeners that data has changed
-
getData
public List<DataContainer> getData()
Returns the underlying data.- Returns:
- the data
-
swap
protected void swap(int firstIndex, int secondIndex)Swaps the two rows.- Specified by:
swapin classadams.gui.core.AbstractMoveableTableModel- Parameters:
firstIndex- the index of the first rowsecondIndex- the index of the second row
-
-