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.AbstractMoveableTableModel
Model 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_Data
the underlying data.protected boolean
m_ReadOnly
whether 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.int
getColumnCount()
The number of columns.String
getColumnName(int column)
Returns the column name.List<DataContainer>
getData()
Returns the underlying data.int
getRowCount()
The number of datasets loaded.Object
getValueAt(int rowIndex, int columnIndex)
Returns the value at the specified position.boolean
isCellEditable(int rowIndex, int columnIndex)
Returns whether a cell is editable.boolean
isReadOnly()
Returns whether the model is readonly.void
setData(List<DataContainer> value)
Sets the underlying data and notifies listeners of change.void
setData(List<DataContainer> value, boolean notify)
Sets the underlying data.void
setValueAt(Object aValue, int rowIndex, int columnIndex)
Sets the value at the specified position, if possible.protected void
swap(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:
getColumnName
in interfaceTableModel
- Overrides:
getColumnName
in 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:
getColumnClass
in interfaceTableModel
- Overrides:
getColumnClass
in classAbstractTableModel
- Parameters:
columnIndex
- the column- Returns:
- the class
-
isCellEditable
public boolean isCellEditable(int rowIndex, int columnIndex)
Returns whether a 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 at the specified position, if possible.- Specified by:
setValueAt
in interfaceTableModel
- Overrides:
setValueAt
in 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:
swap
in classadams.gui.core.AbstractMoveableTableModel
- Parameters:
firstIndex
- the index of the first rowsecondIndex
- the index of the second row
-
-