public class TextOption extends AbstractOption
Constructor and Description |
---|
TextOption(String id,
String label,
String defaultValue,
OptionMaster.OptionPlatform optionPlatform,
OptionMaster.Visibility optionVisibility)
Create a startup option that allows the user to supply arbitrary text.
|
Modifier and Type | Method and Description |
---|---|
void |
fromPrefsFormat(String text)
Initializes the current option using a relevant variable from the
startup script.
|
JTextField |
getComponent()
Builds a
JTextField containing the text value specified in the
constructor. |
String |
getValue()
Returns the user's input (or the default value).
|
static String |
removeOutermostQuotes(String value)
If the given
String begins and ends with
OptionMaster.QUOTE_STRING , this method will return the given
String without the "outermost" quote pair. |
void |
setValue(String newValue)
Stores the user's input.
|
String |
toString()
String representation of this TextOption . |
getLabel, getOptionId, getOptionPlatform, getOptionType, getOptionVisibility, isValidPrefFormat, onValidPlatform, toPrefsFormat
public TextOption(String id, String label, String defaultValue, OptionMaster.OptionPlatform optionPlatform, OptionMaster.Visibility optionVisibility)
NOTE: null
is not a permitted value for any of this
constructor's parameters.
id
- Identifier for this startup option.label
- Brief description suitable for a GUI label.defaultValue
- Default value for this startup option.optionPlatform
- Platforms where this option may be applied.optionVisibility
- Whether or not the option is presented via the GUI.public JTextField getComponent()
JTextField
containing the text value specified in the
constructor.getComponent
in interface Option
getComponent
in class AbstractOption
JTextField
to present to the user.public String getValue()
getValue
in interface Option
getValue
in class AbstractOption
public void setValue(String newValue)
setValue
in interface Option
setValue
in class AbstractOption
newValue
- User input. Should not be null
; use a zero
length String
to specify an empty value.public void fromPrefsFormat(String text)
fromPrefsFormat
in interface Option
fromPrefsFormat
in class AbstractOption
text
- Line from the startup script that represents the current
option. null
is not allowed.IllegalArgumentException
- if text
is not in the proper
format for the current platform.public String toString()
String
representation of this TextOption
.toString
in interface Option
toString
in class AbstractOption
String
that looks something like
"[TextOption@7825114a: optionId=BLAH value=USER INPUT]".toString()
,
BooleanOption.toString()
public static String removeOutermostQuotes(String value)
String
begins and ends with
OptionMaster.QUOTE_STRING
, this method will return the given
String
without the "outermost" quote pair. Otherwise
the String
is returned without modification.value
- String
from which the outermost pair of quotes
should be removed. Cannot be null
.value
with the outermost pair of quotes removed,
or value
, unmodified.