The Content Provider is a set of interfaces that are implemented by applications to supply data to the table control.
The table control has a paging mechanism that it uses to limit the amount of data it displays to one subset of the available data at a time. It maintains a virtual mapping of the data divided into multiple pages. You can specify the amount of data for the table to display per page by passing the following parameters to the provider.
- count – Defines how many data items to load into memory at a time; it uses an integer value, such as 50.
- offset – Defines the first data element to load into memory using an index value, such as 0.
For example, a flat list table with a provider that is passed an offset parameter of 0 and a count parameter of 50, would display data elements 1 through 49. If the entire data set included 75 items, items 50 through 75 would be displayed on a second page.
The following types of content providers are available:
- com.ibm.rcp.jface.viewers.IPagedContentProvider – Provides access to a content provider that returns one page of data at a time. The getPage method returns the elements with a given offset and count. It also provides find methods that enable users to search the data items for a specific data element.
In Expeditor table control applications, you should use CollectionContentProvider as a content provider wrapper. Do not directly use CollectionContentProvider as the paged content provider into the table viewer. The ordinary call is:
tableViewer.setContentProvider(new CollectionContentProvider(new PagedContentProvider()))
Note that PagedContentProvider is an implementation class for IPagedContentProvider.
- com.ibm.rcp.jface.viewers.ITreePagedContentProvider – Extends the IPagedContentProvider. It provides access to a content provider that checks if the data item has children and preserves its relationship to those child objects and other objects when it displays the data item.
In Expeditor table control application, you should use CollectionContentProvider as a content provider wrapper. Do not directly use CollectionContentProvider as the tree paged content provider into the table viewer. The ordinary call is
tableViewer.setContentProvider(new CollectionContentProvider(new TreePagedContentProvider()))
Note that TreePagedContentProvider is an implementation class for ITreePagedContentProvider.
- com.ibm.rcp.jface.viewers.CollectionContentProvider – Provides a series of methods for TableViewer to call and fetch data as well as update a table control's UI. It invokes the instance of IPagedContentProvider (when a table is in flat/persist mode) or ITreePagedContentProvider (when a table is in tree mode) to fetch data in a new thread. Each fetch operation must have both "start offset" and "fetch count" parameters. Each object in the returned data is tagged with CollectionPosition that provides the object position in the larger collection. The fetch data is used to create table items. Afterwards, the table is justified and redrawn.
Parent topic: Custom table control: XPD622