Package adams.flow.template
Class SimpleMenu
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,ShallowCopySupporter<AbstractActorTemplate>,SizeOfHandler,Serializable
public class SimpleMenu extends AbstractActorTemplate
Generates a sub-flow that displays a dialog with the choice strings as buttons.
If custom values are used, then these strings get stored in the variable rather than the choice strings.
When enabling looping, ensure you have an exit option in the menu that sets the loop_state variable to 'false' to avoid an endless loop menu.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-name <java.lang.String> (property: name) The new name for the actor; leave empty to use current. default:
-message <java.lang.String> (property: message) The message to prompt the user with. default: Please select
-choice <adams.core.base.BaseString> [-choice ...] (property: choices) The strings that get displayed as buttons. default:
-use-custom-values <boolean> (property: useCustomValues) If enabled, the associated custom value gets stored in the variable rather than the choice string. default: false
-value <adams.core.base.BaseString> [-value ...] (property: values) The values associated with the choice strings. default:
-choice-variable <adams.core.VariableName> (property: choiceVariable) The name of the variable to use for storing the choice. default: choice
-cancelled-variable <adams.core.VariableName> (property: cancelledVariable) The name of the variable to use for storing the cancelled state. default: cancelled
-loop-menu <boolean> (property: loopMenu) If enabled, the menu gets wrapped in a while loop. default: false
-loop-variable <adams.core.VariableName> (property: loopVariable) The name of the variable for storing the loop state; this variable needs to get initialized with 'true' before the while loop. default: loop_state
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected VariableNamem_CancelledVariablethe variable to store the cancelled state in.protected BaseString[]m_Choicesthe choices.protected VariableNamem_ChoiceVariablethe variable to store the choice in.protected booleanm_LoopMenuwhether to loop the menu.protected VariableNamem_LoopVariablethe variable for storing the loop state.protected Stringm_Messagethe message for the user.protected booleanm_UseCustomValueswhether to use custom values.protected BaseString[]m_Valuesthe values associated with the choice strings.-
Fields inherited from class adams.flow.template.AbstractActorTemplate
m_Name
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description SimpleMenu()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcancelledVariableTipText()Returns the tip text for this property.StringchoicesTipText()Returns the tip text for this property.StringchoiceVariableTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected ActordoGenerate()Generates the actor.VariableNamegetCancelledVariable()Returns the variable name to use for storing the cancelled state.BaseString[]getChoices()Returns the choices, which get displayed as buttons.VariableNamegetChoiceVariable()Returns the variable name to use for storing the choice.booleangetLoopMenu()Returns whether to wrap the menu in a while loop.VariableNamegetLoopVariable()Returns the variable name to use for storing the cancelled state.StringgetMessage()Returns the message the user is prompted with.booleangetUseCustomValues()Returns whether to store the associate value in the variable rather than the choice string.BaseString[]getValues()Returns the associated value strings.StringglobalInfo()Returns a string describing the object.booleanisInteractive()Whether the flow generated is an interactive one.StringloopMenuTipText()Returns the tip text for this property.StringloopVariableTipText()Returns the tip text for this property.StringmessageTipText()Returns the tip text for this property.voidsetCancelledVariable(VariableName value)Sets the variable name to use for storing the cancelled state.voidsetChoices(BaseString[] value)Sets the choices, which get displayed as buttons.voidsetChoiceVariable(VariableName value)Sets the variable name to use for storing the choice.voidsetLoopMenu(boolean value)Sets whether to wrap the menu in a while loop.voidsetLoopVariable(VariableName value)Sets the variable name to use for storing the cancelled state.voidsetMessage(String value)Sets the message to prompt the user with.voidsetUseCustomValues(boolean value)Sets whether to store the associate value in the variable rather than the choice string.voidsetValues(BaseString[] value)Sets the associated value strings.StringuseCustomValuesTipText()Returns the tip text for this property.StringvaluesTipText()Returns the tip text for this property.-
Methods inherited from class adams.flow.template.AbstractActorTemplate
compareTo, equals, forCommandLine, forName, generate, getBaselineCorrections, getDefaultName, getName, nameTipText, postGenerate, preGenerate, setName, shallowCopy, shallowCopy
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Message
protected String m_Message
the message for the user.
-
m_Choices
protected BaseString[] m_Choices
the choices.
-
m_UseCustomValues
protected boolean m_UseCustomValues
whether to use custom values.
-
m_Values
protected BaseString[] m_Values
the values associated with the choice strings.
-
m_ChoiceVariable
protected VariableName m_ChoiceVariable
the variable to store the choice in.
-
m_CancelledVariable
protected VariableName m_CancelledVariable
the variable to store the cancelled state in.
-
m_LoopMenu
protected boolean m_LoopMenu
whether to loop the menu.
-
m_LoopVariable
protected VariableName m_LoopVariable
the variable for storing the loop state.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractActorTemplate
-
setMessage
public void setMessage(String value)
Sets the message to prompt the user with.- Parameters:
value- the message
-
getMessage
public String getMessage()
Returns the message the user is prompted with.- Returns:
- the message
-
messageTipText
public String messageTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setChoices
public void setChoices(BaseString[] value)
Sets the choices, which get displayed as buttons.- Parameters:
value- the choices
-
getChoices
public BaseString[] getChoices()
Returns the choices, which get displayed as buttons.- Returns:
- the choices
-
choicesTipText
public String choicesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseCustomValues
public void setUseCustomValues(boolean value)
Sets whether to store the associate value in the variable rather than the choice string.- Parameters:
value- true if to use custom values
-
getUseCustomValues
public boolean getUseCustomValues()
Returns whether to store the associate value in the variable rather than the choice string.- Returns:
- true if to use custom values
-
useCustomValuesTipText
public String useCustomValuesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setChoiceVariable
public void setChoiceVariable(VariableName value)
Sets the variable name to use for storing the choice.- Parameters:
value- the variable name
-
getChoiceVariable
public VariableName getChoiceVariable()
Returns the variable name to use for storing the choice.- Returns:
- the variable name
-
choiceVariableTipText
public String choiceVariableTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setValues
public void setValues(BaseString[] value)
Sets the associated value strings.- Parameters:
value- the values
-
getValues
public BaseString[] getValues()
Returns the associated value strings.- Returns:
- the values
-
valuesTipText
public String valuesTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setCancelledVariable
public void setCancelledVariable(VariableName value)
Sets the variable name to use for storing the cancelled state.- Parameters:
value- the variable name
-
getCancelledVariable
public VariableName getCancelledVariable()
Returns the variable name to use for storing the cancelled state.- Returns:
- the variable name
-
cancelledVariableTipText
public String cancelledVariableTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLoopMenu
public void setLoopMenu(boolean value)
Sets whether to wrap the menu in a while loop.- Parameters:
value- true if to loop
-
getLoopMenu
public boolean getLoopMenu()
Returns whether to wrap the menu in a while loop.- Returns:
- true if to loop
-
loopMenuTipText
public String loopMenuTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setLoopVariable
public void setLoopVariable(VariableName value)
Sets the variable name to use for storing the cancelled state.- Parameters:
value- the variable name
-
getLoopVariable
public VariableName getLoopVariable()
Returns the variable name to use for storing the cancelled state.- Returns:
- the variable name
-
loopVariableTipText
public String loopVariableTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
isInteractive
public boolean isInteractive()
Whether the flow generated is an interactive one.- Specified by:
isInteractivein classAbstractActorTemplate- Returns:
- true if interactive
-
doGenerate
protected Actor doGenerate()
Generates the actor.- Specified by:
doGeneratein classAbstractActorTemplate- Returns:
- the generated actor
-
-