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 JButton
Used to pop up aJFileChooser
.private static final String
Name of the "bundle" subdirectory of the user path.static final String
Tool tip used bybundleField
.private JTextField
Shows current default bundle.private static final String
Label forbrowseButton
.private boolean
Current state ofenableCheckBox
.private static final String
Label forenableCheckBox
.private final String
Default path forbundleField
.private final boolean
Default state ofenableCheckBox
.private JCheckBox
Whether or not the default bundle should be used.private static final String
Constant that represents string version of the0
boolean.private String
Current contents ofbundleField
.private static final String
Used to ensure that no quote marks are present.private static final String
Constant that represents string version of the1
boolean.private static final String
System 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 boolean
booleanFromFormat
(String value) Convert the strings1
and0
to their corresponding boolean values.private void
Handles 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 ofenableCheckBox
andbundleField
.static String[]
parseFormat
(String format) Attempt to extract something sensible from the value given in "runMcV-Prefs".private String
selectBundle
(String bundleDirectory) Show aJFileChooser
dialog that allows the user to select a bundle.void
Forces 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 the1
boolean.- See Also:
-
FALSE_STRING
Constant that represents string version of the0
boolean.- 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 aJFileChooser
dialog 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
invalid reference
#defaultValue
-
getComponent
Returns the GUI component that represents the option.- Specified by:
getComponent
in interfaceOption
- Specified by:
getComponent
in classAbstractOption
- Returns:
- GUI representation of this option.
-
getValue
Returns a string containing the state ofenableCheckBox
andbundleField
.Results should look like
0;/path/to/bundle.mcv
.- Specified by:
getValue
in interfaceOption
- Specified by:
getValue
in classAbstractOption
- Returns:
- Current value of the option.
-
getCheckBoxValue
Returns a string representation ofenableCheckBox
.- Returns:
- Either
1
or0
depending upon the state ofenableCheckBox
.
-
getBundlePath
Returns a string representating the path to the startup bundle.- Returns:
- If
bundleField
isnull
,defaultBundle
is returned. Otherwise the contents of the text field are returned.
-
setValue
Forces the value of the option to the data specified.- Specified by:
setValue
in interfaceOption
- Specified by:
setValue
in classAbstractOption
- Parameters:
newValue
- New value to use.
-
toString
Friendly string representation of the option.- Specified by:
toString
in interfaceOption
- Specified by:
toString
in classAbstractOption
- Returns:
String
containing 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 thatenableCheckBox
is not selected, and the contents ofbundleField
are/path/to/bundle.mcv
. The second example would signify thatenableCheckBox
is selected, and the contents ofbundleField
should be an empty string.- Parameters:
format
- See method description for details.null
not allowed.- Returns:
- Two element array where the first element is the state of
enableCheckBox
and the second is the bundle path. Note that the bundle path may be empty. - See Also:
-
booleanFromFormat
Convert the strings1
and0
to their corresponding boolean values.- Parameters:
value
- String to convert.null
or empty strings accepted.- Returns:
- Returns
true
ifvalue
is1
. Otherwise returnsfalse
.
-