1.1. Overview
Eclipse JFace viewers allow to display a domain model in a list, tree or table without converting the domain model beforehand.
These viewers provider adaptors which are used to provide the model to the viewer (these are called content provider) and adaptors to define how the model data is displayed in the viewer (these are called label providers).
The Eclipse JFace viewer concept is very flexible as it allows to use the same content provider / label provider in different viewers without changing the underlying data structure.
JFace also allows assign label provider directly to columns instead of one label provider for the whole table.
In working with JFace viewers it is important to understand the concept of viewers, label and content providers. The following provides an overview and lists some typical classes in these areas.
The user interface is represented by the viewer, e.g. in our example the table viewer.
Viewer: Typical viewers are
-
org.eclipse.jface.viewers.ListViewer - Display a simple list
-
org.eclipse.jface.viewers.TreeViewer - Displays a tree
-
org.eclipse.jface.viewers.TableViewer - Displays a table
Responsible for providing objects to the view. It can simply return objects as-is.
Typical content provider are
-
IStructuredContentProvider: Used for lists and tables
-
ITreeContentProvider: Used for trees, has addional methods to determine the children and the parents of elements
Defines how objects are displayed, e.g. which part of the object is used to return the text which is displayed.
Label provider follow usually the template approach; you have an interface which describes and contact and a class which the programmer can use which delivers already reasonable implementations for the interface and the programmer can then choose to override only the relevant methods.
Typical label providers are
0 comments:
Post a Comment