org.argouml.uml.cognitive.critics
Class WizAssocComposite

java.lang.Object
  extended byorg.argouml.cognitive.ui.Wizard
      extended byorg.argouml.uml.cognitive.critics.UMLWizard
          extended byorg.argouml.uml.cognitive.critics.WizAssocComposite
All Implemented Interfaces:
Serializable

public class WizAssocComposite
extends UMLWizard

A non-modal wizard to assist the user in changing aggregation of an association.

Earlier version always imposed composite aggregation. This version allows the user to choose.

Note. This only applies to binary associations. A separate wizard is needed for 3-way (or more) associations.

See Also:
"ArgoUML User Manual: Two Aggregate ends (roles) in binary Association", Serialized Form

Field Summary
private  String instructions
          The initial instructions on the Step 1 screen.
private static Logger LOG
          Logger.
private  WizStepChoice step1Choice
          Contains the WizStepChoice that is used to get the user's desired options.
private  Object triggerAssociation
          The Association WizStepChoice that triggered the critic.
 
Fields inherited from class org.argouml.uml.cognitive.critics.UMLWizard
 
Fields inherited from class org.argouml.cognitive.ui.Wizard
 
Constructor Summary
WizAssocComposite()
          Constructor for the wizard.
 
Method Summary
private  Vector buildOptions()
          Returns a vector of options to be used in creating a WizStepChoice that will exercise the options.
 boolean canFinish()
          Determine if we have sufficient information to finish.
 void doAction(int oldStep)
          Take action at the completion of a step.
private  Object getTriggerAssociation()
          Tries to identify the Association that triggered the critic.
 JPanel makePanel(int newStep)
          Create a JPanel for the given step.
 void setInstructions(String s)
          Set the initial instruction string for the choice.
 
Methods inherited from class org.argouml.uml.cognitive.critics.UMLWizard
getModelElement, getNumSteps, getSuggestion, offerSuggestion, setSuggestion
 
Methods inherited from class org.argouml.cognitive.ui.Wizard
back, canGoBack, canGoNext, doAction, finish, getCurrentPanel, getPanel, getProgress, getStep, getToDoItem, isFinished, isStarted, next, removePanel, setToDoItem, undoAction, undoAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Logger LOG
Logger.


instructions

private String instructions
The initial instructions on the Step 1 screen. May be set to a different string through setInstructions(String).


step1Choice

private WizStepChoice step1Choice
Contains the WizStepChoice that is used to get the user's desired options. Not created until we get to that step.


triggerAssociation

private Object triggerAssociation
The Association WizStepChoice that triggered the critic. Null until set when it is first needed.

Constructor Detail

WizAssocComposite

public WizAssocComposite()
Constructor for the wizard. Currently does nothing.

Method Detail

getTriggerAssociation

private Object getTriggerAssociation()
Tries to identify the Association that triggered the critic.

The first time it is called, it will initialise the trigger from the ToDoItem. If there, it is assumed to be the first trigger of the ToDoItem and to be an association. If found, the value is stored in the private field triggerAssociation.

On all subsequent calls, if a non-null value is found in triggerAssociation that is returned.

Returns:
the Association that triggered the critic, or null if there was none.

buildOptions

private Vector buildOptions()
Returns a vector of options to be used in creating a WizStepChoice that will exercise the options.

We provide five options, shared aggregation in each direction, composite aggregation in each direction and no aggregation at all.

It is possible that a very malicious user could delete the triggering association just before we get to this point. For now we don't bother to trap this. It will raise an exception, and then everything will carry on happily.

Returns:
A Vector of the options or null if the association that triggered the critic is no longer there.

setInstructions

public void setInstructions(String s)
Set the initial instruction string for the choice. May be called by the creator of the wizard to override the default.

Parameters:
s - The new instructions.

makePanel

public JPanel makePanel(int newStep)
Create a JPanel for the given step.

We use a WizStepChoice to handle the choice selection for the user. We only create the panel once, saving it in a private field (_step1Choice) for subsequent use.

Note. If the association has been deleted, then we may not be able to create a vector of options. Under these circumstances we also return null.

Specified by:
makePanel in class Wizard
Parameters:
newStep - The index of the step for which a panel is needed.
Returns:
The created JPanel or null if no options were available.
See Also:
Wizard

doAction

public void doAction(int oldStep)
Take action at the completion of a step.

The guideline for ArgoUML non-modal wizards is to act immediately, not wait for the finish. This method may also be invoked when finish is triggered for any steps whose panels didn't get created.

The observation is that this seems to be trigged when there is any change on the panel (e.g choosing an option), not just when "next" is pressed. Coded accordingly

We allow for the association that caused the problem having by now been deleted, and hence an exception may be raised. We catch this politely.

Specified by:
doAction in class Wizard
Parameters:
oldStep - The index of the step just completed (0 for the first information panel)
See Also:
Wizard

canFinish

public boolean canFinish()
Determine if we have sufficient information to finish.

We can't finish if our parent Wizard can't finish.

We can finish if we're on step 0.

We can finish if we're on step 1 and have made a choice.

Overrides:
canFinish in class Wizard
Returns:
true if we can finish, otherwise false.
See Also:
Wizard


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