Class AbstractOptions
- All Implemented Interfaces:
Options
- Direct Known Subclasses:
FileOptions
,ToolOptions
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected Map
<String, AbstractOptions.AliasBinding> protected Map
<String, HelpLocation> protected WeakSet
<OptionsChangeListener> protected String
protected Map
<String, OptionsEditor> protected ThemeListener
Fields inherited from interface ghidra.framework.options.Options
DELIMITER, DELIMITER_STRING, ILLEGAL_DELIMITER
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if a option exists with the given name.void
createAlias
(String aliasName, Options options, String optionsName) Create an alias in this options for an existing option in some other options object.protected abstract Option
createRegisteredOption
(String optionName, OptionType type, String description, HelpLocation help, Object defaultValue, PropertyEditor editor) protected abstract Option
createUnregisteredOption
(String optionName, OptionType type, Object defaultValue) void
dispose()
static PropertyEditor
findPropertyEditor
(Class<?> originalValueClass) getActionTrigger
(String optionName, ActionTrigger defaultValue) Get theActionTrigger
for the given full action name.boolean
getBoolean
(String optionName, boolean defaultValue) Get the boolean value for the given option name.byte[]
getByteArray
(String optionName, byte[] defaultValue) Get the byte array for the given option name.getCategoryHelpLocation
(String categoryPath) Returns a list of Options objects that are nested one level down from this Options object.Get the Color for the given option name.getCustomOption
(String optionName, CustomOption defaultValue) Get the custom option value for the given option name.Get the Date for the given option name.getDefaultValue
(String optionName) Returns the default value for the given option.getDefaultValueAsString
(String optionName) Returns the default value as a string for the given option.getDescription
(String optionName) Get the description for the given option name.double
Get the double value for the given option name.<T extends Enum<T>>
TGet the Enum value for the given option name.Get the File for the given option name.float
Get the float value for the given option name.Get the Font for the given option name.getHelpLocation
(String optionName) Get the location for where help can be found for the option with the given name.Returns a unique id for option in this options with the given name.int
Get the int value for the given option name.getKeyStroke
(String optionName, KeyStroke defaultValue) Get the KeyStroke for the given action name.Returns a list of option names that immediately fall under this options.long
Get the long value for the given option name.getName()
Get the name of this options object.Get the object value; called when the options dialog is being populated.getOption
(String optionName, OptionType type, Object defaultValue) Get the list of option names.getOptions
(String path) Returns a Options object that is a sub-options of this options.Get the editor that will handle editing all the values in this options or sub group of options.getOptionsEditor
(String categoryPath) Returns the HelpLocation for this entire Options object.getPropertyEditor
(String optionName) Get the property editor for the option with the given name.getRegisteredPropertyEditor
(String optionName) Get the property editor that was registered for the specific option with the given name.Get the string value for the given option name.Returns the OptionType of the given option.getValueAsString
(String optionName) Returns the value as a string for the given option.boolean
Returnsboolean
isDefaultValue
(String optionName) Returns true if the option with the given name's current value is the default value.boolean
isRegistered
(String optionName) Returns true if the specified option has been registered.protected abstract boolean
notifyOptionChanged
(String optionName, Object oldValue, Object newValue) void
Put the object value.void
putObject
(String optionName, Object newValue, OptionType type) void
registerOption
(String optionName, OptionType type, Object defaultValue, HelpLocation help, String description) Registers an option with a description, help location, and a optional default value.void
registerOption
(String optionName, OptionType type, Object defaultValue, HelpLocation help, String description, Supplier<PropertyEditor> editorSupplier) Registers an option with a description, help location, and a optional default value.void
registerOption
(String optionName, Object defaultValue, HelpLocation help, String description) Registers an option with a description, help location, and a default value without specifying the option type.void
registerOptionsEditor
(String categoryPath, Supplier<OptionsEditor> editorSupplier) void
registerOptionsEditor
(Supplier<OptionsEditor> editor) Register the options editor that will handle the editing for all the options or a sub-group of options.void
registerThemeColorBinding
(String optionName, String colorId, HelpLocation help, String description) Register/binds the option to a theme color id.void
registerThemeFontBinding
(String optionName, String fontId, HelpLocation help, String description) Register/binds the option to a theme font id.void
removeOption
(String optionName) Remove the option name.void
restoreDefaultValue
(String optionName) Restores the option denoted by the given name to its default value.void
Restores all options contained herein to their default values.void
setActionTrigger
(String optionName, ActionTrigger value) Sets the action trigger value for the optionvoid
setBoolean
(String optionName, boolean value) Sets the boolean value for the option.void
setByteArray
(String optionName, byte[] value) Sets the byte[] value for the given option name.void
setCategoryHelpLocation
(String categoryPath, HelpLocation helpLocation) void
Sets the Color value for the optionvoid
setCustomOption
(String optionName, CustomOption value) Sets the Custom option value for the option.void
Sets the Date value for the option.void
Sets the double value for the option.<T extends Enum<T>>
voidSet the Enum value for the option.void
Sets the File value for the option.void
Sets the float value for the option.void
Sets the Font value for the optionvoid
Sets the int value for the option.void
setKeyStroke
(String optionName, KeyStroke value) Sets the KeyStroke value for the optionvoid
Sets the long value for the option.void
Sets the name for this Options object.void
setOptionsHelpLocation
(HelpLocation helpLocation) Set the location for where help can be found for this entire options object.void
Set the String value for the option.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface ghidra.framework.options.Options
registerOption, registerOptionsEditor
-
Field Details
-
SUPPORTED_CLASSES
-
name
-
valueMap
-
listeners
-
optionsEditorMap
-
categoryHelpMap
-
aliasMap
-
themeListener
-
themeToOptionMap
-
-
Constructor Details
-
AbstractOptions
-
-
Method Details
-
createRegisteredOption
protected abstract Option createRegisteredOption(String optionName, OptionType type, String description, HelpLocation help, Object defaultValue, PropertyEditor editor) -
createUnregisteredOption
protected abstract Option createUnregisteredOption(String optionName, OptionType type, Object defaultValue) -
notifyOptionChanged
-
registerOptionsEditor
-
getOptionsEditor
-
dispose
public void dispose() -
getName
Description copied from interface:Options
Get the name of this options object. -
setName
Sets the name for this Options object. Used when updating old options names to new names.- Parameters:
newName
- the new name for this options object.
-
registerOption
public void registerOption(String optionName, Object defaultValue, HelpLocation help, String description) Description copied from interface:Options
Registers an option with a description, help location, and a default value without specifying the option type. This form requires that the default value not be null so that the option type can be inferred from the default value.Note, this method should not be used for colors and font as doing so will result in those colors and fonts becoming disconnected to the current theme. Instead use
Options.registerThemeColorBinding(String, String, HelpLocation, String)
orOptions.registerThemeFontBinding(String, String, HelpLocation, String)
.- Specified by:
registerOption
in interfaceOptions
- Parameters:
optionName
- the name of the option being registered.defaultValue
- the defaultValue for the option. The default value must not be null so that the OptionType can be determined. If the default value should be null, useOptions.registerOption(String, OptionType, Object, HelpLocation, String)
help
- the HelpLocation for this option.description
- a description of the option.
-
registerOption
public void registerOption(String optionName, OptionType type, Object defaultValue, HelpLocation help, String description) Description copied from interface:Options
Registers an option with a description, help location, and a optional default value. With an optional default value, an OptionType must be passed as it is otherwise derived from the default value.Note, this method should not be used for colors and font as doing so will result in those colors and fonts becoming disconnected to the current theme. Instead use
Options.registerThemeColorBinding(String, String, HelpLocation, String)
orOptions.registerThemeFontBinding(String, String, HelpLocation, String)
.- Specified by:
registerOption
in interfaceOptions
- Parameters:
optionName
- the name of the option being registered.type
- the OptionType for this options.defaultValue
- the defaultValue for the option. In this version of the method, the default value may be null.help
- the HelpLocation for this option.description
- a description of the option.
-
registerOption
public void registerOption(String optionName, OptionType type, Object defaultValue, HelpLocation help, String description, Supplier<PropertyEditor> editorSupplier) Description copied from interface:Options
Registers an option with a description, help location, and a optional default value. With an optional default value, an OptionType must be passed as it is otherwise derived from the default value.Note, this method should not be used for colors and font as doing so will result in those colors and fonts becoming disconnected to the current theme. Instead use
Options.registerThemeColorBinding(String, String, HelpLocation, String)
orOptions.registerThemeFontBinding(String, String, HelpLocation, String)
.Note: we use a supplier of a custom editor, instead of a custom editor, to avoid creating
PropertyEditor
s until needed. This allows us to use the same API in both GUI mode and headless mode. If GUI property editors are created in headless mode, exceptions may be thrown. This API will not use the supplier when in headless mode, this avoiding the creation of GUI components. For this to work correctly, clients using custom property editors must defer construction of the editor until the supplier is called.- Specified by:
registerOption
in interfaceOptions
- Parameters:
optionName
- the name of the option being registered.type
- the OptionType for this options.defaultValue
- the defaultValue for the option. In this version of the method, the default value may be null.help
- the HelpLocation for this option.description
- a description of the option.editorSupplier
- an optional supplier of a custom editor for this property. Note if the option is a custom option, then the property editor can't be null;
-
registerThemeColorBinding
public void registerThemeColorBinding(String optionName, String colorId, HelpLocation help, String description) Description copied from interface:Options
Register/binds the option to a theme color id. Changing the option's color via the options Gui will result in directly changing the theme color of the given color id.- Specified by:
registerThemeColorBinding
in interfaceOptions
- Parameters:
optionName
- the name of the color optioncolorId
- the theme color id whose color value is changed when the option's color is changedhelp
- the HelpLocation for this optiondescription
- a description of the option
-
registerThemeFontBinding
public void registerThemeFontBinding(String optionName, String fontId, HelpLocation help, String description) Description copied from interface:Options
Register/binds the option to a theme font id. Changing the option's font via the options Gui will result in directly changing the theme color of the given font id.- Specified by:
registerThemeFontBinding
in interfaceOptions
- Parameters:
optionName
- the name of the font optionfontId
- the theme color id whose color value is changed when the option's color is changedhelp
- the HelpLocation for this optiondescription
- a description of the option
-
removeOption
Description copied from interface:Options
Remove the option name.- Specified by:
removeOption
in interfaceOptions
- Parameters:
optionName
- name of option to remove
-
getOptionNames
Description copied from interface:Options
Get the list of option names. This method will return the names (paths) of all options contained in this options object or below. For example, if the options has ("aaa", "bbb", "ccc.ddd"), all three will be returned. theOptions.getLeafOptionNames()
method will return only the "aaa" and "bbb" names.- Specified by:
getOptionNames
in interfaceOptions
- Returns:
- the list of all option names(paths) under this options.
-
getObject
Description copied from interface:Options
Get the object value; called when the options dialog is being populated. -
getOption
-
putObject
Description copied from interface:Options
Put the object value. If the option exists, the type must match the type of the existing object. -
putObject
-
getType
Description copied from interface:Options
Returns the OptionType of the given option. -
getBoolean
Description copied from interface:Options
Get the boolean value for the given option name.- Specified by:
getBoolean
in interfaceOptions
- Parameters:
optionName
- option namedefaultValue
- value that is stored and returned if there is no option with the given name.- Returns:
- boolean option value
-
getByteArray
Description copied from interface:Options
Get the byte array for the given option name.- Specified by:
getByteArray
in interfaceOptions
- Parameters:
optionName
- option namedefaultValue
- value that is stored and returned if there is no option with the given name- Returns:
- byte[] byte array value
-
getInt
Description copied from interface:Options
Get the int value for the given option name. -
getDouble
Description copied from interface:Options
Get the double value for the given option name. -
getFloat
Description copied from interface:Options
Get the float value for the given option name. -
getLong
Description copied from interface:Options
Get the long value for the given option name. -
getCustomOption
Description copied from interface:Options
Get the custom option value for the given option name.- Specified by:
getCustomOption
in interfaceOptions
- Parameters:
optionName
- option namedefaultValue
- value that is stored and returned if there is no option with the given name- Returns:
- WrappedOption value for the option
-
getColor
Description copied from interface:Options
Get the Color for the given option name. -
getFile
Description copied from interface:Options
Get the File for the given option name. -
getFont
Description copied from interface:Options
Get the Font for the given option name. -
getDate
Description copied from interface:Options
Get the Date for the given option name. -
getKeyStroke
Description copied from interface:Options
Get the KeyStroke for the given action name.- Specified by:
getKeyStroke
in interfaceOptions
- Parameters:
optionName
- the option namedefaultValue
- value that is stored and returned if there is no option with the given name- Returns:
- KeyStroke option
-
getActionTrigger
Description copied from interface:Options
Get theActionTrigger
for the given full action name.- Specified by:
getActionTrigger
in interfaceOptions
- Parameters:
optionName
- the action namedefaultValue
- value that is stored and returned if there is no option with the given name- Returns:
- the action trigger
-
getString
Description copied from interface:Options
Get the string value for the given option name. -
getEnum
Description copied from interface:Options
Get the Enum value for the given option name. -
setLong
Description copied from interface:Options
Sets the long value for the option. -
setBoolean
Description copied from interface:Options
Sets the boolean value for the option.- Specified by:
setBoolean
in interfaceOptions
- Parameters:
optionName
- name of the optionvalue
- value of the option
-
setInt
Description copied from interface:Options
Sets the int value for the option. -
setDouble
Description copied from interface:Options
Sets the double value for the option. -
setFloat
Description copied from interface:Options
Sets the float value for the option. -
setCustomOption
Description copied from interface:Options
Sets the Custom option value for the option.- Specified by:
setCustomOption
in interfaceOptions
- Parameters:
optionName
- name of the optionvalue
- the value
-
setByteArray
Description copied from interface:Options
Sets the byte[] value for the given option name.- Specified by:
setByteArray
in interfaceOptions
- Parameters:
optionName
- the name of the option on which to save bytes.value
- the value
-
setFile
Description copied from interface:Options
Sets the File value for the option. -
setColor
Description copied from interface:Options
Sets the Color value for the option -
setFont
Description copied from interface:Options
Sets the Font value for the option -
setDate
Description copied from interface:Options
Sets the Date value for the option. -
setKeyStroke
Description copied from interface:Options
Sets the KeyStroke value for the option- Specified by:
setKeyStroke
in interfaceOptions
- Parameters:
optionName
- name of the optionvalue
- KeyStroke to set
-
setActionTrigger
Description copied from interface:Options
Sets the action trigger value for the option- Specified by:
setActionTrigger
in interfaceOptions
- Parameters:
optionName
- name of the optionvalue
- action trigger to set
-
setString
Description copied from interface:Options
Set the String value for the option. -
setEnum
Description copied from interface:Options
Set the Enum value for the option. -
getDefaultValue
Description copied from interface:Options
Returns the default value for the given option.- Specified by:
getDefaultValue
in interfaceOptions
- Parameters:
optionName
- the name of the option for which to retrieve the default value.- Returns:
- the default value for the given option.
-
getPropertyEditor
Description copied from interface:Options
Get the property editor for the option with the given name. Note: This method must be called from the swing thread.- Specified by:
getPropertyEditor
in interfaceOptions
- Parameters:
optionName
- the option name- Returns:
- either the PropertyEditor that was registered for this option or a default editor for the property type if one can be found; otherwise null.
-
getRegisteredPropertyEditor
Description copied from interface:Options
Get the property editor that was registered for the specific option with the given name. Unlike the getPropertyEditor() method, this method does not have to be called from the swing thread- Specified by:
getRegisteredPropertyEditor
in interfaceOptions
- Parameters:
optionName
- the option name- Returns:
- the PropertyEditor that was registered for this option.
-
contains
Description copied from interface:Options
Return true if a option exists with the given name. -
getDescription
Description copied from interface:Options
Get the description for the given option name.- Specified by:
getDescription
in interfaceOptions
- Parameters:
optionName
- name of the option- Returns:
- null if the description or option name does not exist
-
getHelpLocation
Description copied from interface:Options
Get the location for where help can be found for the option with the given name.- Specified by:
getHelpLocation
in interfaceOptions
- Parameters:
optionName
- name of the option- Returns:
- null if the help location was not set on the option
-
isRegistered
Description copied from interface:Options
Returns true if the specified option has been registered. Only registered names are saved.- Specified by:
isRegistered
in interfaceOptions
- Parameters:
optionName
- the option name- Returns:
- true if registered
-
isDefaultValue
Description copied from interface:Options
Returns true if the option with the given name's current value is the default value.- Specified by:
isDefaultValue
in interfaceOptions
- Parameters:
optionName
- the name of the option.- Returns:
- true if the options has its current value equal to its default value.
-
restoreDefaultValues
public void restoreDefaultValues()Description copied from interface:Options
Restores all options contained herein to their default values.- Specified by:
restoreDefaultValues
in interfaceOptions
- See Also:
-
restoreDefaultValue
Description copied from interface:Options
Restores the option denoted by the given name to its default value.- Specified by:
restoreDefaultValue
in interfaceOptions
- Parameters:
optionName
- The name of the option to restore- See Also:
-
getChildOptions
Description copied from interface:Options
Returns a list of Options objects that are nested one level down from this Options object.- Specified by:
getChildOptions
in interfaceOptions
- Returns:
- a list of Options objects that are nested one level down from this Options object.
-
getOptions
Description copied from interface:Options
Returns a Options object that is a sub-options of this options.Note: the option path can have
Options.DELIMITER
characters which will be used to create a hierarchy with each element in the path resulting in sub-option of the previous path element.- Specified by:
getOptions
in interfaceOptions
- Parameters:
path
- the path for the sub-options object- Returns:
- an Options object that is a sub-options of this options
-
setOptionsHelpLocation
Description copied from interface:Options
Set the location for where help can be found for this entire options object.- Specified by:
setOptionsHelpLocation
in interfaceOptions
- Parameters:
helpLocation
- location for help on the option
-
getOptionsHelpLocation
Description copied from interface:Options
Returns the HelpLocation for this entire Options object.- Specified by:
getOptionsHelpLocation
in interfaceOptions
- Returns:
- the HelpLocation for this entire Options object.
-
registerOptionsEditor
Description copied from interface:Options
Register the options editor that will handle the editing for all the options or a sub-group of options.Note: we use a supplier of a custom editor, instead of a custom editor, to avoid creating
PropertyEditor
s until needed. This allows us to use the same API in both GUI mode and headless mode. If GUI property editors are created in headless mode, exceptions may be thrown. This API will not use the supplier when in headless mode, this avoiding the creation of GUI components. For this to work correctly, clients using custom property editors must defer construction of the editor until the supplier is called.- Specified by:
registerOptionsEditor
in interfaceOptions
- Parameters:
editor
- a supplier for the custom editor panel to be used to edit the options or sub-group of options.
-
getOptionsEditor
Description copied from interface:Options
Get the editor that will handle editing all the values in this options or sub group of options.- Specified by:
getOptionsEditor
in interfaceOptions
- Returns:
- null if no options editor was registered
-
createAlias
Description copied from interface:Options
Create an alias in this options for an existing option in some other options object.- Specified by:
createAlias
in interfaceOptions
- Parameters:
aliasName
- the name within this options object that will actually refer to some other options object.options
- the options object that has the actual option.optionsName
- the name within the given options object of the actual option.
-
isAlias
Description copied from interface:Options
Returns -
setCategoryHelpLocation
-
getCategoryHelpLocation
-
getID
Description copied from interface:Options
Returns a unique id for option in this options with the given name. This will be the full path name to the root options object. -
getValueAsString
Description copied from interface:Options
Returns the value as a string for the given option.- Specified by:
getValueAsString
in interfaceOptions
- Parameters:
optionName
- the name of the option for which to retrieve the value as a string- Returns:
- the value as a string for the given option.
-
getDefaultValueAsString
Description copied from interface:Options
Returns the default value as a string for the given option.- Specified by:
getDefaultValueAsString
in interfaceOptions
- Parameters:
optionName
- the name of the option for which to retrieve the default value as a string- Returns:
- the default value as a string for the given option.
-
toString
-
getLeafOptionNames
Description copied from interface:Options
Returns a list of option names that immediately fall under this options. For example, if this options object had the following options named ("a", "b", "c.d"), only "a" and "b" would be returned. The "c.d" leaf option name could be returned by getOptions("c").getLeafOptionNames()- Specified by:
getLeafOptionNames
in interfaceOptions
- Returns:
- the list of the names of the options that are immediate children of this options object.
-
findPropertyEditor
-