Class DeferredContentProvider

java.lang.Object
org.eclipse.jface.viewers.deferred.DeferredContentProvider
All Implemented Interfaces:
IContentProvider, ILazyContentProvider

public class DeferredContentProvider extends Object implements ILazyContentProvider
Content provider that performs sorting and filtering in a background thread. Requires a TableViewer created with the SWT.VIRTUAL flag and an IConcurrentModel as input.

The sorter and filter must be set directly on the content provider. Any sorter or filter on the TableViewer will be ignored.

The real implementation is in BackgroundContentProvider. This object is a lightweight wrapper that adapts the algorithm to work with TableViewer.

Since:
3.1
  • Constructor Details

    • DeferredContentProvider

      public DeferredContentProvider(Comparator sortOrder)
      Create a DeferredContentProvider with the given sort order.
      Parameters:
      sortOrder - a comparator that sorts the content.
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: IContentProvider
      Disposes of this content provider. This is called by the viewer when it is disposed.

      The viewer should not be updated during this call, as it is in the process of being disposed.

      The default implementation does nothing.

      Specified by:
      dispose in interface IContentProvider
    • inputChanged

      public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
      Description copied from interface: IContentProvider
      Notifies this content provider that the given viewer's input has been switched to a different element.

      A typical use for this method is registering the content provider as a listener to changes on the new input (using model-specific means), and deregistering the viewer from the old input. In response to these change notifications, the content provider should update the viewer (see the add, remove, update and refresh methods on the viewers).

      The viewer should not be updated during this call, as it might be in the process of being disposed.

      The default implementation does nothing.

      Specified by:
      inputChanged in interface IContentProvider
      Parameters:
      viewer - the viewer
      oldInput - the old input element, or null if the viewer did not previously have an input
      newInput - the new input element, or null if the viewer does not have an input
    • setSortOrder

      public void setSortOrder(Comparator sortOrder)
      Sets the sort order for this content provider. This sort order takes priority over anything that was supplied to the TableViewer.
      Parameters:
      sortOrder - new sort order. The comparator must be able to support being used in a background thread.
    • setFilter

      public void setFilter(IFilter toSet)
      Sets the filter for this content provider. This filter takes priority over anything that was supplied to the TableViewer. The filter must be capable of being used in a background thread.
      Parameters:
      toSet - filter to set
    • setLimit

      public void setLimit(int limit)
      Sets the maximum number of rows in the table. If the model contains more than this number of elements, only the top elements will be shown based on the current sort order.
      Parameters:
      limit - maximum number of rows to show or -1 if unbounded
    • getLimit

      public int getLimit()
      Returns the current maximum number of rows or -1 if unbounded
      Returns:
      the current maximum number of rows or -1 if unbounded
    • updateElement

      public void updateElement(int element)
      Description copied from interface: ILazyContentProvider
      Called when a previously-blank item becomes visible in the TableViewer. If the content provider knows the element at this row, it should respond by calling TableViewer#replace(Object, int). NOTE #updateElement(int index) can be used to determine selection values. TableViewer#replace(Object, int) is not called before returning from this method selections may have missing or stale elements. In this situation it is suggested that the selection is asked for again after he update.
      Specified by:
      updateElement in interface ILazyContentProvider
      Parameters:
      element - The index that is being updated in the table.