Class WizardDescriptor

All Implemented Interfaces:
org.openide.util.HelpCtx.Provider

public class WizardDescriptor extends DialogDescriptor
Implements a basic "wizard" GUI system. A list of wizard panels may be specified and these may be traversed at the proper times using the "Previous" and "Next" buttons (or "Finish" on the last one).

Related Tutorial

See Also:
  • Field Details

    • NEXT_OPTION

      public static final Object NEXT_OPTION
      "Next" button option.
      See Also:
    • FINISH_OPTION

      public static final Object FINISH_OPTION
      "Finish" button option.
      See Also:
    • PREVIOUS_OPTION

      public static final Object PREVIOUS_OPTION
      "Previous" button option.
      See Also:
    • PROP_AUTO_WIZARD_STYLE

      public static final String PROP_AUTO_WIZARD_STYLE
      Set to true for enabling other properties. It is relevant only on initialization (client property in first panel). Recommended to be set to true in most cases, then wizard can display wizard steps on the left side, create a subtitle on active panel, display of error messages and others. When false or not present in JComponent.getClientProperty(), then supplied panel is used directly without content, help or panel name auto layout. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Boolean type property.
      Since:
      7.8
      See Also:
    • PROP_HELP_DISPLAYED

      public static final String PROP_HELP_DISPLAYED
      Set to true for showing help pane (HTML browser) in the left pane. It is relevant only on initialization (client property in first panel). Help content will be taken from property PROP_HELP_URL. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Boolean type property.
      Since:
      7.8
      See Also:
    • PROP_CONTENT_DISPLAYED

      public static final String PROP_CONTENT_DISPLAYED
      Set to true for showing content pane (steps) in the left pane. It is relevant only on initialization (client property in first panel). Content will be constructed from property PROP_CONTENT_DATA. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Boolean type property.
      Since:
      7.8
      See Also:
    • PROP_CONTENT_NUMBERED

      public static final String PROP_CONTENT_NUMBERED
      Set to true for displaying numbers in the content. It is relevant only on initialization (client property in first panel). The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Boolean type property.
      Since:
      7.8
      See Also:
    • PROP_CONTENT_SELECTED_INDEX

      public static final String PROP_CONTENT_SELECTED_INDEX
      Represents index of content item which will be highlighted. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Integer type property.
      Since:
      7.8
      See Also:
    • PROP_CONTENT_DATA

      public static final String PROP_CONTENT_DATA
      Represents array of content items. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. String[] type property.
      Since:
      7.8
      See Also:
    • PROP_CONTENT_BACK_COLOR

      public static final String PROP_CONTENT_BACK_COLOR
      Set background color of content pane. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Color type property.
      Since:
      7.8
      See Also:
    • PROP_CONTENT_FOREGROUND_COLOR

      public static final String PROP_CONTENT_FOREGROUND_COLOR
      Set foreground color of content pane. The value is taken from WizardDescriptor.getProperty() or ((JComponent)Panel.getComponent()).getClientProperty() in this order. Color type property.
      Since:
      7.8
      See Also:
    • PROP_IMAGE

      public static final String PROP_IMAGE
      Set the image which will be displayed in the left pane (behind the content). The value is taken from WizardDescriptor.getProperty() or ((JComponent) Panel.getComponent()).getClientProperty() in this order. java.awt.Image type property.
      Since:
      7.8
      See Also:
    • PROP_IMAGE_ALIGNMENT

      public static final String PROP_IMAGE_ALIGNMENT
      Set the side where the image should be drawn. The value is taken from WizardDescriptor.getProperty() or ((JComponent) Panel.getComponent()).getClientProperty() in this order. String type property.
      Since:
      7.8
      See Also:
    • PROP_LEFT_DIMENSION

      public static final String PROP_LEFT_DIMENSION
      Dimension of left pane, should be same as dimension of PROP_IMAGE. It is relevant only on initialization (client property in first panel). The value is taken from WizardDescriptor.getProperty() or ((JComponent) Panel.getComponent()).getClientProperty() in this order. Dimension type property.
      Since:
      7.8
      See Also:
    • PROP_HELP_URL

      public static final String PROP_HELP_URL
      Represents URL of help displayed in left pane. The value is taken from WizardDescriptor.getProperty() or ((JComponent) Panel.getComponent()).getClientProperty() in this order. URL type property.
      Since:
      7.8
      See Also:
    • PROP_ERROR_MESSAGE

      public static final String PROP_ERROR_MESSAGE
      Error message that is displayed at the bottom of the wizard. Message informs user why the panel is invalid and possibly why the Next/Finish buttons were disabled. The property must be set to null value to clear the message. The value is taken from WizardDescriptor.getProperty(). String type property.
      Since:
      7.8
      See Also:
    • PROP_WARNING_MESSAGE

      public static final String PROP_WARNING_MESSAGE
      Warning message that is displayed at the bottom of the wizard. Message informs user about possible non fatal problems with current enterd values in the wizard panel. Next/Finish buttons are usually enabled. The property must be set to null value to clear the message. The value is taken from WizardDescriptor.getProperty(). String type property.
      Since:
      7.8
      See Also:
    • PROP_INFO_MESSAGE

      public static final String PROP_INFO_MESSAGE
      Informational message that is displayed at the bottom of the wizard. Message informs user usually about need to fill some field or similar requirements or other non fatal problems. Next/Finish button are usually enabled. The property must be set to null value to clear the message. The value is taken from WizardDescriptor.getProperty(). String type property.
      Since:
      7.8
      See Also:
  • Constructor Details

  • Method Details

    • initialize

      protected void initialize()
      Initializes settings.
      Overrides:
      initialize in class NotifyDescriptor
    • setPanels

      @Deprecated public final void setPanels(WizardDescriptor.Iterator panels)
      Deprecated.
      use setPanelsAndSettings if needed.
      Set a different list of panels. Correctly updates the buttons.
      Parameters:
      panels - the new list of WizardDescriptor.Panels
    • setPanelsAndSettings

      public final <Data> void setPanelsAndSettings(WizardDescriptor.Iterator<Data> panels, Data settings)
      Set a different list of panels. Correctly updates the buttons.
      Parameters:
      panels - the new list of WizardDescriptor.Panels
      settings - the new settings that will be passed to the panels
      Since:
      7.2
    • setOptions

      public void setOptions(Object[] options)
      Set options permitted by the wizard considered as a DialogDescriptor. Substitutes tokens such as NEXT_OPTION with the actual button.
      Overrides:
      setOptions in class NotifyDescriptor
      Parameters:
      options - the options to set
      See Also:
    • setAdditionalOptions

      public void setAdditionalOptions(Object[] options)
      Description copied from class: NotifyDescriptor
      Define an explicit description of the set of additional user-selectable options. Additional options are supposed to be used for help button, etc.

      The usual value for the options parameter is an array of Strings. But the parameter type is an array of Objects. Its interpretation depends on its type:

      Component
      The component is added to the button row directly.
      Icon
      A JButton is created with this icon as its label.
      anything else
      The Object is converted to a string and the result is used to label a JButton.
      Overrides:
      setAdditionalOptions in class NotifyDescriptor
      Parameters:
      options - the options to set
      See Also:
    • setClosingOptions

      public void setClosingOptions(Object[] options)
      Description copied from class: DialogDescriptor
      Setter for list of options that close the dialog. Special values are:
      • null - all options will close the dialog
      • empty array - no option will close the dialog
      Overrides:
      setClosingOptions in class DialogDescriptor
      Parameters:
      options - the options to set
    • getValue

      public Object getValue()
      Overriden to ensure that returned value is one of the XXX_OPTION constants.
      Overrides:
      getValue in class NotifyDescriptor
      Returns:
      an Object indicating the option selected by the user
      See Also:
    • setTitleFormat

      public void setTitleFormat(MessageFormat format)
      Sets the message format to create title of the wizard. The format can take two parameters. The name of the current component and the name returned by the iterator that defines the order of panels. The default value is something like
         {0} wizard {1}
       
      That can be expanded to something like this
         EJB wizard (1 of 8)
       
      This method allows anybody to provide own title format.
      Parameters:
      format - message format to the title
    • getTitleFormat

      public MessageFormat getTitleFormat()
      Getter for current format to be used to format title.
      Returns:
      the format
      See Also:
    • putProperty

      public void putProperty(String name, Object value)
      Allows Panels that use WizardDescriptor as settings object to store additional settings into it.
      Parameters:
      name - name of the property
      value - value of property
    • getProperty

      public Object getProperty(String name)
      Getter for stored property.
      Parameters:
      name - name of the property
      Returns:
      the value
    • getProperties

      public Map<String,Object> getProperties()
      Read only map with stored properties.
      Returns:
      read only map of properties stored using putProperty(java.lang.String, java.lang.Object) method
      Since:
      7.2
    • setHelpCtx

      public void setHelpCtx(org.openide.util.HelpCtx helpCtx)
      Description copied from class: DialogDescriptor
      Set new help context for this dialog descriptor. Fires property change event if successful.

      The implementation should automatically display a help button among the secondary options, without your needing to specify it, if the help context on the descriptor is neither null nor HelpCtx.DEFAULT_HELP. If the descriptor is null, this feature will be disabled (you can still add your own help button manually if you wish, of course). If DEFAULT_HELP (the default), normally the button will also be disabled, however if the inner pane is a component and this component has an associated help ID, that will be used automatically. So most users should never need to manually add a help button: call this method with the correct context, or associate an ID with the displayed component. Note that to set it to null you must explicitly call this method; passing null in the constructor actually sets it to DEFAULT_HELP.

      Overrides:
      setHelpCtx in class DialogDescriptor
      Parameters:
      helpCtx - new help context, can be null (no help)
      See Also:
    • getInstantiatedObjects

      public Set getInstantiatedObjects()
      Returns set of newly instantiated objects if the wizard has been correctly finished. Returns the empty set as default. If the wizard uses the InstantiatingIterator then WizardDescriptor returns a set of Object as same as InstantiatingIterator.instantiate().
      Returns:
      a set of Objects created
      Throws:
      IllegalStateException - if this method is called on the unfinished wizard
      Since:
      4.41
    • updateState

      protected void updateState()
      Updates buttons to reflect the current state of the panels. Can be overridden by subclasses to change the options to special values. In such a case use:
      
         super.updateState ();
         setOptions (...);
       
    • setValue

      public void setValue(Object value)
      Overrides superclass method. Adds reseting of wizard for CLOSED_OPTION.
      Overrides:
      setValue in class NotifyDescriptor
      Parameters:
      value - the chosen value
      See Also:
    • doNextClick

      public final void doNextClick()
      Moves the wizard to its next panel - if Next button is enabled. Always call this method from EDT thread.
      Since:
      7.19
    • doPreviousClick

      public final void doPreviousClick()
      Moves the wizard to its previous panel - if Previous button is enabled. Always call this method from EDT thread.
      Since:
      7.19
    • doFinishClick

      public final void doFinishClick()
      Finishes the wizard - if Finish button is enabled. Always call this method from EDT thread.
      Since:
      7.19
    • doCancelClick

      public final void doCancelClick()
      Cancels the wizard - if Cancel button is enabled. Always call this method from EDT thread.
      Since:
      7.19