![]() |
Custom resource creation wizards are the best way to support the creation of resources using a process that you control. New file wizards allow you to control naming, location, and contents. New project wizards allow you to add natures, properties, and standard structures.
This example demonstrates the implementation of a new file wizard, with customized content. The com.ibm.lab.soln.resources
plug-in has an example of a new
project wizard.
The implementation of a resource wizard requires that you define an
extension in your plug-in and provide an implementation of the
extension. The plugin.xml
defines two resource creation
wizard extensions. The wizards contain a mix of custom wizard pages created from scratch and pages that build on basic file and folder creation wizard pages provided as part of Eclipse.
To run the example, launch the run-time instance of Eclipse (Run > Run As > Run-time Workbench).
Usage scenarios for the two resource creation wizard examples are detailed below.
The first resource creation wizard demonstrates how wizard pages provided by Eclipse can be reused and the page progression control logic integrated into the wizard framework using the page complete status for each wizard page.
MyBasicWizard
class. The wizard page implemented by the MyBasicWizardPage1
class is shown as this page is the first added by the wizards addPages()
method:MyNewFileWizardPage
class). The input validation, such as the error shown based on a failed
file name test, is provided by the WizardNewFileCreationPage
class from Eclipse. By overriding the getInitialContents()
method this page even provides initial content for the file.This example demonstrated the use of wizard pages provided as part of Eclipse and simple page control logic.
The second resource creation wizard demonstrates dynamic page
content. That is, the wizard's addPages()
method defines the initial page – all subsequent pages are determined by user interaction.
The purpose of this wizard is to allow you to create any number of folders
or files through one wizard interaction. Beginning with the first page, the wizard control logic allows you to request what type of resource creation page you want to see next. After the first page, each time you move on to the next page the the resource creation request is processed. If you select Finish, the only processing left to perform is that shown on the current page.
This is an unorthodox wizard, but it does allow for a demonstration of dynamic page content.
StructureWizard
class. The first wizard page is implemented by the StructureInitPage
class is shown: getNextPage()
method add another page to the wizard. StructureNewFolderWizardPage
class builds on the org.eclipse.ui.dialogs.WizardNewFolderMainPage
class. This example includes two resource creation new wizard extensions that demonstrate wizard implementation techniques. The extension definitions can be found in the plugin.xml. The classes that implement these extensions and capabilities are shown below.
Extension / Object | Implementation |
---|---|
My Basic Wizard and Wizard Pages |
This resource creation wizard is implemented by the MyBasicWizard
class. |
There are three wizard pages included in this basic wizard example:
|
|
Project Structure Wizard and Wizard Pages |
This resource creation wizard is implemented by the StructureWizard
class. |
There are three wizard pages included in the project structure wizard:
|
© Copyright International Business Machines Corporation, 2003.
All rights reserved.