public final class FileOption extends AbstractOption
Modifier and Type | Field and Description |
---|---|
private javax.swing.JButton |
browseButton
Used to pop up a
JFileChooser . |
private static java.lang.String |
BUNDLE_DIR
Name of the "bundle" subdirectory of the user path.
|
static java.lang.String |
BUNDLE_FIELD_TIP
Tool tip used by
bundleField . |
private javax.swing.JTextField |
bundleField
Shows current default bundle.
|
private static java.lang.String |
BUTTON_LABEL
Label for
browseButton . |
private boolean |
checkbox
Current state of
enableCheckBox . |
private static java.lang.String |
CHECKBOX_LABEL
Label for
enableCheckBox . |
private static java.util.regex.Pattern |
CLEAN_VALUE_REGEX
Regular expression pattern for ensuring that no quote marks are present.
|
private java.lang.String |
defaultBundle
Default path for
bundleField . |
private boolean |
defaultCheckBox
Default state of
enableCheckBox . |
private java.lang.String |
defaultValue
Default option value.
|
private javax.swing.JCheckBox |
enableCheckBox
Whether or not the default bundle should be used.
|
private static java.lang.String |
FALSE_STRING
Constant that represents string version of the
0 boolean. |
private static java.lang.String |
FORMAT
Formatting string used by
toString() . |
private java.lang.String |
path
Current contents of
bundleField . |
private static java.lang.String |
TRUE_STRING
Constant that represents string version of the
1 boolean. |
private static java.lang.String |
USERPATH
System property that points to the McIDAS-V user path.
|
Constructor and Description |
---|
FileOption(java.lang.String id,
java.lang.String label,
java.lang.String defaultValue,
OptionMaster.OptionPlatform platform,
OptionMaster.Visibility visibility)
Create a new "file option" that allows the user to select
a file.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
booleanFromFormat(java.lang.String value)
Convert the strings
1 and 0 to their corresponding
boolean values. |
private void |
browseButtonActionPerformed(java.awt.event.ActionEvent event)
Handles the user clicking on the
browseButton . |
java.lang.String |
getBundlePath()
Returns a string representating the path to the startup bundle.
|
java.lang.String |
getCheckBoxValue()
Returns a string representation of
enableCheckBox . |
javax.swing.JComponent |
getComponent()
Returns the GUI component that represents the option.
|
java.lang.String |
getValue()
Returns a string containing the state of
enableCheckBox and
bundleField . |
static java.lang.String[] |
parseFormat(java.lang.String format)
Attempt to extract something sensible from the value given in
"runMcV-Prefs".
|
private java.lang.String |
selectBundle(java.lang.String bundleDirectory)
Show a
JFileChooser dialog that allows the user to select a
bundle. |
void |
setValue(java.lang.String newValue)
Forces the value of the option to the data specified.
|
java.lang.String |
toString()
Friendly string representation of the option.
|
fromPrefsFormat, getLabel, getOptionId, getOptionPlatform, getOptionType, getOptionVisibility, isValidPrefFormat, onValidPlatform, toPrefsFormat
private static final java.lang.String BUTTON_LABEL
browseButton
.private static final java.lang.String CHECKBOX_LABEL
enableCheckBox
.private static final java.lang.String USERPATH
private static final java.lang.String BUNDLE_DIR
private static final java.lang.String TRUE_STRING
1
boolean.private static final java.lang.String FALSE_STRING
0
boolean.private static final java.util.regex.Pattern CLEAN_VALUE_REGEX
private static final java.lang.String FORMAT
toString()
.public static final java.lang.String BUNDLE_FIELD_TIP
bundleField
.private final java.lang.String defaultValue
OptionMaster.blahblah
.private final boolean defaultCheckBox
enableCheckBox
.private final java.lang.String defaultBundle
bundleField
.private javax.swing.JTextField bundleField
null
!private javax.swing.JButton browseButton
JFileChooser
. May be null
!private javax.swing.JCheckBox enableCheckBox
null
!private boolean checkbox
enableCheckBox
.private java.lang.String path
bundleField
. Value may be null
!public FileOption(java.lang.String id, java.lang.String label, java.lang.String defaultValue, OptionMaster.OptionPlatform platform, OptionMaster.Visibility visibility)
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.private void browseButtonActionPerformed(java.awt.event.ActionEvent event)
browseButton
.event
- Currently ignored.private java.lang.String selectBundle(java.lang.String bundleDirectory)
JFileChooser
dialog that allows the user to select a
bundle.bundleDirectory
- Initial directory for the JFileChooser
.defaultValue
if the user cancelled.public javax.swing.JComponent getComponent()
getComponent
in interface Option
getComponent
in class AbstractOption
public java.lang.String getValue()
enableCheckBox
and
bundleField
.
Results should look like 0;/path/to/bundle.mcv
.
getValue
in interface Option
getValue
in class AbstractOption
public java.lang.String getCheckBoxValue()
enableCheckBox
.1
or 0
depending upon the state of
enableCheckBox
.public java.lang.String getBundlePath()
bundleField
is null
, defaultBundle
is returned. Otherwise the contents of the text field are returned.public void setValue(java.lang.String newValue)
setValue
in interface Option
setValue
in class AbstractOption
newValue
- New value to use.public java.lang.String toString()
toString
in interface Option
toString
in class AbstractOption
String
containing relevant info about the option.TextOption.toString()
,
BooleanOption.toString()
public static java.lang.String[] parseFormat(java.lang.String format)
Expected format is something like "0;/path/to/bundle.mcv"
or
"1;"
. The first example would signify that
enableCheckBox
is not selected, and the contents of
bundleField
are /path/to/bundle.mcv
. The second
example would signify that enableCheckBox
is selected, and the
contents of bundleField
should be an empty string.
format
- See method description for details. null
not
allowed.enableCheckBox
and the second is the bundle path. Note that
the bundle path may be empty.booleanFromFormat(String)
public static boolean booleanFromFormat(java.lang.String value)
1
and 0
to their corresponding
boolean values.value
- String to convert. null
or empty strings accepted.true
if value
is 1
. Otherwise
returns false
.