com.metamatrix.common.callback
Class CallbackChoices

java.lang.Object
  extended by com.metamatrix.common.callback.CallbackChoices

public class CallbackChoices
extends java.lang.Object

This callback class is used when a component requires an application to ask for YES/NO, OK/CANCEL, YES/NO/CANCEL or other similar confirmations


Field Summary
static int CANCEL
          Return value from class method if CANCEL is chosen.
static int DISMISSED
          Return value form class method if this callback is simply dismissed.
static int ERROR_MESSAGE
          Used for error messages.
static int INFORMATION_MESSAGE
          Used for information messages.
static int NO
          Return value from class method if NO is chosen.
static int OK
          Return value form class method if OK is chosen.
static int OK_CANCEL_OPTION
          Type used to provied Yes or No choice options.
static int QUESTION_MESSAGE
          Used for questions.
static int UNSPECIFIED_MESSAGE
          Used for generic message.
static int UNSPECIFIED_OPTION
          Type used to provied Yes or No choice options.
static int WARNING_MESSAGE
          Used for warning messages.
static int YES
          Return value from class method if YES is chosen.
static int YES_NO_CANCEL_OPTION
          Type used to provied Yes or No choice options.
static int YES_NO_OPTION
          Type used to provied Yes or No choice options.
 
Constructor Summary
CallbackChoices(java.lang.String prompt, int messageType, int optionType, int defaultOption)
          Construct a CallbackChoices with a message type, an option type and a default option.
CallbackChoices(java.lang.String prompt, int messageType, java.lang.String[] options, int defaultOption)
          Construct a CallbackChoices with a message type, a list of options and a default option.
 
Method Summary
 int getDefaultOption()
          Get the default option.
 int getMessageType()
          Get the message type.
 java.lang.String[] getOptions()
          Get the confirmation options.
 int getOptionType()
          Get the option type.
 java.lang.String getPrompt()
          Get the prompt.
 int getSelectedIndex()
          Get the selected confirmation option.
protected  boolean isOutOfBounds(int choice)
           
 void setSelectedIndex(int selection)
          Set the selected confirmation option.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNSPECIFIED_OPTION

public static final int UNSPECIFIED_OPTION
Type used to provied Yes or No choice options.

See Also:
Constant Field Values

YES_NO_OPTION

public static final int YES_NO_OPTION
Type used to provied Yes or No choice options.

See Also:
Constant Field Values

YES_NO_CANCEL_OPTION

public static final int YES_NO_CANCEL_OPTION
Type used to provied Yes or No choice options.

See Also:
Constant Field Values

OK_CANCEL_OPTION

public static final int OK_CANCEL_OPTION
Type used to provied Yes or No choice options.

See Also:
Constant Field Values

DISMISSED

public static final int DISMISSED
Return value form class method if this callback is simply dismissed.

See Also:
Constant Field Values

YES

public static final int YES
Return value from class method if YES is chosen.

See Also:
Constant Field Values

NO

public static final int NO
Return value from class method if NO is chosen.

See Also:
Constant Field Values

CANCEL

public static final int CANCEL
Return value from class method if CANCEL is chosen.

See Also:
Constant Field Values

OK

public static final int OK
Return value form class method if OK is chosen.

See Also:
Constant Field Values

UNSPECIFIED_MESSAGE

public static final int UNSPECIFIED_MESSAGE
Used for generic message.

See Also:
Constant Field Values

ERROR_MESSAGE

public static final int ERROR_MESSAGE
Used for error messages.

See Also:
Constant Field Values

INFORMATION_MESSAGE

public static final int INFORMATION_MESSAGE
Used for information messages.

See Also:
Constant Field Values

WARNING_MESSAGE

public static final int WARNING_MESSAGE
Used for warning messages.

See Also:
Constant Field Values

QUESTION_MESSAGE

public static final int QUESTION_MESSAGE
Used for questions.

See Also:
Constant Field Values
Constructor Detail

CallbackChoices

public CallbackChoices(java.lang.String prompt,
                       int messageType,
                       int optionType,
                       int defaultOption)
Construct a CallbackChoices with a message type, an option type and a default option.

This is used if either a YES/NO, YES/NO/CANCEL or OK/CANCEL confirmation is required.

Parameters:
prompt - the prompt used to request the information
messageType - the message type (INFORMATION_MESSAGE, WARNING_MESSAGE or ERROR_MESSAGE).
optionType - the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION).
defaultOption - the default option from the provided optionType (YES, NO, CANCEL or OK).

CallbackChoices

public CallbackChoices(java.lang.String prompt,
                       int messageType,
                       java.lang.String[] options,
                       int defaultOption)
Construct a CallbackChoices with a message type, a list of options and a default option.

This is used if either a YES/NO, YES/NO/CANCEL or OK/CANCEL confirmation different from the available preset confirmations provided (for example, CONTINUE/ABORT or STOP/GOis required. The confirmation options are listed in the options array, and are displayed by the CallbackHandler implementation in a manner consistent with the way preset options are displayed.

Parameters:
prompt - the prompt used to request the information
messageType - the message type (INFORMATION_MESSAGE, WARNING_MESSAGE or ERROR_MESSAGE).
options - the list of confirmation options.
defaultOption - the default option, represented as an index into the options array.
Method Detail

getPrompt

public java.lang.String getPrompt()
Get the prompt.

Returns:
the prompt used to request the information; never null or zero-length

getMessageType

public int getMessageType()
Get the message type.

Returns:
the message type (INFORMATION, WARNING or ERROR).

getOptionType

public int getOptionType()
Get the option type.

If this method returns UNSPECIFIED_OPTION, then this ConfirmationCallback was instantiated with options instead of an optionType. In this case, invoke the getOptions method to determine which confirmation options to display

Returns:
the option type (YES_NO_OPTION, YES_NO_CANCEL_OPTION or OK_CANCEL_OPTION), or UNSPECIFIED_OPTION if this ConfirmationCallback was instantiated with options instead of an optionType.

getOptions

public java.lang.String[] getOptions()
Get the confirmation options.

Returns:
the list of confirmation options, or null if this ConfirmationCallback was instantiated with an optionType instead of options

getDefaultOption

public int getDefaultOption()
Get the default option.

Returns:
the default option, represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, this method returns the default option as an index into the options array specified to the constructor of this ConfirmationCallback

setSelectedIndex

public void setSelectedIndex(int selection)
Set the selected confirmation option.

Parameters:
selection - the selection represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, the selection represents the index into the options array specified to the constructor of this ConfirmationCallback

getSelectedIndex

public int getSelectedIndex()
Get the selected confirmation option.

Returns:
the selected confirmation option represented as YES, NO, OK or CANCEL if an optionType was specified to the constructor of this ConfirmationCallback. Otherwise, this method returns the selected confirmation option as an index into the options array specified to the constructor of this ConfirmationCallback.

isOutOfBounds

protected boolean isOutOfBounds(int choice)


Copyright © 2009. All Rights Reserved.