Package ghidra.app.util.viewer.format
Class FormatManager
- java.lang.Object
-
- ghidra.app.util.viewer.format.FormatManager
-
- All Implemented Interfaces:
OptionsChangeListener
public class FormatManager extends java.lang.Object implements OptionsChangeListener
Class to manage the set of format models.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ARRAY_DISPLAY_DESCRIPTION
static java.lang.String
ARRAY_DISPLAY_OPTIONS
static java.lang.String
ARRAY_OPTIONS_GROUP
static java.lang.String
HIGHLIGHT_ALT_COLOR_NAME
static java.lang.String
HIGHLIGHT_COLOR_NAME
-
Constructor Summary
Constructors Constructor Description FormatManager(ToolOptions displayOptions, ToolOptions fieldOptions)
Constructs a new FormatManager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFormatModelListener(FormatModelListener listener)
Adds a listener to be notified when a format changes.void
addHighlightProvider(HighlightProvider provider)
Adds a HighlightProviderFormatManager
createClone()
void
dispose()
FieldFormatModel
getCodeUnitFormat()
Returns the format model for a code unit.ToolOptions
getDisplayOptions()
Returns the Options used for display properties.FieldFormatModel
getDividerModel()
Returns the format model for the address break (divider)ToolOptions
getFieldOptions()
Returns the Options used for field specific properties.HighlightProvider
getFormatHighlightProvider()
Returns theHighlightProvider
that should be used when creatingFieldFactory
objects.FieldFormatModel
getFunctionFormat()
Returns the format model for the function signatureFieldFormatModel
getFunctionVarFormat()
Returns the format model for the function variables.java.util.List<HighlightProvider>
getHighlightProviders()
Gets allHighlightProvider
s installed on this FormatManager via theaddHighlightProvider(HighlightProvider)
.int
getMaxNumRows()
Returns the maximum number of possible rows in a layout.int
getMaxRowCount()
int
getMaxWidth()
Returns the width of the widest model in this manager.FieldFormatModel
getModel(int index)
Returns the format model for the given index.int
getNumModels()
Returns the total number of model in the format manager.FieldFormatModel
getOpenDataFormat(Data data)
Returns the format model to use for the internals of open structures.FieldFormatModel
getPlateFormat()
Returns the format model for the plate fieldServiceProvider
getServiceProvider()
void
modelChanged(FieldFormatModel model)
Notifies listeners that the given model has changed.void
optionsChanged(ToolOptions options, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Notification that an option changed.void
readState(SaveState saveState)
Restores the state of this LayoutController from the given SaveState object.void
removeFormatModleListener(FormatModelListener listener)
Removes the given listener from the list of listeners to be notified of a format change.void
removeHighlightProvider(HighlightProvider provider)
Removes the providervoid
saveState(SaveState saveState)
Saves the state of this LayoutManager to the SaveState object.void
setDefaultFormat(int modelID)
Resets the model with the given id to its default format.void
setDefaultFormats()
Resets all format models to their default format.void
setServiceProvider(ServiceProvider provider)
Sets the service provider used by the field factory objects.void
update()
update all listeners that a model has changed.
-
-
-
Field Detail
-
ARRAY_OPTIONS_GROUP
public static final java.lang.String ARRAY_OPTIONS_GROUP
- See Also:
- Constant Field Values
-
HIGHLIGHT_COLOR_NAME
public static final java.lang.String HIGHLIGHT_COLOR_NAME
- See Also:
- Constant Field Values
-
HIGHLIGHT_ALT_COLOR_NAME
public static final java.lang.String HIGHLIGHT_ALT_COLOR_NAME
- See Also:
- Constant Field Values
-
ARRAY_DISPLAY_OPTIONS
public static final java.lang.String ARRAY_DISPLAY_OPTIONS
- See Also:
- Constant Field Values
-
ARRAY_DISPLAY_DESCRIPTION
public static final java.lang.String ARRAY_DISPLAY_DESCRIPTION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FormatManager
public FormatManager(ToolOptions displayOptions, ToolOptions fieldOptions)
Constructs a new FormatManager.- Parameters:
displayOptions
- the Options containing display options (color, fonts, etc)fieldOptions
- the Options contains specific field options.
-
-
Method Detail
-
createClone
public FormatManager createClone()
-
dispose
public void dispose()
-
setServiceProvider
public void setServiceProvider(ServiceProvider provider)
Sets the service provider used by the field factory objects.- Parameters:
provider
- the service provider
-
addFormatModelListener
public void addFormatModelListener(FormatModelListener listener)
Adds a listener to be notified when a format changes.- Parameters:
listener
- the listener to be added.
-
removeFormatModleListener
public void removeFormatModleListener(FormatModelListener listener)
Removes the given listener from the list of listeners to be notified of a format change.- Parameters:
listener
- the listener to be removed.
-
getNumModels
public int getNumModels()
Returns the total number of model in the format manager.
-
getModel
public FieldFormatModel getModel(int index)
Returns the format model for the given index.- Parameters:
inde
- the index of the format model to return.
-
getDividerModel
public FieldFormatModel getDividerModel()
Returns the format model for the address break (divider)
-
getPlateFormat
public FieldFormatModel getPlateFormat()
Returns the format model for the plate field
-
getFunctionFormat
public FieldFormatModel getFunctionFormat()
Returns the format model for the function signature
-
getFunctionVarFormat
public FieldFormatModel getFunctionVarFormat()
Returns the format model for the function variables.
-
getCodeUnitFormat
public FieldFormatModel getCodeUnitFormat()
Returns the format model for a code unit.- Parameters:
cu
- the code unit for which to get a model. The cu is used in case there is a custom format for it.useCustomFormats
- if true seaches for a custom format for the code unit, otherwise always returns the basic instruction/data format model.
-
getOpenDataFormat
public FieldFormatModel getOpenDataFormat(Data data)
Returns the format model to use for the internals of open structures.- Parameters:
data
- the data code unit to get the format model for.useCustomFormats
- if true, tries to find a custom format model, otherwise always uses the default open data model.
-
update
public void update()
update all listeners that a model has changed.
-
getDisplayOptions
public ToolOptions getDisplayOptions()
Returns the Options used for display properties.
-
getFieldOptions
public ToolOptions getFieldOptions()
Returns the Options used for field specific properties.
-
modelChanged
public void modelChanged(FieldFormatModel model)
Notifies listeners that the given model has changed.- Parameters:
mode
- the format model that changed.
-
getMaxWidth
public int getMaxWidth()
Returns the width of the widest model in this manager.
-
getMaxRowCount
public int getMaxRowCount()
-
getMaxNumRows
public int getMaxNumRows()
Returns the maximum number of possible rows in a layout. This would only occur if some address had every possible type of information to be displayed.
-
setDefaultFormat
public void setDefaultFormat(int modelID)
Resets the model with the given id to its default format.- Parameters:
modelID
- the id of the model to reset.
-
setDefaultFormats
public void setDefaultFormats()
Resets all format models to their default format.
-
addHighlightProvider
public void addHighlightProvider(HighlightProvider provider)
Adds a HighlightProvider- Parameters:
provider
- the provider to use.- See Also:
removeHighlightProvider(HighlightProvider)
,getHighlightProviders()
-
removeHighlightProvider
public void removeHighlightProvider(HighlightProvider provider)
Removes the provider- Parameters:
provider
- the provider to remove.- See Also:
addHighlightProvider(HighlightProvider)
-
getHighlightProviders
public java.util.List<HighlightProvider> getHighlightProviders()
Gets allHighlightProvider
s installed on this FormatManager via theaddHighlightProvider(HighlightProvider)
.- Returns:
- all
HighlightProvider
s installed on this FormatManager.
-
getFormatHighlightProvider
public HighlightProvider getFormatHighlightProvider()
Returns theHighlightProvider
that should be used when creatingFieldFactory
objects.
-
optionsChanged
public void optionsChanged(ToolOptions options, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Description copied from interface:OptionsChangeListener
Notification that an option changed.Note: to reject an options change, you can throw a
OptionsVetoException
.- Specified by:
optionsChanged
in interfaceOptionsChangeListener
- Parameters:
options
- options object containing the property that changedname
- name of option that changedoldValue
- old value of the optionnewValue
- new value of the option
-
saveState
public void saveState(SaveState saveState)
Saves the state of this LayoutManager to the SaveState object.- Parameters:
saveState
- the SaveState object to write to.
-
readState
public void readState(SaveState saveState)
Restores the state of this LayoutController from the given SaveState object.- Parameters:
saveState
- the SaveState to read from.
-
getServiceProvider
public ServiceProvider getServiceProvider()
-
-