Class AbstractListSelectTableModel<V>

  • Type Parameters:
    V - The type of values representing table rows.
    All Implemented Interfaces:
    com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, com.globalmentor.model.MutableValued<V>, com.globalmentor.model.Valued<V>, ListListenable<V>, ListSelectModel<V>, Model, SelectModel<V>, TableModel, ValueModel<V>, java.lang.Iterable<V>, java.util.Collection<V>, java.util.List<V>

    public abstract class AbstractListSelectTableModel<V>
    extends DefaultListSelectModel<V>
    implements TableModel
    An abstract implementation of a table model representing selectable list values. The model is thread-safe, synchronized on itself. Any iteration over values should include synchronization on the instance of this class.
    Author:
    Garret Wilson
    • Constructor Detail

      • AbstractListSelectTableModel

        public AbstractListSelectTableModel​(java.lang.Class<V> valueClass,
                                            TableColumnModel<?>... columns)
        Constructs a list select table model indicating the type of values it can hold, using a default multiple selection strategy.
        Parameters:
        valueClass - The class indicating the type of values held in the model.
        columns - The models representing the table columns.
        Throws:
        java.lang.NullPointerException - if the given value class is null.
      • AbstractListSelectTableModel

        public AbstractListSelectTableModel​(java.lang.Class<V> valueClass,
                                            ListSelectionPolicy<V> listSelectionStrategy,
                                            TableColumnModel<?>... columns)
        Constructs a list select table model indicating the type of values it can hold. The selection strategy is not added as a listener to this model but is rather notified manually so that the event won't be delayed and/or sent out of order
        Parameters:
        valueClass - The class indicating the type of values held in the model.
        listSelectionStrategy - The strategy for selecting values in the model.
        columns - The models representing the table columns.
        Throws:
        java.lang.NullPointerException - if the given value class and/or selection strategy is null.
    • Method Detail

      • getColumnIndex

        public int getColumnIndex​(TableColumnModel<?> column)
        Description copied from interface: TableModel
        Determines the logical index of the given table column.
        Specified by:
        getColumnIndex in interface TableModel
        Parameters:
        column - One of the table columns.
        Returns:
        The zero-based logical index of the column within the table, or -1 if the column is not one of the model's columns.
      • getColumns

        public java.util.List<TableColumnModel<?>> getColumns()
        Specified by:
        getColumns in interface TableModel
        Returns:
        A read-only list of table columns in physical order.
      • getRowCount

        public int getRowCount()
        Specified by:
        getRowCount in interface TableModel
        Returns:
        The number of rows in this table.
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface TableModel
        Returns:
        The number of columns in this table.
      • getCellValueModel

        public ValueModel<java.lang.Object> getCellValueModel​(int rowIndex,
                                                              int colIndex)
        Returns the model representing the cell value at the given row and column.
        Parameters:
        rowIndex - The zero-based row index.
        colIndex - The zero-based column index.
        Returns:
        The value model representing the value in the cell at the given row and column.
        Throws:
        java.lang.IndexOutOfBoundsException - if the given row index and/or column index represents an invalid location for the table.
      • getCellValue

        public <C> C getCellValue​(TableModel.Cell<C> cell)
        Description copied from interface: TableModel
        Returns the cell value for the given cell. This method delegates to TableModel.getCellValue(int, TableColumnModel).
        Specified by:
        getCellValue in interface TableModel
        Type Parameters:
        C - The type of cell value.
        Parameters:
        cell - The cell containing the row index and column information.
        Returns:
        The value in the cell at the given row and column, or null if there is no value in that cell.
      • getCellValue

        public <C> C getCellValue​(int rowIndex,
                                  TableColumnModel<C> column)
        Description copied from interface: TableModel
        Returns the cell value at the given row and column.
        Specified by:
        getCellValue in interface TableModel
        Type Parameters:
        C - The type of cell values in the given column.
        Parameters:
        rowIndex - The zero-based row index.
        column - The column for which a value should be returned.
        Returns:
        The value in the cell at the given row and column, or null if there is no value in that cell.
      • setCellValue

        public <C> void setCellValue​(TableModel.Cell<C> cell,
                                     C newCellValue)
        Description copied from interface: TableModel
        Sets the cell value for the given cell. This method delegates to TableModel.setCellValue(int, TableColumnModel, Object).
        Specified by:
        setCellValue in interface TableModel
        Type Parameters:
        C - The type of cell value.
        Parameters:
        cell - The cell containing the row index and column information.
        newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
      • setCellValue

        public <C> void setCellValue​(int rowIndex,
                                     TableColumnModel<C> column,
                                     C newCellValue)
        Description copied from interface: TableModel
        Sets the cell value at the given row and column.
        Specified by:
        setCellValue in interface TableModel
        Type Parameters:
        C - The type of cell values in the given column.
        Parameters:
        rowIndex - The zero-based row index.
        column - The column for which a value should be returned.
        newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
      • getCellValue

        protected abstract <C> C getCellValue​(V value,
                                              int rowIndex,
                                              TableColumnModel<C> column)
        Returns the value's property for the given column.
        Type Parameters:
        C - The type of cell values in the given column.
        Parameters:
        value - The value in this list select model.
        rowIndex - The zero-based row index of the value.
        column - The column for which a value should be returned.
        Returns:
        The value in the cell at the given row and column, or null if there is no value in that cell.
        Throws:
        java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
        java.lang.IllegalArgumentException - if the given column is not one of this table's columns.
      • setCellValue

        protected abstract <C> void setCellValue​(V value,
                                                 int rowIndex,
                                                 TableColumnModel<C> column,
                                                 C newCellValue)
        Sets the value's property for the given column.
        Type Parameters:
        C - The type of cell values in the given column.
        Parameters:
        value - The value in this list select model.
        rowIndex - The zero-based row index of the value.
        column - The column for which a value should be returned.
        newCellValue - The value to place in the cell at the given row and column, or null if there should be no value in that cell.
        Throws:
        java.lang.IndexOutOfBoundsException - if the given row index represents an invalid location for the table.
        java.lang.IllegalArgumentException - if the given column is not one of this table's columns.