public abstract class AbstractOption extends Object implements Option
Modifier and Type | Field and Description |
---|---|
private String |
label
Brief description of the option.
|
private String |
optionId
A unique identifier for an option.
|
private OptionMaster.OptionPlatform |
optionPlatform |
private OptionMaster.Type |
optionType |
private OptionMaster.Visibility |
optionVisibility |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
fromPrefsFormat(String text)
Initializes the current option using a relevant variable from the
startup script.
|
abstract JComponent |
getComponent()
Returns the GUI component that represents the option.
|
String |
getLabel()
Returns a brief description of this option.
|
String |
getOptionId()
Returns the ID used when referring to this option.
|
OptionMaster.OptionPlatform |
getOptionPlatform()
Returns the platform(s) to which this option applies.
|
OptionMaster.Type |
getOptionType()
Returns this option's type.
|
OptionMaster.Visibility |
getOptionVisibility()
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 |
onValidPlatform()
Determines if the option applies to the current platform.
|
abstract void |
setValue(String value)
Forces the value of the option to the data specified.
|
String |
toPrefsFormat()
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.
|
private final String optionId
private final String label
private final OptionMaster.Type optionType
OptionMaster.Type
private final OptionMaster.OptionPlatform optionPlatform
OptionMaster.OptionPlatform
private final OptionMaster.Visibility optionVisibility
OptionMaster.Visibility
public AbstractOption(String id, String label, OptionMaster.Type optionType, OptionMaster.OptionPlatform optionPlatform, OptionMaster.Visibility optionVisibility)
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.protected boolean onValidPlatform()
true
if this option is applicable, false
otherwise.protected boolean isValidPrefFormat(String text)
text
- The string to test.public OptionMaster.Type getOptionType()
getOptionType
in interface Option
OptionMaster.Type
public OptionMaster.OptionPlatform getOptionPlatform()
getOptionPlatform
in interface Option
OptionMaster.OptionPlatform
public OptionMaster.Visibility getOptionVisibility()
getOptionVisibility
in interface Option
OptionMaster.Visibility
public String getOptionId()
getOptionId
in interface Option
public String getLabel()
public void fromPrefsFormat(String text)
fromPrefsFormat
in interface Option
text
- Line from the startup script that represents the current
option.IllegalArgumentException
- if text
is not in the proper
format for the current platform.public String toPrefsFormat()
toPrefsFormat
in interface Option
isValidPrefFormat(String)
public abstract JComponent getComponent()
BooleanOptions
are represented by a
JCheckBox
, while TextOptions
appear as a
JTextField
.getComponent
in interface Option
public abstract String getValue()
BooleanOptions
return either "0" or
"1".public abstract void setValue(String value)
BooleanOptions
accept either "0", or
"1".public abstract String toString()
toString
in interface Option
toString
in class Object
String
containing relevant info about the option.TextOption.toString()
,
BooleanOption.toString()