5.1.1. Label providersA label provider is one of the most common adapter types used in list viewers. This provider is used to map a domain model object into one or more images and text strings displayable in the viewer's widget. The two most common types of label providers are ILabelProvider (see Figure 5-2), used in lists and trees, and ITableLabelProvider (see Figure 5-3), used in tables. The former maps an item into a single image and text label while the latter maps an item into multiple images and text labels (one set for each column in the table). A label provider is associated with a viewer using the setLabelProvider() method. Figure 5-2. LabelProvider hierarchy.
Figure 5-3. TableLabelProvider hierarchy.
Useful APIs defined by ILabelProvider include:
Useful APIs defined by ITableLabelProvider include:
For an example of label providers, see Section 5.1.6, ListViewer class, on page 192. |