Interface FilteredTableModel<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:
FilteredModel<R>, TableModel
All Known Implementing Classes:
SwingEntityTableModel

public interface FilteredTableModel<R,C> extends TableModel, FilteredModel<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
    • 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 sorting is enabled 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
      See Also:
    • 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
    • rowsAsDelimitedString

      String rowsAsDelimitedString(char delimiter)
      Parameters:
      delimiter - the delimiter
      Returns:
      the table rows as a tab delimited string, with column names as a header
    • mergeOnRefresh

      State mergeOnRefresh()
      Note that when merging during refresh, the items are not sorted, since that would cause an empty-selection event, defeating the purpose of merging.
      Returns:
      the State controlling whether merge on refresh should be enabled
    • sortItems

      void sortItems()
      Sorts the visible items according to the FilteredTableSortModel, keeping the selected items. Calling this method with the sort model disabled has no effect.
      See Also:
    • columnModel

      FilteredTableColumnModel<C> columnModel()
      Returns:
      the FilteredTableColumnModel used by this TableModel
    • selectionModel

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

      FilteredTableSortModel<R,C> sortModel()
      Returns:
      the sorting model
    • searchModel

      Returns:
      the search model
    • filterModel

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

      TableSummaryModel<C> summaryModel()
      Returns:
      the summary model
    • refresh

      void refresh()
      Refreshes the items in this filtered model using its FilteredModel.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 (mergeOnRefresh()) will prevent that at a considerable performance cost.
      Specified by:
      refresh in interface FilteredModel<R>
      See Also:
    • refreshThen

      void refreshThen(Consumer<Collection<R>> afterRefresh)
      Refreshes the data in this filtered model using its FilteredModel.Refresher. Note that this method only throws exceptions when run synchronously off the user interface thread. Use FilteredModel.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 (mergeOnRefresh()) will prevent that at a considerable performance cost.
      Specified by:
      refreshThen in interface FilteredModel<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> FilteredTableModel.Builder<R,C> builder(FilteredTableModel.ColumnFactory<C> columnFactory, FilteredTableModel.ColumnValueProvider<R,C> columnValueProvider)
      Instantiates a new table model builder.
      Type Parameters:
      R - the row type
      C - the column identifier type
      Parameters:
      columnFactory - the column factory
      columnValueProvider - the column value provider
      Returns:
      a new builder instance
      Throws:
      NullPointerException - in case columnFactory or columnValueProvider is null
    • summaryValueProvider

      static <T extends Number, C> ColumnSummaryModel.SummaryValueProvider<T> summaryValueProvider(C columnIdentifier, FilteredTableModel<?,C> tableModel, Format format)
      Instantiates a new ColumnSummaryModel.SummaryValueProvider instance.
      Type Parameters:
      T - the column value type
      C - the column identifier type
      Parameters:
      columnIdentifier - the column identifier
      tableModel - the table model
      format - the format
      Returns:
      a new ColumnSummaryModel.SummaryValueProvider instance