Description
Enables a wizard facility based on https://wizard.dev.java.net/.
Installation
The current version of griffon-wizard-plugin is 0.2.1
To install just issue the following command
griffon install-plugin wizard
Usage
The wizard plugin adds 1 node factory and a explicit method to Griffon's CompositeBuilder.
| Node | Property | Type | Default | Required | Bindable | Notes |
|---|---|---|---|---|---|---|
| wizard [Wizard] |
url | URL | |
|
||
| file | File | |
|
can also be a String | ||
| inputStream | InputStream | |
|
|||
| image | BufferedImage | |
|
|||
| resource | String | |
|
|||
| class | Class | |
|
only required if resource is specified. | ||
| title | String | |
|
|||
| pages | List | |
|
a List of Strings | ||
| panelProvider | String | |
|
the name of a WizardPanelProvider class | ||
| specify one of url, file, inputStream, image resource. | ||||||
| branchingWizard [Wizard] |
url | URL | |
|
||
| file | File | |
|
can also be a String | ||
| inputStream | InputStream | |
|
|||
| image | BufferedImage | |
|
|||
| resource | String | |
|
|||
| class | Class | |
|
only required if resource is specified. | ||
| specify one of url, file, inputStream, image resource. | ||||||
| value must be the logical name of BranchingWizard class |
Once installed you'll be able to create WizardPages with a new script create-wizard-page, WizardPages will be place at griffon-app/wizards. Other artifacts are available as well
| Script | Artifact |
|---|---|
| create-wizard-page | griffon/wizards/${NAME}WizardPage |
| create-wizard-panel-provider | griffon/wizards/${NAME}WizardPanelProvider |
| create-branching-wizard | griffon/wizards/${NAME}BranchingWizard |
| create-wizard-result-producer | griffon/wizards/${NAME}WizardResultproducer |
$ griffon create-wizard-page One Welcome to Griffon 0.1-SNAPSHOT - http://griffon.codehaus.org/ Licensed under Apache Standard License 2.0 Griffon home is set to: /usr/local/griffon Base Directory: /tmp/work/FileViewer Running script /home/user/.griffon/0.1-SNAPSHOT/projects/FileViewer/plugins/wizard-0.2/scripts/CreateWizardPage.groovy Environment set to development Found events script in plugin wizard-0.1 Created WizardPage for One $ cat griffon-app/wizards/OneWizardPage.groovy class OneWizardPage { def stepId = "step1" def description = "Step Description" def autoListen = true // true by default if omitted def pageContents = { // remember to always set a name: property to each input widget textField( name: "tf1", text: "Add Content Here" ) // delete me } def onValidate = { component, event -> return null } }
It is very important to set a name: property on each widget that serves as input, the Wizard will use it to automatically store any data that is entered by the user. The onValidate closure property will be used (if defined) to verify that entered data is valid, it will only be called whenever the target component is not null, be sure to verify which component is currently being validated (by checking against its name property for example).
Wizards must be created by setting title and pages/panelProvider properties, the rest of the aforementioned properties are used to customize the sidebar image.
wizard( title: "My Wizard", pages: ["One", "Two"] )
You can customize the cancel and finish behavior of a wizard, either by setting a resultProducer: property, which should be an instance of WizardPage.WizardResultProducer or a Map with cancel: and finish: keys, or with a nested closure as shown next
def wizard = wizard( title: "My Wizard", pages: ["One", "Two"] ) { onCancel { settings -> // return true to cancel } onFinish { data -> // return data } }
You can also return a Summary object as a result of onFinish. Lastly you can display the wizard inside any controller with the following code
def result = showWizard(wizard)
showWizard accepts 3 additional parameters
- helpAction (javax.swing.Action) - used as Action for the Help button.
- initialProperties (Map) - a map with default values to be used on the wizard, keys will match named widgets.
- location (java.awt.Rectangle) - location and size of the wizard.
showWizard has a variant that accepts a Map, enabling the following showWizard( wizard, helpAction: myHelpAction, location: [50,50,300,200] ) |


