Class TextOption
java.lang.Object
edu.wisc.ssec.mcidasv.startupmanager.options.AbstractOption
edu.wisc.ssec.mcidasv.startupmanager.options.TextOption
- All Implemented Interfaces:
Option
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTextOption
(String id, String label, String defaultValue, OptionMaster.OptionPlatform optionPlatform, OptionMaster.Visibility optionVisibility) Create a startup option that allows the user to supply arbitrary text. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromPrefsFormat
(String text) Initializes the current option using a relevant variable from the startup script.Builds aJTextField
containing the text value specified in the constructor.getValue()
Returns the user's input (or the default value).static String
removeOutermostQuotes
(String value) If the givenString
begins and ends withOptionMaster.QUOTE_STRING
, this method will return the givenString
without the "outermost" quote pair.void
Stores the user's input.toString()
String
representation of thisTextOption
.Methods inherited from class edu.wisc.ssec.mcidasv.startupmanager.options.AbstractOption
getLabel, getOptionId, getOptionPlatform, getOptionType, getOptionVisibility, isValidPrefFormat, onValidPlatform, toPrefsFormat
-
Field Details
-
value
Text field value.
-
-
Constructor Details
-
TextOption
public 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.NOTE:
null
is not a permitted value for any of this constructor's parameters.- 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.
-
-
Method Details
-
getComponent
Builds aJTextField
containing the text value specified in the constructor.- Specified by:
getComponent
in interfaceOption
- Specified by:
getComponent
in classAbstractOption
- Returns:
JTextField
to present to the user.
-
getValue
Returns the user's input (or the default value).- Specified by:
getValue
in interfaceOption
- Specified by:
getValue
in classAbstractOption
- Returns:
- Input or default value.
-
setValue
Stores the user's input.- Specified by:
setValue
in interfaceOption
- Specified by:
setValue
in classAbstractOption
- Parameters:
newValue
- User input. Should not benull
; use a zero lengthString
to specify an empty value.
-
fromPrefsFormat
Initializes the current option using a relevant variable from the startup script.- Specified by:
fromPrefsFormat
in interfaceOption
- Overrides:
fromPrefsFormat
in classAbstractOption
- Parameters:
text
- Line from the startup script that represents the current option.null
is not allowed.- Throws:
IllegalArgumentException
- iftext
is not in the proper format for the current platform.
-
toString
String
representation of thisTextOption
.- Specified by:
toString
in interfaceOption
- Specified by:
toString
in classAbstractOption
- Returns:
String
that looks something like "[TextOption@7825114a: optionId=BLAH value=USER INPUT]".- See Also:
-
removeOutermostQuotes
If the givenString
begins and ends withOptionMaster.QUOTE_STRING
, this method will return the givenString
without the "outermost" quote pair. Otherwise theString
is returned without modification.- Parameters:
value
-String
from which the outermost pair of quotes should be removed. Cannot benull
.- Returns:
- Either
value
with the outermost pair of quotes removed, orvalue
, unmodified.
-