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