![]() | The Java Developer's Guide to Eclipse |
Chapter 16, Dialogs and Wizards, covered the options for definition and implementation of
dialogs that extend the basic function of the Eclipse Platform. This project,
com.ibm.jdg2e.wizards.newwizards,
provides
a detailed look at how multiple page wizards can be defined and managed. This includes an example
of a wizard with pages defined statically and a wizard that dynamically adds pages.
There are other projects you can review for additional dialog examples.
The Simple Model View plug-in, located in the
com.ibm.jdg2e.view.simplemodel
project, includes examples of wizard programming and property page creation. This includes the
ability to open the common Properties dialog for a specific object in a viewer. Additional wizard
examples are defined by the
Resource Extensions
(com.ibm.jdg2e.resources.extensions) and
Mini-Spreadsheet plug-in
(com.ibm.jdg2e.msseditor.ide).
The User Settings API Demonstration plug-in
(com.ibm.jdg2e.usersettings)
includes examples of preference and property page creation. This includes the
initialization of preference values.
The goal of this demonstration is an understanding of the options you have for page management in a multi-page wizard. This demonstration is best run as a project in your workspace that you can test. This is because you will be asked to modify the source as a last step. You can use it as an installed plug-in for this demonstration, but you will have to skip the last step.
First, some basics on the code so you understand what is going on. There are two wizards: a
Defined Page Wizard and a Dynamic Page Wizard, and one wizard page
called PageChain. This page can be added to a wizard multiple times, each time with
a different name and some control settings that define its behavior. The page can either act
as a simple page without any control over page progression or be more dynamic and use the
user input to determine if another page is required and which page that might be.
The wizard page can
be added with a pageComplete status of true or false.
When added as false the page must trigger a state change before the wizard framework
will allow it to proceed to the next, or if all pages are then complete, finish the wizard processing.
In addition the wizard page has user interface controls that determine behavior. One
user interface label attempts to populated itself with content from a text input field on
the previous page. This only works in certain situations as you will soon see.
In the
defined page example three wizard pages (PageChain instances) are added to the wizard.
The first is defined as incomplete, the rest are complete. These pages do not participate in the
process of determining the next page, they leave it to the wizard. That is why portions of the
page user interface are disabled.
This testing cycle will help
you understand the capabilities of this basic wizard structure.
addPages method defines three pages.
PageChain class
extracts information about the pages known to the wizard and progression through the pages for display
in the user interface. The page attempts to read content from the page before it in sequence, and
customize the user interface for that page instance.
addPages method
their user interface is created immediately upon entry to the wizard, so no customization was possible.
This is why the user input is not displayed on the subsequent page.
In the
dynamic page example only one PageChain wizard page instance is added to the wizard.
This page is defined as incomplete; it is also responsible for identifying if another page is
available, and which page will be next. Previously disabled portions of the user interface are enabled.
This testing cycle will help you understand the capabilities of this open-ended wizard structure.
addPages method defines only one page.PageChain
implementation also includes a customized getNextPage method which can support
the addition of new pages dynamically.
getNextPage method. The input on the previous page
will be included in the user interface as well. This is because the widgets for a given page are not
created until that page is entered for the first time when dynamically identified pages are used in a wizard.
Modifying Defined Page Wizard to Support a Dynamic Page User Interface
The first visit to the defined page wizard structure showed that the user interface for a page was created up front. This early user interface creation can actually be delayed; this allows you to react to user input while using a simpler wizard structure.
DefinedPageWizard class and find the createPageControls method.
createPageControls method.
super.createPageControls(pageContainer);
The JDG2E: Wizard Page/Flow Control Demonstration plug-in is designed to help you understand
how progression through a set of wizard pages can be controlled. Below are
the key classes from the com.ibm.jdg2e.wizards.newwizards
package that are used to implement the defined and dynamic wizards.
| Class (All) | Description |
DefinedPageWizard |
Wizard that adds all pages up front in the addPages method. |
DynamicPageWizard |
Wizard that adds only one initial page in the addPages method and allows all other pages
to be added dynamically. |
PageChain |
Wizard page that interrogates the wizard to display a list of all pages known to the wizard and all
pages that have been traversed. The page also control the dynamic progression process by overriding
the getNextPage method. The customized method determines if another page is required
and which page that will be at the point of page progression. |
© Copyright International Business Machines Corporation, 2003, 2004 , 2006. All Rights Reserved.
Code or samples provided herein are provided without warranty of any kind.