- java.lang.Object
-
- org.controlsfx.dialog.Wizard
-
public class Wizard extends Object
The API for creating multi-page Wizards, based on JavaFX
DialogAPI.
Wizard can be setup in following few steps:- Design wizard pages by inheriting them from
WizardPane - Define wizard flow by implementing
Wizard.Flow - Create and instance of the Wizard and assign flow to it
- Execute the wizard using showAndWait method
- Values can be extracted from settings map by calling getSettings
For simple, linear wizards, the
Wizard.LinearFlowcan be used. It is a flow based on a collection of wizard pages. Here is the example:// Create pages. Here for simplicity we just create and instance of WizardPane. WizardPane page1 = new WizardPane(); WizardPane page2 = new WizardPane(); WizardPane page3 = new WizardPane(); // create wizard Wizard wizard = new Wizard(); // create and assign the flow wizard.setFlow(new LinearFlow(page1, page2, page3)); // show wizard and wait for response wizard.showAndWait().ifPresent(result -> { if (result == ButtonType.FINISH) { System.out.println("Wizard finished, settings: " + wizard.getSettings()); } });For more complex wizard flows we suggest to create a custom ones, describing page traversal logic. Here is a simplified example:
Wizard.Flow branchingFlow = new Wizard.Flow() { public Optional<WizardPane> advance(WizardPane currentPage) { return Optional.of(getNext(currentPage)); } public boolean canAdvance(WizardPane currentPage) { return currentPage != page3; } private WizardPane getNext(WizardPane currentPage) { if ( currentPage == null ) { return page1; } else if ( currentPage == page1) { // skipNextPage() does not exist - this just represents that you // can add a conditional statement here to change the page. return page1.skipNextPage()? page3: page2; } else { return page3; } } }; - Design wizard pages by inheriting them from
-
-
Property Summary
Properties Type Property Description ObjectProperty<Wizard.Flow>flowTheWizard.Flowproperty represents the flow of pages in the wizard.BooleanPropertyinvalidProperty for overriding the individual validation state of thisWizard.BooleanPropertyreadSettingsProperty for overriding the individual read-settings state of thisWizard.ObjectProperty<ButtonType>resultStringPropertytitleReturn the titleProperty of the wizard.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWizard.FlowRepresents the page flow of the wizard.static classWizard.LinearFlowLinearFlow is an implementation of theWizard.Flowinterface, designed to support the most common type of wizard flow - namely, a linear wizard page flow (i.e.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectProperty<Wizard.Flow>flowProperty()TheWizard.Flowproperty represents the flow of pages in the wizard.Wizard.FlowgetFlow()Returns the currently setWizard.Flow, which represents the flow of pages in the wizard.ObservableMap<Object,Object>getProperties()Returns an observable map of properties on this Wizard for use primarily by application developers - not to be confused with thegetSettings()map that represents the values entered by the user into the wizard.ObservableMap<String,Object>getSettings()The settings map is the place where all data from pages is kept once the user moves on from the page, assuming there is aValueExtractorthat is capable of extracting a value out of the various fields on the page.StringgetTitle()Return the title of the wizard.ObjectgetUserData()Returns a previously set Object property, or null if no such property has been set using thesetUserData(Object)method.booleanhasProperties()Tests if this Wizard has properties.BooleanPropertyinvalidProperty()Property for overriding the individual validation state of thisWizard.booleanisInvalid()Gets the value of the propertyinvalid.booleanisReadSettings()Gets the value of the propertyreadSettings.BooleanPropertyreadSettingsProperty()Property for overriding the individual read-settings state of thisWizard.ObjectProperty<ButtonType>resultProperty()voidsetFlow(Wizard.Flow flow)Sets theWizard.Flow, which represents the flow of pages in the wizard.voidsetInvalid(boolean invalid)Sets the value of the propertyinvalid.voidsetReadSettings(boolean readSettings)Sets the value of the propertyreadSettings.voidsetTitle(String title)Change the Title of the wizard.voidsetUserData(Object value)Convenience method for setting a single Object property that can be retrieved at a later date.Optional<ButtonType>showAndWait()Shows the wizard and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).StringPropertytitleProperty()Return the titleProperty of the wizard.
-
-
-
Property Detail
-
result
public final ObjectProperty<ButtonType> resultProperty
-
title
public final StringProperty titleProperty
Return the titleProperty of the wizard.- See Also:
getTitle(),setTitle(String)
-
flow
public final ObjectProperty<Wizard.Flow> flowProperty
TheWizard.Flowproperty represents the flow of pages in the wizard.- See Also:
getFlow(),setFlow(Wizard.Flow)
-
invalid
public final BooleanProperty invalidProperty
Property for overriding the individual validation state of thisWizard. Settinginvalidto true will disable the next/finish Button and the user will not be able to advance to the next page of theWizard. Settinginvalidto false will enable the next/finish Button.
For example you can use theValidationSupport.invalidProperty()of a page and bind it to theinvalidproperty:
wizard.invalidProperty().bind(page.validationSupport.invalidProperty());- See Also:
isInvalid(),setInvalid(boolean)
-
readSettings
public final BooleanProperty readSettingsProperty
Property for overriding the individual read-settings state of thisWizard. SettingreadSettingsto true will enable the value extraction for thisWizard. SettingreadSettingsto false will disable the value extraction for thisWizard.- See Also:
isReadSettings(),setReadSettings(boolean)
-
-
Constructor Detail
-
Wizard
public Wizard()
Creates an instance of the wizard without an owner.
-
Wizard
public Wizard(Object owner)
Creates an instance of the wizard with the given owner.- Parameters:
owner- The object from which the owner window is deduced (typically this is a Node, but it may also be a Scene or a Stage).
-
-
Method Detail
-
showAndWait
public final Optional<ButtonType> showAndWait()
Shows the wizard and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).- Returns:
- An
Optionalthat contains the result.
-
resultProperty
public final ObjectProperty<ButtonType> resultProperty()
-
getSettings
public final ObservableMap<String,Object> getSettings()
The settings map is the place where all data from pages is kept once the user moves on from the page, assuming there is aValueExtractorthat is capable of extracting a value out of the various fields on the page.
-
titleProperty
public final StringProperty titleProperty()
Return the titleProperty of the wizard.- See Also:
getTitle(),setTitle(String)
-
getTitle
public final String getTitle()
Return the title of the wizard.
-
setTitle
public final void setTitle(String title)
Change the Title of the wizard.- Parameters:
title-
-
flowProperty
public final ObjectProperty<Wizard.Flow> flowProperty()
TheWizard.Flowproperty represents the flow of pages in the wizard.- See Also:
getFlow(),setFlow(Wizard.Flow)
-
getFlow
public final Wizard.Flow getFlow()
Returns the currently setWizard.Flow, which represents the flow of pages in the wizard.
-
setFlow
public final void setFlow(Wizard.Flow flow)
Sets theWizard.Flow, which represents the flow of pages in the wizard.
-
getProperties
public final ObservableMap<Object,Object> getProperties()
Returns an observable map of properties on this Wizard for use primarily by application developers - not to be confused with thegetSettings()map that represents the values entered by the user into the wizard.- Returns:
- an observable map of properties on this Wizard for use primarily by application developers
-
hasProperties
public boolean hasProperties()
Tests if this Wizard has properties.- Returns:
- true if this Wizard has properties.
-
setUserData
public void setUserData(Object value)
Convenience method for setting a single Object property that can be retrieved at a later date. This is functionally equivalent to calling the getProperties().put(Object key, Object value) method. This can later be retrieved by callinggetUserData().- Parameters:
value- The value to be stored - this can later be retrieved by callinggetUserData().
-
getUserData
public Object getUserData()
Returns a previously set Object property, or null if no such property has been set using thesetUserData(Object)method.- Returns:
- The Object that was previously set, or null if no property has been set or if null was set.
-
setInvalid
public final void setInvalid(boolean invalid)
Sets the value of the propertyinvalid.- Parameters:
invalid- The new validation stateinvalidProperty()
-
isInvalid
public final boolean isInvalid()
Gets the value of the propertyinvalid.- Returns:
- The validation state
- See Also:
invalidProperty()
-
invalidProperty
public final BooleanProperty invalidProperty()
Property for overriding the individual validation state of thisWizard. Settinginvalidto true will disable the next/finish Button and the user will not be able to advance to the next page of theWizard. Settinginvalidto false will enable the next/finish Button.
For example you can use theValidationSupport.invalidProperty()of a page and bind it to theinvalidproperty:
wizard.invalidProperty().bind(page.validationSupport.invalidProperty());- See Also:
isInvalid(),setInvalid(boolean)
-
setReadSettings
public final void setReadSettings(boolean readSettings)
Sets the value of the propertyreadSettings.- Parameters:
readSettings- The new read-settings state- See Also:
readSettingsProperty()
-
isReadSettings
public final boolean isReadSettings()
Gets the value of the propertyreadSettings.- Returns:
- The read-settings state
- See Also:
readSettingsProperty()
-
readSettingsProperty
public final BooleanProperty readSettingsProperty()
Property for overriding the individual read-settings state of thisWizard. SettingreadSettingsto true will enable the value extraction for thisWizard. SettingreadSettingsto false will disable the value extraction for thisWizard.- See Also:
isReadSettings(),setReadSettings(boolean)
-
-