Class DeferredContentProvider
- All Implemented Interfaces:
IContentProvider
,ILazyContentProvider
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 Summary
ConstructorDescriptionDeferredContentProvider
(Comparator sortOrder) Create a DeferredContentProvider with the given sort order. -
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
Disposes of this content provider.int
getLimit()
Returns the current maximum number of rows or -1 if unboundedvoid
inputChanged
(Viewer viewer, Object oldInput, Object newInput) Notifies this content provider that the given viewer's input has been switched to a different element.void
Sets the filter for this content provider.void
setLimit
(int limit) Sets the maximum number of rows in the table.void
setSortOrder
(Comparator sortOrder) Sets the sort order for this content provider.void
updateElement
(int element) Called when a previously-blank item becomes visible in the TableViewer.
-
Constructor Details
-
DeferredContentProvider
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 interfaceIContentProvider
-
inputChanged
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 interfaceIContentProvider
- Parameters:
viewer
- the vieweroldInput
- the old input element, ornull
if the viewer did not previously have an inputnewInput
- the new input element, ornull
if the viewer does not have an input
-
setSortOrder
Sets the sort order for this content provider. This sort order takes priority over anything that was supplied to theTableViewer
.- Parameters:
sortOrder
- new sort order. The comparator must be able to support being used in a background thread.
-
setFilter
Sets the filter for this content provider. This filter takes priority over anything that was supplied to theTableViewer
. 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 interfaceILazyContentProvider
- Parameters:
element
- The index that is being updated in the table.
-