edu.wisc.ssec.mcidasv.startupmanager.options
Class AbstractOption

java.lang.Object
  extended by edu.wisc.ssec.mcidasv.startupmanager.options.AbstractOption
All Implemented Interfaces:
Option
Direct Known Subclasses:
BooleanOption, DirectoryOption, LoggerLevelOption, MemoryOption, SliderOption, TextOption

public abstract class AbstractOption
extends Object
implements Option


Field Summary
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 Summary
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.
 
Method Summary
 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.
private  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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

optionId

private final String optionId
A unique identifier for an option. Should be the same as the startup variable name found in the startup preference file.


label

private final String label
Brief description of the option. It will appear as the option's label in the GUI.


optionType

private final OptionMaster.Type optionType
See Also:
OptionMaster.Type

optionPlatform

private final OptionMaster.OptionPlatform optionPlatform
See Also:
OptionMaster.OptionPlatform

optionVisibility

private final OptionMaster.Visibility optionVisibility
See Also:
OptionMaster.Visibility
Constructor Detail

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 option
optionType - Type of data this option will represent.
optionPlatform - Platform(s) where this option is applicable.
optionVisibility - Visibility behavior of this option.
Method Detail

onValidPlatform

protected boolean onValidPlatform()
Determines if the option applies to the current platform.

Returns:
true if this option is applicable, false otherwise.

isValidPrefFormat

private boolean isValidPrefFormat(String text)
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

public OptionMaster.Type getOptionType()
Returns this option's type.

Specified by:
getOptionType in interface Option
Returns:
The option's type.
See Also:
OptionMaster.Type

getOptionPlatform

public OptionMaster.OptionPlatform getOptionPlatform()
Returns the platform(s) to which this option applies.

Specified by:
getOptionPlatform in interface Option
Returns:
The option's platform.
See Also:
OptionMaster.OptionPlatform

getOptionVisibility

public OptionMaster.Visibility getOptionVisibility()
Returns whether or not this option represents a visible UI element.

Specified by:
getOptionVisibility in interface Option
Returns:
The option's visibility.
See Also:
OptionMaster.Visibility

getOptionId

public String getOptionId()
Returns the ID used when referring to this option.

Specified by:
getOptionId in interface Option
Returns:
The option's ID.

getLabel

public String getLabel()
Returns a brief description of this option. Mostly useful for providing a GUI label.

Specified by:
getLabel in interface Option
Returns:
The option's label.

fromPrefsFormat

public void fromPrefsFormat(String text)
Initializes the current option using a relevant variable from the startup script.

Specified by:
fromPrefsFormat in interface Option
Parameters:
text - Line from the startup script that represents the current option.
Throws:
IllegalArgumentException - if text is not in the proper format for the current platform.

toPrefsFormat

public String toPrefsFormat()
Returns a string representation of the current option that is suitable for use in the startup script.

Specified by:
toPrefsFormat in interface Option
Returns:
Current value of this option as a startup script variable. The formatting changes slightly between "Unix-like" platforms and Windows.
See Also:
isValidPrefFormat(String)

getComponent

public abstract JComponent getComponent()
Returns the GUI component that represents the option. BooleanOptions are represented by a JCheckBox, while TextOptions appear as a JTextField.

Specified by:
getComponent in interface Option
Returns:
The GUI representation of this option.

getValue

public abstract String getValue()
Returns the value of the option. Note that BooleanOptions return either "0" or "1".

Specified by:
getValue in interface Option
Returns:
The current value of the option.

setValue

public abstract void setValue(String value)
Forces the value of the option to the data specified. Note that BooleanOptions accept either "0", or "1".

Specified by:
setValue in interface Option
Parameters:
value - New value to use.

toString

public abstract String toString()
Friendly string representation of the option.

Specified by:
toString in interface Option
Overrides:
toString in class Object
Returns:
String containing relevant info about the option.
See Also:
TextOption.toString(), BooleanOption.toString()