Class AbstractOption
java.lang.Object
edu.wisc.ssec.mcidasv.startupmanager.options.AbstractOption
- All Implemented Interfaces:
Option
- Direct Known Subclasses:
BooleanOption
,DirectoryOption
,FileOption
,LoggerLevelOption
,MemoryOption
,SliderOption
,TextOption
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final String
Brief description of the option.private final String
A unique identifier for an option.private final OptionMaster.OptionPlatform
private final OptionMaster.Type
private final OptionMaster.Visibility
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractOption
(String id, String label, OptionMaster.Type optionType, OptionMaster.OptionPlatform optionPlatform, OptionMaster.Visibility optionVisibility) Creates an option that can hold a specified sort of data and that applies to a given platform. -
Method Summary
Modifier and TypeMethodDescriptionvoid
fromPrefsFormat
(String text) Initializes the current option using a relevant variable from the startup script.abstract JComponent
Returns the GUI component that represents the option.getLabel()
Returns a brief description of this option.Returns the ID used when referring to this option.Returns the platform(s) to which this option applies.Returns this option's type.Returns whether or not this option represents a visible UI element.abstract String
getValue()
Returns the value of the option.protected boolean
isValidPrefFormat
(String text) Tests the specified string to see if it's valid for the current platform.protected boolean
Determines if the option applies to the current platform.abstract void
Forces the value of the option to the data specified.Returns a string representation of the current option that is suitable for use in the startup script.abstract String
toString()
Friendly string representation of the option.
-
Field Details
-
optionId
A unique identifier for an option. Should be the same as the startup variable name found in the startup preference file. -
label
Brief description of the option. It will appear as the option's label in the GUI. -
optionType
- See Also:
-
optionPlatform
- See Also:
-
optionVisibility
- See Also:
-
-
Constructor Details
-
AbstractOption
public AbstractOption(String id, String label, OptionMaster.Type optionType, OptionMaster.OptionPlatform optionPlatform, OptionMaster.Visibility optionVisibility) Creates an option that can hold a specified sort of data and that applies to a given platform.- Parameters:
id
- ID used to refer to this option.label
- Text that'll be used as the GUI label for this optionoptionType
- Type of data this option will represent.optionPlatform
- Platform(s) where this option is applicable.optionVisibility
- Visibility behavior of this option.
-
-
Method Details
-
onValidPlatform
Determines if the option applies to the current platform.- Returns:
true
if this option is applicable,false
otherwise.
-
isValidPrefFormat
Tests the specified string to see if it's valid for the current platform. Currently strings that contain "SET " [ note the space ] are considered to be Windows-only, while strings lacking "SET " are considered Unix-like.- Parameters:
text
- The string to test.- Returns:
- Whether or not the string is valid.
-
getOptionType
Returns this option's type.- Specified by:
getOptionType
in interfaceOption
- Returns:
- Option's type.
- See Also:
-
getOptionPlatform
Returns the platform(s) to which this option applies.- Specified by:
getOptionPlatform
in interfaceOption
- Returns:
- Option's platform.
- See Also:
-
getOptionVisibility
Returns whether or not this option represents a visible UI element.- Specified by:
getOptionVisibility
in interfaceOption
- Returns:
- The option's visibility.
- See Also:
-
getOptionId
Returns the ID used when referring to this option.- Specified by:
getOptionId
in interfaceOption
- Returns:
- Option's ID.
-
getLabel
Returns a brief description of this option. Mostly useful for providing a GUI label. -
fromPrefsFormat
Initializes the current option using a relevant variable from the startup script.- Specified by:
fromPrefsFormat
in interfaceOption
- Parameters:
text
- Line from the startup script that represents the current option.- Throws:
IllegalArgumentException
- iftext
is not in the proper format for the current platform.
-
toPrefsFormat
Returns a string representation of the current option that is suitable for use in the startup script.- Specified by:
toPrefsFormat
in interfaceOption
- Returns:
- Current value of this option as a startup script variable. The formatting changes slightly between "Unix-like" platforms and Windows.
- See Also:
-
getComponent
Returns the GUI component that represents the option.BooleanOptions
are represented by aJCheckBox
, whileTextOptions
appear as aJTextField
.- Specified by:
getComponent
in interfaceOption
- Returns:
- The GUI representation of this option.
-
getValue
Returns the value of the option. Note thatBooleanOptions
return either "0" or "1". -
setValue
Forces the value of the option to the data specified. Note thatBooleanOptions
accept either "0", or "1". -
toString
Friendly string representation of the option.
-