Class FileOption
java.lang.Object
edu.wisc.ssec.mcidasv.startupmanager.options.AbstractOption
edu.wisc.ssec.mcidasv.startupmanager.options.FileOption
- All Implemented Interfaces:
Option
Represents a file selection.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate JButtonUsed to pop up aJFileChooser.private static final StringName of the "bundle" subdirectory of the user path.static final StringTool tip used bybundleField.private JTextFieldShows current default bundle.private static final StringLabel forbrowseButton.private booleanCurrent state ofenableCheckBox.private static final StringLabel forenableCheckBox.private final StringDefault path forbundleField.private final booleanDefault state ofenableCheckBox.private JCheckBoxWhether or not the default bundle should be used.private static final StringConstant that represents string version of the0boolean.private StringCurrent contents ofbundleField.private static final StringUsed to ensure that no quote marks are present.private static final StringConstant that represents string version of the1boolean.private static final StringSystem property that points to the McIDAS-V user path. -
Constructor Summary
ConstructorsConstructorDescriptionFileOption(String id, String label, String defaultValue, OptionMaster.OptionPlatform platform, OptionMaster.Visibility visibility) Create a new "file option" that allows the user to select a file. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanbooleanFromFormat(String value) Convert the strings1and0to their corresponding boolean values.private voidHandles the user clicking on thebrowseButton.Returns a string representating the path to the startup bundle.Returns a string representation ofenableCheckBox.Returns the GUI component that represents the option.getValue()Returns a string containing the state ofenableCheckBoxandbundleField.static String[]parseFormat(String format) Attempt to extract something sensible from the value given in "runMcV-Prefs".private StringselectBundle(String bundleDirectory) Show aJFileChooserdialog that allows the user to select a bundle.voidForces the value of the option to the data specified.toString()Friendly string representation of the option.Methods inherited from class edu.wisc.ssec.mcidasv.startupmanager.options.AbstractOption
fromPrefsFormat, getLabel, getOptionId, getOptionPlatform, getOptionType, getOptionVisibility, isValidPrefFormat, onValidPlatform, toPrefsFormat
-
Field Details
-
BUTTON_LABEL
Label forbrowseButton.- See Also:
-
CHECKBOX_LABEL
Label forenableCheckBox.- See Also:
-
USERPATH
System property that points to the McIDAS-V user path.- See Also:
-
BUNDLE_DIR
Name of the "bundle" subdirectory of the user path.- See Also:
-
TRUE_STRING
Constant that represents string version of the1boolean.- See Also:
-
FALSE_STRING
Constant that represents string version of the0boolean.- See Also:
-
QUOTE
Used to ensure that no quote marks are present.- See Also:
-
BUNDLE_FIELD_TIP
Tool tip used bybundleField.- See Also:
-
defaultCheckBox
Default state ofenableCheckBox. -
defaultBundle
Default path forbundleField. -
bundleField
Shows current default bundle. Empty means there isn't one. May benull! -
browseButton
Used to pop up aJFileChooser. May benull! -
enableCheckBox
Whether or not the default bundle should be used. May benull! -
checkbox
Current state ofenableCheckBox. -
path
Current contents ofbundleField. Value may benull!
-
-
Constructor Details
-
FileOption
public FileOption(String id, String label, String defaultValue, OptionMaster.OptionPlatform platform, OptionMaster.Visibility visibility) Create a new "file option" that allows the user to select a file.- Parameters:
id- Option ID.label- Option label (used in GUI).defaultValue- Default option value.platform- Platform restrictions for the option.visibility- Visibility restrictions for the option.
-
-
Method Details
-
browseButtonActionPerformed
Handles the user clicking on thebrowseButton.- Parameters:
event- Currently ignored.
-
selectBundle
Show aJFileChooserdialog that allows the user to select a bundle.- Parameters:
bundleDirectory- Initial directory for theJFileChooser.- Returns:
- Either the path to the user's chosen bundle, or
if the user cancelled.
invalid reference
#defaultValue
-
getComponent
Returns the GUI component that represents the option.- Specified by:
getComponentin interfaceOption- Specified by:
getComponentin classAbstractOption- Returns:
- GUI representation of this option.
-
getValue
Returns a string containing the state ofenableCheckBoxandbundleField.Results should look like
0;/path/to/bundle.mcv.- Specified by:
getValuein interfaceOption- Specified by:
getValuein classAbstractOption- Returns:
- Current value of the option.
-
getCheckBoxValue
Returns a string representation ofenableCheckBox.- Returns:
- Either
1or0depending upon the state ofenableCheckBox.
-
getBundlePath
Returns a string representating the path to the startup bundle.- Returns:
- If
bundleFieldisnull,defaultBundleis returned. Otherwise the contents of the text field are returned.
-
setValue
Forces the value of the option to the data specified.- Specified by:
setValuein interfaceOption- Specified by:
setValuein classAbstractOption- Parameters:
newValue- New value to use.
-
toString
Friendly string representation of the option.- Specified by:
toStringin interfaceOption- Specified by:
toStringin classAbstractOption- Returns:
Stringcontaining relevant info about the option.- See Also:
-
parseFormat
Attempt to extract something sensible from the value given in "runMcV-Prefs".Expected format is something like
"0;/path/to/bundle.mcv"or"1;". The first example would signify thatenableCheckBoxis not selected, and the contents ofbundleFieldare/path/to/bundle.mcv. The second example would signify thatenableCheckBoxis selected, and the contents ofbundleFieldshould be an empty string.- Parameters:
format- See method description for details.nullnot allowed.- Returns:
- Two element array where the first element is the state of
enableCheckBoxand the second is the bundle path. Note that the bundle path may be empty. - See Also:
-
booleanFromFormat
Convert the strings1and0to their corresponding boolean values.- Parameters:
value- String to convert.nullor empty strings accepted.- Returns:
- Returns
trueifvalueis1. Otherwise returnsfalse.
-