Package ca.cgjennings.ui.wizard
Class WizardController
- java.lang.Object
-
- ca.cgjennings.ui.wizard.WizardController
-
public class WizardController extends java.lang.Object
Controllers encapsulate the logic needed to coordinate the various components of a wizard dialog. By using a controller, you do not need to subclass a specific wizard dialog base class. Instead, you can convert any group of appropriate controls to have wizard-like functionality.The controller links a group of
JButton
s, aWizardPanel
, and aWizardModel
. The buttons are used to control the page turning and finish actions of the panel. The controller will attach appropriate listeners to the buttons and use these to modify the current page in the model or finish the wizard.- Since:
- 3.0
- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.JButton
finishBtn
protected WizardModel
model
protected javax.swing.JButton
nextBtn
protected WizardPanel
panel
protected javax.swing.JButton
prevBtn
-
Constructor Summary
Constructors Constructor Description WizardController(javax.swing.JButton nextBtn, javax.swing.JButton prevBtn, javax.swing.JButton finishBtn, WizardPanel panel, WizardModel model)
Creates a new controller that makes aWizardPanel
interactive by linking it with a set of controls and aWizardModel
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Removes all listeners installed by the controller and causes it to cease functioning as a controller.javax.swing.JButton
getFinishButton()
Returns the button that finishes the wizard.WizardModel
getModel()
Returns the model that controls the page logic.javax.swing.JButton
getNextPageButton()
Returns the button that advances to the next page.WizardPanel
getPanel()
Returns the panel that displays the pages of the wizard.javax.swing.JButton
getPreviousPageButton()
Returns the button that goes back to the next page.protected void
handleFinishButton()
Called to handle the user pressing the Finish button.protected void
handleNextPageButton()
Called to handle the user pressing the Next/Continue button.protected void
handlePreviousPageButton()
Called to handle the user pressing the Back/Go Back button.protected void
install()
This is called by the constructor to install event handlers on the buttons.protected void
updateButtonStates()
Updates the enabled states of the buttons to reflect the current state of the model.
-
-
-
Field Detail
-
nextBtn
protected final javax.swing.JButton nextBtn
-
prevBtn
protected final javax.swing.JButton prevBtn
-
finishBtn
protected final javax.swing.JButton finishBtn
-
panel
protected final WizardPanel panel
-
model
protected final WizardModel model
-
-
Constructor Detail
-
WizardController
public WizardController(javax.swing.JButton nextBtn, javax.swing.JButton prevBtn, javax.swing.JButton finishBtn, WizardPanel panel, WizardModel model)
Creates a new controller that makes aWizardPanel
interactive by linking it with a set of controls and aWizardModel
.- Parameters:
nextBtn
- the button that will advance to the next pageprevBtn
- the button that will go back to the previous pagefinishBtn
- the button that will finish the wizard procedurepanel
- the panel that displays pages from the modelmodel
- the model that controls the page order and fires events
-
-
Method Detail
-
install
protected void install()
This is called by the constructor to install event handlers on the buttons. Subclasses may override this to alter the controller logic.
-
updateButtonStates
protected void updateButtonStates()
Updates the enabled states of the buttons to reflect the current state of the model.
-
handleNextPageButton
protected void handleNextPageButton()
Called to handle the user pressing the Next/Continue button. Can be overridden to modify controller behaviour.
-
handlePreviousPageButton
protected void handlePreviousPageButton()
Called to handle the user pressing the Back/Go Back button. Can be overridden to modify controller behaviour.
-
handleFinishButton
protected void handleFinishButton()
Called to handle the user pressing the Finish button. Can be overridden to modify controller behaviour.
-
dispose
public void dispose()
Removes all listeners installed by the controller and causes it to cease functioning as a controller. This should be called if you wish to replace this controller with another one.
-
getNextPageButton
public javax.swing.JButton getNextPageButton()
Returns the button that advances to the next page.- Returns:
- the Next button
-
getPreviousPageButton
public javax.swing.JButton getPreviousPageButton()
Returns the button that goes back to the next page.- Returns:
- the Go Back button
-
getFinishButton
public javax.swing.JButton getFinishButton()
Returns the button that finishes the wizard.- Returns:
- the Finish button
-
getPanel
public WizardPanel getPanel()
Returns the panel that displays the pages of the wizard.- Returns:
- the panel linked to the controller
-
getModel
public WizardModel getModel()
Returns the model that controls the page logic.- Returns:
- the model linked to the controller
-
-