Class 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 Detail

      • 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 use
        readOnly - 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
      • getValueAt

        public Object getValueAt​(int rowIndex,
                                 int columnIndex)
        Returns the value at the specified position.
        Parameters:
        rowIndex - the row
        columnIndex - the column
        Returns:
        the value
      • isCellEditable

        public boolean isCellEditable​(int rowIndex,
                                      int columnIndex)
        Returns whether a cell is editable.
        Specified by:
        isCellEditable in interface TableModel
        Overrides:
        isCellEditable in class AbstractTableModel
        Parameters:
        rowIndex - the row
        columnIndex - 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 interface TableModel
        Overrides:
        setValueAt in class AbstractTableModel
        Parameters:
        aValue - the value to set
        rowIndex - the row
        columnIndex - 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 use
        notify - 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 class adams.gui.core.AbstractMoveableTableModel
        Parameters:
        firstIndex - the index of the first row
        secondIndex - the index of the second row