Interface FilterTableModel<R,C>

Type Parameters:
R - the type representing the rows in this table model
C - the type used to identify columns in this table model, Integer for indexed identification for example
All Superinterfaces:
FilterModel<R>, TableModel
All Known Implementing Classes:
SwingEntityTableModel

public interface FilterTableModel<R,C> extends TableModel, FilterModel<R>
Specifies a table model supporting selection as well as filtering
See Also:
  • Method Details

    • dataChangedEvent

      EventObserver<?> dataChangedEvent()
      Returns:
      an observer notified each time the table data changes
    • clearedEvent

      EventObserver<?> clearedEvent()
      Returns:
      an observer notified each time the table model is cleared
    • indexOf

      int indexOf(R item)
      Parameters:
      item - the item
      Returns:
      the index of the item in the table model
    • itemAt

      R itemAt(int rowIndex)
      Parameters:
      rowIndex - the row index
      Returns:
      the item at the given row index in the table model
    • columns

      Returns:
      the table columns
    • getStringAt

      String getStringAt(int rowIndex, C columnIdentifier)
      Returns a String representation of the value for the given row and column.
      Parameters:
      rowIndex - the row index
      columnIdentifier - the column identifier
      Returns:
      the string value
    • addItems

      void addItems(Collection<R> items)
      Adds the given items to the bottom of this table model.
      Parameters:
      items - the items to add
    • addItemsSorted

      void addItemsSorted(Collection<R> items)
      Adds the given items to the bottom of this table model. If sorting is enabled this model is sorted after the items have been added.
      Parameters:
      items - the items to add
    • addItemsAt

      void addItemsAt(int index, Collection<R> items)
      Adds the given items to this table model, non-filtered items are added at the given index.
      Parameters:
      index - the index at which to add the items
      items - the items to add
    • addItemsAtSorted

      void addItemsAtSorted(int index, Collection<R> items)
      Adds the given items to this table model, non-filtered items are added at the given index. If a comparator() is specified this model is sorted after the items have been added.
      Parameters:
      index - the index at which to add the items
      items - the items to add
    • addItem

      void addItem(R item)
      Adds the given item to the bottom of this table model.
      Parameters:
      item - the item to add
    • addItemAt

      void addItemAt(int index, R item)
      Parameters:
      index - the index
      item - the item to add
    • addItemSorted

      void addItemSorted(R item)
      Adds the given item to the bottom of this table model. If sorting is enabled this model is sorted after the item has been added.
      Parameters:
      item - the item to add
    • setItemAt

      void setItemAt(int index, R item)
      Sets the item at the given index. If the item should be filtered calling this method has no effect.
      Parameters:
      index - the index
      item - the item
      See Also:
    • removeItems

      void removeItems(Collection<R> items)
      Removes the given items from this table model
      Parameters:
      items - the items to remove from the model
    • removeItem

      void removeItem(R item)
      Removes the given item from this table model
      Parameters:
      item - the item to remove from the model
    • removeItemAt

      R removeItemAt(int index)
      Removes from this table model the visible element whose index is between index
      Parameters:
      index - the index of the row to be removed
      Returns:
      the removed item
      Throws:
      IndexOutOfBoundsException - in case the indexe is out of bounds
    • removeItems

      List<R> removeItems(int fromIndex, int toIndex)
      Removes from this table model all visible elements whose index is between fromIndex, inclusive and toIndex, exclusive
      Parameters:
      fromIndex - index of first row to be removed
      toIndex - index after last row to be removed
      Returns:
      the removed items
      Throws:
      IndexOutOfBoundsException - in case the indexes are out of bounds
    • values

      <T> Collection<T> values(C columnIdentifier)
      Type Parameters:
      T - the value type
      Parameters:
      columnIdentifier - the identifier of the column for which to retrieve the values
      Returns:
      the values (including nulls) of the column identified by the given identifier from the visible rows in the table model
    • getColumnClass

      Class<?> getColumnClass(C columnIdentifier)
      Returns the class of the column with the given identifier
      Parameters:
      columnIdentifier - the column identifier
      Returns:
      the Class representing the given column
    • selectedValues

      <T> Collection<T> selectedValues(C columnIdentifier)
      Type Parameters:
      T - the value type
      Parameters:
      columnIdentifier - the identifier of the column for which to retrieve the values
      Returns:
      the values (including nulls) of the column identified by the given identifier from the selected rows in the table model
    • refreshStrategy

      Returns:
      the Value controlling the refresh strategy
    • comparator

      Value<Comparator<R>> comparator()
      Returns:
      the value controlling the comparator to use when sorting
    • sortItems

      void sortItems()
      Sorts the visible items according to comparator(), keeping the selected items. Calling this method when no comparator is specified has no effect.
      See Also:
    • selectionModel

      FilterTableSelectionModel<R> selectionModel()
      Returns:
      the selection model used by this table model
    • filterModel

      TableConditionModel<C> filterModel()
      Returns:
      the filter model used by this table model
    • refresh

      void refresh()
      Refreshes the items in this filtered model using its FilterModel.Refresher.

      Retains the selection and filtering. Sorts the refreshed data unless merging on refresh is enabled. Note that an empty selection event will be triggered during a normal refresh, since the model is cleared before it is repopulated, during which the selection is cleared as well. Using merge on refresh (refreshStrategy()) will prevent that at a considerable performance cost.
      Specified by:
      refresh in interface FilterModel<R>
      See Also:
    • refreshThen

      void refreshThen(Consumer<Collection<R>> afterRefresh)
      Refreshes the data in this filter model using its FilterModel.Refresher. Note that this method only throws exceptions when run synchronously off the user interface thread. Use FilterModel.Refresher.refreshFailedEvent() to listen for exceptions that happen during asynchronous refresh.

      Retains the selection and filtering. Sorts the refreshed data unless merging on refresh is enabled. Note that an empty selection event will be triggered during a normal refresh, since the model is cleared before it is repopulated, during which the selection is cleared as well. Using merge on refresh (refreshStrategy()) will prevent that at a considerable performance cost.
      Specified by:
      refreshThen in interface FilterModel<R>
      Parameters:
      afterRefresh - called after a successful refresh, may be null
      See Also:
    • clear

      void clear()
      Clears all items from this table model
    • fireTableDataChanged

      void fireTableDataChanged()
      Notifies all listeners that all cell values in the table's rows may have changed. The number of rows may also have changed and the JTable should redraw the table from scratch. The structure of the table (as in the order of the columns) is assumed to be the same.
    • fireTableRowsUpdated

      void fireTableRowsUpdated(int fromIndex, int toIndex)
      Notifies all listeners that the given rows have changed
      Parameters:
      fromIndex - the from index
      toIndex - the to index
    • builder

      static <R, C> FilterTableModel.Builder<R,C> builder(FilterTableModel.Columns<R,C> columns)
      Instantiates a new table model builder.
      Type Parameters:
      R - the row type
      C - the column identifier type
      Parameters:
      columns - the columns
      Returns:
      a new builder instance
      Throws:
      NullPointerException - in case columnValues is null