Class AbstractTableModel

    • Constructor Detail

      • AbstractTableModel

        public AbstractTableModel()
    • Method Detail

      • 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
      • hasChildren

        public boolean hasChildren​(List<Integer> row)
        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 - the row index
        Returns:
        true if the row has children
      • sort

        public int[] sort​(int col,
                          boolean ascending)
        This model does not support the concept of sorting by default. Subclasses will need to override this method and isSortable(int) to support sorting.
        Specified by:
        sort in interface WTable.TableModel
        Parameters:
        col - ignored.
        ascending - ignored.
        Returns:
        null
      • isSortable

        public boolean isSortable​(int col)
        This model does not support the concept of sorting by default. Subclasses will need to override this method and sort(int, boolean) to support sorting.
        Specified by:
        isSortable in interface WTable.TableModel
        Parameters:
        col - ignored.
        Returns:
        false.
      • isDisabled

        public boolean isDisabled​(List<Integer> row)
        This model does not support the concept of row disabling by default. Subclasses will need to override this method to support row disabling.
        Specified by:
        isDisabled in interface WTable.TableModel
        Parameters:
        row - ignored.
        Returns:
        false.
      • isSelectable

        public boolean isSelectable​(List<Integer> row)
        This model does not support the concept of row selectability by default. Subclasses will need to override this method for selection of specific rows.
        Specified by:
        isSelectable in interface WTable.TableModel
        Parameters:
        row - ignored.
        Returns:
        false
      • isExpandable

        public boolean isExpandable​(List<Integer> row)
        This model does not support the concept of rows being expandable by default. Subclasses will need to override this method for expansion of specific rows.
        Specified by:
        isExpandable in interface WTable.TableModel
        Parameters:
        row - ignored
        Returns:
        false
      • getRendererClass

        public Class<? extends WComponent> getRendererClass​(List<Integer> row)
        This model does not support the concept of rows being expandable by default. Subclasses will need to override this method for expansion of specific rows.
        Specified by:
        getRendererClass in interface WTable.TableModel
        Parameters:
        row - ignored
        Returns:
        null
      • sort

        protected int[] sort​(Comparator<Object> comparator,
                             int col,
                             boolean ascending)
        Calculates the sort order for the data, using the given column and comparator.
        Parameters:
        comparator - the comparator to use for sorting
        col - the column to sort on
        ascending - true for an ascending sort, false for descending.
        Returns:
        the row indices in sort order.