|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.jac.aspects.gui.InputSequence
This class allows a GUI programmer to create input sequences to ask the user to fill a set of parameters when invoking a method.
By default, when invoking a method through the GUI, an
InputWrapper
opens a dialog to fill the parameters
values when needed. If an input sequence is attached to this method
(see GuiAC.setInputSequence
), then the input wrappers
will ask for the parameters using several input dialogs, each one
corresponding to a step of the input sequence.
Defining a new input sequence is done by concretizing this class. For instance, the following class defines a sequence with two steps that open input dialogs from some prototypes defined in the class. The first steps asks for a boolean value that will dinamically determines the second step input.
public class MyInputSequence extends InputSequence { public MyInputSequence( Display display, AbstractMethodItem method, Object[] parameters ) { super(display,method,parameters); } public int getNbSteps() { return 2; } public void init() {} public void validate() { Object[] values = getStepValues(2); setParameterValue(0, values[0]); Boolean firstStepResult = getStepValues(1)[0]; if ( firstStepResult.booleanValue() ) { setParameterValue(1, values[1]); } else { setParameterValue(1, null); } } public AbstractMethodItem getStepMethod( int step ) { if( step == 1 ) { return getLocalInputMethod( "myPrototype1" ); } else if ( step == 2 ) { Object[] values = getStepValues(1); Boolean firstStepResult = values[0]; if ( firstStepResult.booleanValue() ) { return getLocalInputMethod( "myPrototype2" ); } else { return getLocalInputMethod( "myPrototype3" ); } else { return null; } } public void myPrototype1( boolean b ) {} public void myPrototype2( String s ) {} public void myPrototype3( String s1, String s2 ) {} }
InputWrapper
Constructor Summary | |
InputSequence(Display display,
AbstractMethodItem method,
Object[] parameters)
Creates a user-defined input sequence. |
Method Summary | |
int |
getCurrentStep()
Returns the current step (indexed from 1). |
protected AbstractMethodItem |
getLocalInputMethod(String name)
Returns the method item that corresponds to a method defined in the user-defined input sequence. |
abstract int |
getNbSteps()
Define this method to return the number of steps (can dynamically change regarding the inputted vaules of the steps). |
abstract AbstractMethodItem |
getStepMethod(int step)
Returns the method that is used to define the input box for a given step. |
protected Object[] |
getStepValues(int step)
Returns the values that were entered by the user for a given step. |
boolean |
hasNextStep()
Tells if the sequence has a next step to perform after the current one. |
abstract void |
init()
This method is called when a new invocation is performed on the method. |
boolean |
nextStep()
Process the next step. |
boolean |
previousStep()
Process the previous step back. |
boolean |
proceedInputs()
Call this method on a new input sequence to process the inputs. |
protected void |
setParameterValue(int i,
Object value)
Sets the parameter value for the final call of the method that will be invoked at the end of the sequence. |
abstract boolean |
validate()
This method is called when the input sequence is finished and when the user validates the last step input. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public InputSequence(Display display, AbstractMethodItem method, Object[] parameters)
display
- the display to use to show the input boxesmethod
- the method that will be finally invoked at the end
of the input sequenceparameters
- the array that contains the parameters of the
invoked methodMethod Detail |
public abstract void init()
Define it if some objects must be dynamically constructed to handle the sequence.
public abstract boolean validate()
Define this method to fill the method parameters from the values found in all the performed steps.
getStepValues(int)
,
setParameterValue(int,Object)
public abstract int getNbSteps()
public final int getCurrentStep()
public final boolean hasNextStep()
public abstract AbstractMethodItem getStepMethod(int step)
This is the most important method since it defines the shape
of an input box step. You should define a set of local method
with the right prototype and get their correponding method item
with the getLocalInputMethod
method.
Note that the method is not actually called but is only used
through the Display.showIntput
method.
step
- the step (indexed from 1)
Display.showInput(Object,AbstractMethodItem,Object[])
,
getLocalInputMethod(String)
public final boolean proceedInputs()
public final boolean nextStep()
public boolean previousStep()
protected AbstractMethodItem getLocalInputMethod(String name)
name
- the method name
protected Object[] getStepValues(int step)
step
- the step number (indexed from 1)
protected void setParameterValue(int i, Object value)
i
- the parameter indexvalue
- the value
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |