org.argouml.uml.cognitive.critics
Class WizAssocComposite

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

public class WizAssocComposite
extends Wizard

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  java.lang.String _instructions
          The initial instructions on the Step 1 screen.
private  WizStepChoice _step1Choice
          Contains the WizStepChoice that is used to get the user's desired options.
private  java.lang.Object _triggerAsc
          The MAssociation WizStepChoice that triggered the critic.
protected static org.apache.log4j.Logger cat
          Deprecated. by Linus Tolke as of 0.15.4. Use your own logger in your class. This will be removed.
 
Fields inherited from class org.argouml.kernel.Wizard
_finished, _item, _panels, _started, _step
 
Constructor Summary
WizAssocComposite()
          Constructor for the wizard.
 
Method Summary
private  java.util.Vector _buildOptions()
          Returns a vector of options to be used in creating a WizStepChoice that will exercise the options.
private  java.lang.Object _getTriggerAsc()
          Tries to identify the MAssociation that triggered the critic.
 boolean canFinish()
          Determine if we have sufficient information to finish.
 void doAction(int oldStep)
          Take action at the completion of a step.
 int getNumSteps()
          Returns the number of steps in this wizard.
 javax.swing.JPanel makePanel(int newStep)
          Create a JPanel for the given step.
 void setInstructions(java.lang.String s)
          Set the initial instruction string for the choice.
 
Methods inherited from class org.argouml.kernel.Wizard
back, canGoBack, canGoNext, doAction, finish, getCurrentPanel, getPanel, getProgress, getToDoItem, isFinished, isStarted, next, setToDoItem, undoAction, undoAction
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cat

protected static org.apache.log4j.Logger cat
Deprecated. by Linus Tolke as of 0.15.4. Use your own logger in your class. This will be removed.


_instructions

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


_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.


_triggerAsc

private java.lang.Object _triggerAsc
The MAssociation 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

getNumSteps

public int getNumSteps()
Returns the number of steps in this wizard.

Specified by:
getNumSteps in class Wizard
Returns:
The number of steps (excluding the initial explanation) in this wizard (1).
See Also:
Wizard

_getTriggerAsc

private java.lang.Object _getTriggerAsc()
Tries to identify the MAssociation 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 _triggerAsc.

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

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

_buildOptions

private java.util.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(java.lang.String s)
Set the initial instruction string for the choice. May be called by the creator of the wizard to override the default.


makePanel

public javax.swing.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 (20040316)ArgoUML HomepageArgoUML Developers' pageArgoUML Cookbook