Package docking.widgets.values
Class GValuesMap
java.lang.Object
docking.widgets.values.GValuesMap
- Direct Known Subclasses:
GhidraValuesMap
Class for defining, storing, and retrieving groups of values of various types. The intended use
is to create a ValuesMap, define some named values, and then invoke the ValuesMapDialog to allow
the user to fill in values for the defined values. It also has a rich set of convenience methods
for adding predefined value types to the map. Users can also directly add custom value types by
using the
addValue(AbstractValue)
method.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddValue
(AbstractValue<?> value) Adds an AbstractValue to this ValuesMap.protected void
void
copyValues
(GValuesMap otherMap) Copies the values (not the AbstractValues objects, but the T values of each AbstractValue) from the given map into this map.defineBoolean
(String name, boolean defaultValue) Defines a value of type Boolean.defineChoice
(String name, String defaultValue, String... choices) Defines a value of type String, but with a restricted set of valid string values.defineDirectory
(String name, File defaultValue) Defines a value of type File, but is restricted to directories.defineDouble
(String name) Defines a value of type Double with no initial default value.defineDouble
(String name, double defaultValue) Defines a value of type Double with an initial valuedefineFile
(String name, File defaultValue) Defines a value of type FiledefineFile
(String name, File defaultValue, File startingDir) Defines a value of type FiledefineHexInt
(String name) Defines a value of type Integer that displays as a hex value.defineHexInt
(String name, int defaultValue) Defines a value of type Integer with an initial value and displays as a hex value.defineHexLong
(String name) Defines a value of type Long that displays as a hex value.defineHexLong
(String name, long defaultValue) Defines a value of type Long with an initial value and displays as a hex value.Defines a value of type Integer with no initial value.Defines a value of type Integer with an initial value.defineLong
(String name) Defines a value of type Long with an initial value.defineLong
(String name, long defaultValue) Defines a value of type Long with an initial value.defineString
(String name) Defines a value of type String.defineString
(String name, String defaultValue) Defines a value of type String with an optional initial valuegetAbstractValue
(String name) Returns the AbstractValue for the given value name.boolean
getBoolean
(String name) Gets the boolean value for the given name.Gets the Choice (String) value for the given name.double
Gets the double value for the given name.Gets theFile
value for the given name.int
Gets the int value for the given name.long
Gets the long value for the given name.Gets the String value for the given name.protected <T> T
Returns a collection of the AbstractValues defined in this ValuesMap.boolean
Returns true if the value defined for the given name has a non-null value.boolean
Returns true if there is a defined value for the given name.boolean
isValid
(StatusListener listener) The call to validate the data using theValuesMapValidator
set in thesetValidator(ValuesMapValidator)
method.protected void
reset()
Resets the values back to their original values when constructed.void
setBoolean
(String name, boolean value) Sets the boolean value for the given name.void
Sets the Choice (String) value for the given name.void
Sets the double value for the given name.void
Sets theFile
value for the given name.void
Sets the int value for the given name.void
Sets the long value for the given name.void
Sets the String value for the given name.void
setValidator
(ValuesMapValidator validator) Sets aValuesMapValidator
.void
Updates each value in this ValuesMap from its corresponding JComponent.
-
Field Details
-
valuesMap
-
-
Constructor Details
-
GValuesMap
public GValuesMap()
-
-
Method Details
-
getValues
Returns a collection of the AbstractValues defined in this ValuesMap.- Returns:
- a collection of the AbstractValues defined in this ValuesMap.
-
addValue
Adds an AbstractValue to this ValuesMap. This is a way to add a custom AbstractValue that doesn't have a convenience method for a predefine value type.- Parameters:
value
- the AbstractValue to add to this ValuesMap- Returns:
- returns the added value
-
setValidator
Sets aValuesMapValidator
. If set, this will be called when the user presses the "Ok" button on theValuesMapDialog
. If the validator passes (returns true), then the dialog will close and return the user values. Otherwise, the dialog will display the error message (via theStatusListener
in theValuesMapValidator.validate(GValuesMap, StatusListener)
call) and remain open.- Parameters:
validator
- the validator to be called before returning from the dialog
-
isValid
The call to validate the data using theValuesMapValidator
set in thesetValidator(ValuesMapValidator)
method. If no validator has been set, this method will return true.- Parameters:
listener
- TheStatusListener
for reporting an error message.- Returns:
- true if the validator passes or no validator has been set.
-
updateFromComponents
Updates each value in this ValuesMap from its corresponding JComponent.- Throws:
ValuesMapParseException
- if any value encountered an error trying to update its value from the editor component.
-
getAbstractValue
Returns the AbstractValue for the given value name.- Parameters:
name
- the name for which to get the AbstractValue- Returns:
- the AbstractValue for the given value name.
-
isDefined
Returns true if there is a defined value for the given name.- Parameters:
name
- the name of the value to check for- Returns:
- true if there is a defined value for the given name.
-
hasValue
Returns true if the value defined for the given name has a non-null value.- Parameters:
name
- the name of the value- Returns:
- true if the value defined for the given name has a non-null value.
-
copyValues
Copies the values (not the AbstractValues objects, but the T values of each AbstractValue) from the given map into this map. The given map must have exactly the same name and AbstractValue types as this map.- Parameters:
otherMap
- The GValuesMap to copy values from- Throws:
IllegalArgumentException
- if the given map does not have exactly the same set of names and types as this this map
-
defineBoolean
Defines a value of type Boolean.- Parameters:
name
- the name for this valuedefaultValue
- the default value for this boolean value.- Returns:
- the new BooleanValue that was defined.
-
defineChoice
Defines a value of type String, but with a restricted set of valid string values.- Parameters:
name
- the name for this value.defaultValue
- an optional (can be null) initial valuechoices
- varargs list of valid string choices- Returns:
- the new ChoiceValue that was defined
-
defineDirectory
Defines a value of type File, but is restricted to directories.- Parameters:
name
- the name for this valuedefaultValue
- an optional initial value- Returns:
- the new FileValue that was defined
-
defineDouble
Defines a value of type Double with no initial default value.- Parameters:
name
- the name for this value- Returns:
- the new DoubleValue that was defined
-
defineDouble
Defines a value of type Double with an initial value- Parameters:
name
- the name for this valuedefaultValue
- the initial value- Returns:
- the new DoubleValue that was defined
-
defineFile
Defines a value of type File- Parameters:
name
- the name for this valuedefaultValue
- an optional initial value- Returns:
- the new FileValue that was defined
-
defineFile
Defines a value of type File- Parameters:
name
- the name for this valuedefaultValue
- an optional initial valuestartingDir
- specifies the starting directory when the FileChooser is invoked- Returns:
- the new FileValue that was defined
-
defineHexInt
Defines a value of type Integer that displays as a hex value.- Parameters:
name
- the name for this value- Returns:
- the new IntValue that was defined
-
defineHexInt
Defines a value of type Integer with an initial value and displays as a hex value.- Parameters:
name
- the name for this valuedefaultValue
- the initial value- Returns:
- the new IntValue that was defined
-
defineHexLong
Defines a value of type Long that displays as a hex value.- Parameters:
name
- the name for this value- Returns:
- the new LongValue that was defined
-
defineHexLong
Defines a value of type Long with an initial value and displays as a hex value.- Parameters:
name
- the name for this valuedefaultValue
- the initial value- Returns:
- the new LongValue that was defined
-
defineInt
Defines a value of type Integer with no initial value.- Parameters:
name
- the name for this value- Returns:
- the new IntValue that was defined
-
defineInt
Defines a value of type Integer with an initial value.- Parameters:
name
- the name for this valuedefaultValue
- the initial value- Returns:
- the new IntValue that was defined
-
defineLong
Defines a value of type Long with an initial value.- Parameters:
name
- the name for this value- Returns:
- the new LongValue that was defined
-
defineLong
Defines a value of type Long with an initial value.- Parameters:
name
- the name for this valuedefaultValue
- the initial value- Returns:
- the new LongValue that was defined
-
defineString
Defines a value of type String.- Parameters:
name
- the name for this value- Returns:
- the new StringValue that was defined
-
defineString
Defines a value of type String with an optional initial value- Parameters:
name
- the name for this valuedefaultValue
- the initial value (can be null)- Returns:
- the new StringValue that was defined
-
getBoolean
Gets the boolean value for the given name.- Parameters:
name
- the name of a previously defined boolean value- Returns:
- the boolean value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a boolean type
-
getChoice
Gets the Choice (String) value for the given name. The value will be either null or one of the strings that were defined as valid choices.- Parameters:
name
- the name of a previously defined Choice value- Returns:
- the Choice value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a Choice type
-
getDouble
Gets the double value for the given name.- Parameters:
name
- the name of a previously defined double value- Returns:
- the double value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a double type
-
getFile
Gets theFile
value for the given name.- Parameters:
name
- the name of a previously defined File value- Returns:
- the File value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a File type
-
getInt
Gets the int value for the given name.- Parameters:
name
- the name of a previously defined int value- Returns:
- the int value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a int type
-
getLong
Gets the long value for the given name.- Parameters:
name
- the name of a previously defined long value- Returns:
- the long value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a long type
-
getString
Gets the String value for the given name.- Parameters:
name
- the name of a previously defined String value- Returns:
- the String value
- Throws:
IllegalArgumentException
- if the name hasn't been defined as a String type
-
setBoolean
Sets the boolean value for the given name.- Parameters:
name
- the name of the boolean value that was previously definedvalue
- the boolean to set as the value- Throws:
IllegalArgumentException
- if the name hasn't been defined as a boolean type
-
setChoice
Sets the Choice (String) value for the given name.- Parameters:
name
- the name of the Choice value that was previously definedchoice
- the string to set as the value. This String must be one of the defined choices- Throws:
IllegalArgumentException
- if the name hasn't been defined as a choice type
-
setDouble
Sets the double value for the given name.- Parameters:
name
- the name of the double value that was previously definedvalue
- the double to set as the value- Throws:
IllegalArgumentException
- if the name hasn't been defined as a double type
-
setFile
Sets theFile
value for the given name.- Parameters:
name
- the name of the File value that was previously definedvalue
- the File to set as the value- Throws:
IllegalArgumentException
- if the name hasn't been defined as a File type
-
setInt
Sets the int value for the given name.- Parameters:
name
- the name of the int value that was previously definedvalue
- the int to set as the value- Throws:
IllegalArgumentException
- if the name hasn't been defined as a int type
-
setLong
Sets the long value for the given name.- Parameters:
name
- the name of the long value that was previously definedvalue
- the long to set as the value- Throws:
IllegalArgumentException
- if the name hasn't been defined as a long type
-
setString
Sets the String value for the given name.- Parameters:
name
- the name of the String value that was previously definedvalue
- the String to set as the value- Throws:
IllegalArgumentException
- if the name hasn't been defined as a String type
-
getValue
-
checkDup
-
reset
protected void reset()Resets the values back to their original values when constructed. Used by the dialog when the user cancels.
-