org.argouml.cognitive.ui
Class Wizard

java.lang.Object
  extended byorg.argouml.cognitive.ui.Wizard
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
UMLWizard

public abstract class Wizard
extends Object
implements Serializable

"Abstract" base class for non-modal wizards. Each subclass should define its own makeNextPanel methods. Because most wizards will not be run to completion, the panels are constructed only as needed. This implies that Wizards should not initialize many instance variables in their constructors.

By convention step 0 is the problem description of the ToDoItem, step 1 is the first panel displayed after the user presses "Next>", and so on. The problem description panel is not stored in this wizard, only the panels that are specific to the wizard are stored. If the user presses "Back>" enough times to get back to the problem description, backPanel should return null. A null panel indicates that the problem description should be shown.

Several of the comments in this class refer to "context". Context is the data about this execution of this wizard, for example, values that the user enters in step 1 is part of the context of later steps, and the ToDoItem with its offenders Set is always context. Most context should be stored in instance variables of Wizard subclasses.

See Also:
Serialized Form

Field Summary
private  boolean finished
          True when the wizard has done everything it can.
private  WizardItem item
           
private  Vector panels
          User interface panels displayed so far.
private  boolean started
           
private  int step
          The current step that the Wizard is on.
 
Constructor Summary
Wizard()
          Construct a new wizard to help the user repair a design flaw.
 
Method Summary
 void back()
          Step back.
 boolean canFinish()
           
 boolean canGoBack()
           
 boolean canGoNext()
          Return true iff the "Next>" button should be enabled.
 void doAction()
          Do the action of this wizard.
abstract  void doAction(int oldStep)
          Take action at the completion of a step.
 void finish()
          Finish the wizard.
 JPanel getCurrentPanel()
          Get the panel that should be displayed now.
abstract  int getNumSteps()
          Get the number of steps in this wizard.
 JPanel getPanel(int s)
          Get the exising panel at step s.
 int getProgress()
          An integer between 0 and 100, shows percent done.
protected  int getStep()
           
 WizardItem getToDoItem()
           
 boolean isFinished()
           
 boolean isStarted()
           
abstract  JPanel makePanel(int newStep)
          Create a new panel for the given step.
 void next()
          The next step of the wizard.
protected  void removePanel(int s)
           
 void setToDoItem(WizardItem i)
          Setter for the todoitem.
 void undoAction()
          Undo the action.
 void undoAction(int oldStep)
          Undo the action done after the given step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

panels

private Vector panels
User interface panels displayed so far.


step

private int step
The current step that the Wizard is on. Zero indicates that the wizard has not yet begun.


finished

private boolean finished
True when the wizard has done everything it can.


started

private boolean started

item

private WizardItem item
Constructor Detail

Wizard

public Wizard()
Construct a new wizard to help the user repair a design flaw.

Method Detail

removePanel

protected void removePanel(int s)
Parameters:
s - the step number of the panel to be removed

setToDoItem

public void setToDoItem(WizardItem i)
Setter for the todoitem.

Parameters:
i - the todoitem

getToDoItem

public WizardItem getToDoItem()
Returns:
the todoitem

getProgress

public int getProgress()
An integer between 0 and 100, shows percent done. The current ArgoUML user interface shows different PostIt note icons for 0, 1-25, 26-50. 51-75, and 76-100.

Returns:
the percentage done.

getNumSteps

public abstract int getNumSteps()
Get the number of steps in this wizard. Subclasses should override to return a constant, or compute based on context.

Returns:
the number of steps in this wizard.

getCurrentPanel

public JPanel getCurrentPanel()
Get the panel that should be displayed now. Usually called after the user pressed "Next>" and next() has returned, or after the user pressed "<Back" and back() has returned. Also called when the user turns away from the wizard to do something else and then returns his or her attention to the wizard.

Returns:
the panel that should be displayed now.

getPanel

public JPanel getPanel(int s)
Get the exising panel at step s. Step 1 is the first wizard panel.

Parameters:
s - the step
Returns:
the panel for step s or null if none.

canGoNext

public boolean canGoNext()
Return true iff the "Next>" button should be enabled. Subclasses should override to first check super.nextEnabled() and then check for legal context values.

Returns:
true iff the "Next>" button should be enabled.

next

public void next()
The next step of the wizard.


canGoBack

public boolean canGoBack()
Returns:
true if we can step back

back

public void back()
Step back.


canFinish

public boolean canFinish()
Returns:
true if we can finish (i.e. the finish button is not downlighted)

isStarted

public boolean isStarted()
Returns:
true if the wizard is started

isFinished

public boolean isFinished()
Returns:
true if the wizard is finished

finish

public void finish()
Finish the wizard.


makePanel

public abstract JPanel makePanel(int newStep)
Create a new panel for the given step. For example, When the given step is 1, create the first step of the wizard.

TODO: It might be convient to make a reusable subclass of Wizard that shows all textual steps to guide the user without any automation. Such a Wizard could be easily authored, stored in an XML file, and efficiently presented by reusing a single panel with a single JTextArea.

Parameters:
newStep - the number of the step to make a panel for.
Returns:
a new panel for the given step

doAction

public abstract void doAction(int oldStep)
Take action at the completion of a step. For example, when the given step is 0, do nothing; and when the given step is 1, do the first action. Argo non-modal wizards should take action as they do along, as soon as possible, they should not wait until the final step. Also, if the user pressed "Finish" doAction may be called for steps that never constructored or displayed their panels.

Parameters:
oldStep - the given step

doAction

public void doAction()
Do the action of this wizard.


undoAction

public void undoAction(int oldStep)
Undo the action done after the given step. For example, when the given step is 0, nothing was done, so nothing can be undone; and when the given step is 1, undo the first action. Undo allows users to work part way through fixing a problem, see the partial result, and explore a different alternative.

Parameters:
oldStep - the given step

undoAction

public void undoAction()
Undo the action.


getStep

protected int getStep()
Returns:
Returns the step.


ArgoUML © 1996-2004 (20050222)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook