5.1.2. Content providersA content provider is another common adapter type used in list viewers. This provider is used to map between a domain model object or a collection of domain model objects used as the input to the viewer and the internal list structure needed by the viewer itself. The two most common types of content providers are IStructuredContentProvider, used in lists and tables, and ITreeContentProvider, used in trees (see Figure 5-4). The former maps a domain model input into an array while the latter adds support for retrieving an item's parent or children within a tree. A content provider is associated with a viewer using the setContentProvider() method. A domain model input is associated with a viewer using the setInput() method. Figure 5-4. ContentProvider hierarchy.
Useful APIs defined by IStructuredContentProvider include:
Useful APIs added by ITreeContentProvider include:
For an example of content providers, see Section 5.1.6, ListViewer class, on page 192. |