The Java Developer's Guide to EclipseThe Java Developer's Guide to Eclipse

In Chapter 15, JFace Viewers, you learned how to use viewers, content providers, and label providers to create user interface content derived from your model as input. To demonstrate the basic techniques for how viewers can be combined with the appropriate content and label providers, a working implementation of many of the available viewers is contained in the com.ibm.jdg2e.jface.viewers project. This example requires the com.ibm.jdg2e.simplemodel project. Ensure you have it loaded in your workspace.

Running the Example

  1. Launch and run a runtime workbench (Run > Run As > Eclipse Application).
  2. Find and select the Open Viewer Examples Dialog toolbar action (Open Viewer Examples Dialog toolbar action).
  3. Viewer Examples Dialog
  4. Explore the different viewers, there is one on each tab in the dialog.

Roadmap of the Example

The JFace Viewers plug-in is limited in function by design. It lets you clearly see what is required to create a working viewer. The example viewers use as input the location elements obtained from the "road trip" model defined in the Simple Model (RoadTrip Locations) plug-in, defined in the com.ibm.jdg2e.simplemodel project.

The viewer examples are all displayed in a common dialog, this dialog has multiple pages, one for each type of viewer example that is provided.

The plug-in manifest file defines the action set extension definition for the Open Viewer Examples Dialog action that opens up the dialog. The table below shows the key classes from the com.ibm.jdg2e.viewers package that are used to implement the viewer dialog and its associated JFace viewer user interface examples.

Class (All) Description
OpenDialogAction Action to open the dialog.
ViewerExamplesDialog The dialog that contains multiple pages of viewer examples.
AbstractViewerExample Basic structure for creating a viewer example page. This includes the actions and common context menu available for each viewer.
ListViewerExample List viewer example; a list has no image, just a single text attribute.
This example uses the LocationsContentProvider and LocationLabelProvider.
TableViewerExample Table viewer example; a single column table with image and text.
This example uses the LocationsContentProvider and LocationTableLabelProvider.
TableColumnViewerExample Multi-column table viewer example; some columns have an image while others have just text.
This example uses the LocationsContentProvider and LocationTableColumnLabelProvider.
TreeViewerExample Tree viewer example; simple model data organized by political unit. Some branches have multiple nodes.
This example uses the LocationsTreeContentProvider and LocationLabelProvider.
TableTreeViewerExample Table tree viewer example; simple model data organized by political unit. Branches are represented by a multi-column table.
This example uses the LocationsTreeContentProvider and LocationTableColumnLabelProvider.

© Copyright International Business Machines Corporation, 2003, 2004, 2006. All Rights Reserved.
Code or samples provided herein are provided without warranty of any kind.