Class AdapterBasicTableModel

    • Method Detail

      • getValueAt

        public Object getValueAt​(List<Integer> row,
                                 int col)
        Retrieves the value at the given row and column.
        Specified by:
        getValueAt in interface WTable.TableModel
        Parameters:
        row - - the row index.
        col - - the column index. Column of -1 indicates row has a renderer.
        Returns:
        the value at the given row and column.
      • isCellEditable

        public boolean isCellEditable​(List<Integer> row,
                                      int col)
        Indicates whether the given cell is editable.
        Specified by:
        isCellEditable in interface WTable.TableModel
        Parameters:
        row - - the row index.
        col - - the column index. Column of -1 indicates row has a renderer.
        Returns:
        true if the given cell is editable, false otherwise.
      • setValueAt

        public void setValueAt​(Object value,
                               List<Integer> row,
                               int col)
        Sets the value at the given row and column.
        Specified by:
        setValueAt in interface WTable.TableModel
        Parameters:
        value - the value to set.
        row - - the row index.
        col - - the column index.
      • isSortable

        public boolean isSortable​(int col)
        Indicates whether the model supports sorting by the given column.
        Specified by:
        isSortable in interface WTable.TableModel
        Parameters:
        col - the column index.
        Returns:
        true if the model is sortable by the given column, false otherwise.
      • sort

        public int[] sort​(int col,
                          boolean ascending)

        Sorts the data by the given column. Any previous sorting should be disregarded.

        Data models must implement sorting in one of two ways.

        1. If the data is accessible locally by the data model (ie. a sort won't result in a service call to obtain sorted data), then this method should not sort the actual data, but return a row-index mapping which the table will use to access the data. Row selection and expansion will be updated to use the new row indices.

          For example, if the data for the column is {"a", "b", "d", "c"}, then an ascending sort should return {0, 1, 3, 2}, and a descending sort {2, 3, 1, 0}.

        2. If the data is not accessible locally by the data model, or the model is otherwise unable to perform a mapping between old and new row indices, then the model should sort the actual data, and return null. In this case, the table will reset any row selection or expansion.

        Specified by:
        sort in interface WTable.TableModel
        Parameters:
        col - the column to sort on
        ascending - true for an ascending sort, false for descending.
        Returns:
        the row indices in sort order, or null if row mappings can not be determined.
      • isDisabled

        public boolean isDisabled​(List<Integer> row)
        Indicates whether the given row is disabled.
        Specified by:
        isDisabled in interface WTable.TableModel
        Parameters:
        row - the row index
        Returns:
        true if the row is disabled, false otherwise.
      • isSelectable

        public boolean isSelectable​(List<Integer> row)
        Indicates whether the given row is selectable.
        Specified by:
        isSelectable in interface WTable.TableModel
        Parameters:
        row - the row index
        Returns:
        true if the row is selectable, false otherwise.
      • isExpandable

        public boolean isExpandable​(List<Integer> row)
        Description copied from interface: WTable.TableModel
        Indicates whether the given row is expandable.
        Specified by:
        isExpandable in interface WTable.TableModel
        Parameters:
        row - the row index
        Returns:
        false as data is not expandable
      • getRowCount

        public int getRowCount()
        Retrieves the number of rows for the root (ie top) level.
        Specified by:
        getRowCount in interface WTable.TableModel
        Returns:
        the number of rows in the model for the root (ie top) level.
      • hasChildren

        public boolean hasChildren​(List<Integer> row)
        Description copied from interface: WTable.TableModel
        Allows the model to report if the row has children without actually having to determine the number of children (as it might not be known).
        Specified by:
        hasChildren in interface WTable.TableModel
        Parameters:
        row - ignored
        Returns:
        false as data is not expandable
      • getRowKey

        public Object getRowKey​(List<Integer> row)
        Retrieves the key (ie bean) used to uniquely identify this row.

        The usual implementation of this method would just return the row id passed in.

        However, if you are required to dynamically add/remove rows in the model, which would change the row index, then the implementation of this method needs to return an object that uniquely identifies this row.

        When rows have been added/removed, the WTable.handleDataChanged() method on WTable needs to be called.

        Specified by:
        getRowKey in interface WTable.TableModel
        Parameters:
        row - the row index
        Returns:
        the key (ie bean) used to uniquely identify this row