Package ghidra.app.merge
Class ProgramMergeManagerPlugin
- java.lang.Object
-
- ghidra.framework.plugintool.Plugin
-
- ghidra.app.merge.MergeManagerPlugin
-
- ghidra.app.merge.ProgramMergeManagerPlugin
-
- All Implemented Interfaces:
ProgramManager
,ProgramaticUseOnly
,DomainObjectListener
,PluginEventListener
,ServiceListener
,ExtensionPoint
,java.util.EventListener
public class ProgramMergeManagerPlugin extends MergeManagerPlugin implements ProgramManager
Plugin that provides a merge component provider.
-
-
Field Summary
-
Fields inherited from class ghidra.app.merge.MergeManagerPlugin
currentDomainObject, mergeManager, provider
-
Fields inherited from class ghidra.framework.plugintool.Plugin
name, pluginDescription, tool
-
Fields inherited from interface ghidra.app.services.ProgramManager
OPEN_CURRENT, OPEN_HIDDEN, OPEN_VISIBLE
-
-
Constructor Summary
Constructors Constructor Description ProgramMergeManagerPlugin(PluginTool tool, ProgramMultiUserMergeManager mergeManager, Program program)
Constructor for plugin that handles multi-user merge of programs.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
closeAllPrograms(boolean ignoreChanges)
Closes all open programs in this tool.boolean
closeOtherPrograms(boolean ignoreChanges)
Closes all open programs in this tool except the current program.boolean
closeProgram()
Closes the currently active programboolean
closeProgram(Program program, boolean ignoreChanges)
Closes the given program with the option of saving any changes.ghidra.app.merge.MergeManagerProvider
createProvider()
Creates the provider that will be displayed in the merge tool.protected void
dispose()
Tells a plugin that it is no longer needed.Program[]
getAllOpenPrograms()
Returns a list of all open program.Program
getCurrentProgram()
Return the program that is currently active.Program
getProgram(Address addr)
Returns the first program in the list of open programs that contains the given address.int
getSearchPriority(Program p)
boolean
isLocked()
Returns true if program manager is in the locked stateboolean
isVisible(Program program)
Returns true if the specified program is open and considered visible to the user.void
lockDown(boolean state)
Allows program manager state to be locked/unlocked.Program
openProgram(DomainFile domainFile)
Open the program for the given domainFile.Program
openProgram(DomainFile df, int version)
Opens the specified version of the program represented by the given DomainFile.Program
openProgram(DomainFile domainFile, int version, int state)
Open the program for the given domainFileProgram
openProgram(DomainFile domainFile, java.awt.Component dialogParent)
Open the program for the given domainFile.void
openProgram(Program program)
Opens the program to the tool.void
openProgram(Program program, boolean current)
Opens the program to the tool.void
openProgram(Program program, int state)
Open the specified program in the tool.Program
openProgram(java.net.URL ghidraURL, int state)
Open the program corresponding to the given url.void
processEvent(PluginEvent event)
Method called to process a plugin event.void
releaseProgram(Program program, java.lang.Object persistentOwner)
Release the persistent ownership of a program.void
saveProgram()
Saves the current program, possibly prompting the user for a new name.void
saveProgram(Program program)
Saves the specified program, possibly prompting the user for a new name.void
saveProgramAs()
Prompts the user to save the current program to a selected file.void
saveProgramAs(Program program)
Prompts the user to save the specified program to a selected file.void
setCurrentProgram(Program p)
Sets the given program to be the current active program in the tool.boolean
setPersistentOwner(Program program, java.lang.Object owner)
Establish a persistent owner on an open program.void
setSearchPriority(Program p, int priority)
-
Methods inherited from class ghidra.app.merge.MergeManagerPlugin
canClose, closeAllDomainObjects, closeDomainObject, closeDomainObject, domainObjectChanged, getAllOpenDomainObjects, getCategory, getCurrentDomainObject, getDescription, getDescriptiveName, getSearchPriority, isVisible, openDomainObject, openDomainObject, openDomainObject, openDomainObject, openDomainObject, openDomainObject, releaseDomainObject, setCurrentDomainObject, setPersistentOwner, setSearchPriority
-
Methods inherited from class ghidra.framework.plugintool.Plugin
acceptData, canCloseDomainObject, cleanup, close, dataStateRestoreCompleted, dependsUpon, deregisterService, equals, eventSent, firePluginEvent, getData, getMissingRequiredServices, getName, getPluginDescription, getPluginName, getServicesRequired, getSupportedDataTypes, getTool, getTransientState, getUndoRedoState, hashCode, hasMissingRequiredService, hasUnsaveData, init, isDisposed, prepareToSave, readConfigState, readDataState, registerDynamicEventConsumed, registerDynamicServiceProvided, registerEventConsumed, registerEventProduced, registerServiceProvided, registerServiceUsed, restoreTransientState, restoreUndoRedoState, saveData, serviceAdded, serviceRemoved, writeConfigState, writeDataState
-
-
-
-
Constructor Detail
-
ProgramMergeManagerPlugin
public ProgramMergeManagerPlugin(PluginTool tool, ProgramMultiUserMergeManager mergeManager, Program program)
Constructor for plugin that handles multi-user merge of programs.- Parameters:
tool
- the tool with the active program to be mergedmergeManager
- the merge manager that will control the merge processprogram
- the current program
-
-
Method Detail
-
createProvider
public ghidra.app.merge.MergeManagerProvider createProvider()
Description copied from class:MergeManagerPlugin
Creates the provider that will be displayed in the merge tool. This shows the merge progress to the user and lets the user resolve conflicts. Any class that extends this plugin must provide its own MergeManagerProvider here that will be shown to the user for the merge.- Specified by:
createProvider
in classMergeManagerPlugin
- Returns:
- the merge provider associated with this plugin.
-
processEvent
public void processEvent(PluginEvent event)
Description copied from class:Plugin
Method called to process a plugin event. Plugins should override this method if the plugin processes PluginEvents;- Specified by:
processEvent
in classMergeManagerPlugin
- Parameters:
event
- plugin to process
-
dispose
protected void dispose()
Description copied from class:Plugin
Tells a plugin that it is no longer needed. The plugin should release any resources that it has. All actions, components, services will automatically be cleaned up.- Overrides:
dispose
in classMergeManagerPlugin
-
closeOtherPrograms
public boolean closeOtherPrograms(boolean ignoreChanges)
Description copied from interface:ProgramManager
Closes all open programs in this tool except the current program. If this tool is the only tool with a program open and that program has changes, then the user will be prompted to close each such file. (Providing the ignoreChanges flag is false)- Specified by:
closeOtherPrograms
in interfaceProgramManager
- Parameters:
ignoreChanges
- if true, the programs will be closed without saving changes.- Returns:
- true if all other programs were closed. Returns false if the user canceled the close while being prompted to save.
-
closeAllPrograms
public boolean closeAllPrograms(boolean ignoreChanges)
Description copied from interface:ProgramManager
Closes all open programs in this tool. If this tool is the only tool with a program open and that program has changes, then the user will be prompted to close each such file. (Providing the ignoreChanges flag is false)- Specified by:
closeAllPrograms
in interfaceProgramManager
- Parameters:
ignoreChanges
- if true, the programs will be closed without saving changes.- Returns:
- true if all programs were closed. Returns false if the user canceled the close while being prompted to save.
-
closeProgram
public boolean closeProgram()
Description copied from interface:ProgramManager
Closes the currently active program- Specified by:
closeProgram
in interfaceProgramManager
- Returns:
- true if the close is successful. false if the close fails or if there is no program currently active.
-
closeProgram
public boolean closeProgram(Program program, boolean ignoreChanges)
Description copied from interface:ProgramManager
Closes the given program with the option of saving any changes. The exact behavior of this method depends on several factors. First of all, if any other tool has this program open, then the program is closed for this tool only and the user is not prompted to save the program regardless of the ignoreChanges flag. Otherwise, if ignoreChanges is false and changes have been made, the user is prompted to save the program.- Specified by:
closeProgram
in interfaceProgramManager
- Parameters:
program
- the program to close.ignoreChanges
- if true, the program is closed without saving any changes.- Returns:
- true if the program was closed. Returns false if the user canceled the close while being prompted to save. Also returns false if the program passed in as a parameter is null.
-
getAllOpenPrograms
public Program[] getAllOpenPrograms()
Description copied from interface:ProgramManager
Returns a list of all open program.- Specified by:
getAllOpenPrograms
in interfaceProgramManager
- Returns:
- the programs
-
getCurrentProgram
public Program getCurrentProgram()
Description copied from interface:ProgramManager
Return the program that is currently active.- Specified by:
getCurrentProgram
in interfaceProgramManager
- Returns:
- may return null if no program is open
-
getProgram
public Program getProgram(Address addr)
Description copied from interface:ProgramManager
Returns the first program in the list of open programs that contains the given address. Programs are searched in the order they were opened within a given priority. Program are initially opened with the PRIORITY_NORMAL priority, but can be set to have PRIORITY_HIGH or PRIORITY_LOW.- Specified by:
getProgram
in interfaceProgramManager
- Parameters:
addr
- the address for which to search.- Returns:
- the first program that can be found to contain the given address.
-
getSearchPriority
public int getSearchPriority(Program p)
-
isVisible
public boolean isVisible(Program program)
Description copied from interface:ProgramManager
Returns true if the specified program is open and considered visible to the user.- Specified by:
isVisible
in interfaceProgramManager
- Parameters:
program
- the program- Returns:
- true if the specified program is open and considered visible to the user
-
openProgram
public Program openProgram(java.net.URL ghidraURL, int state)
Description copied from interface:ProgramManager
Open the program corresponding to the given url.- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
ghidraURL
- valid server-based program URLstate
- initial open state (OPEN_HIDDEN, OPEN_CURRENT, OPEN_VISIBLE). The visibility states will be ignored if the program is already open.- Returns:
- null if the user canceled the "open" for the new program or an error occurred and was displayed.
- See Also:
GhidraURL
-
openProgram
public Program openProgram(DomainFile domainFile)
Description copied from interface:ProgramManager
Open the program for the given domainFile. Once open it will become the active program.- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
domainFile
- domain file that has the program- Returns:
- null if the user canceled the "open" for the new program
-
openProgram
public Program openProgram(DomainFile domainFile, java.awt.Component dialogParent)
Description copied from interface:ProgramManager
Open the program for the given domainFile. Once open it will become the active program.Note: this method functions exactly as
ProgramManager.openProgram(DomainFile)
- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
domainFile
- domain file that has the programdialogParent
- unused- Returns:
- the program
-
openProgram
public Program openProgram(DomainFile df, int version)
Description copied from interface:ProgramManager
Opens the specified version of the program represented by the given DomainFile. This method should be used for shared DomainFiles. The newly opened file will be made the active program.- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
df
- the DomainFile to openversion
- the version of the Program to open- Returns:
- the opened program or null if the given version does not exist.
-
openProgram
public Program openProgram(DomainFile domainFile, int version, int state)
Description copied from interface:ProgramManager
Open the program for the given domainFile- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
domainFile
- domain file that has the programversion
- the version of the Program to open. Specify DomainFile.DEFAULT_VERSION for file update mode.state
- initial open state (OPEN_HIDDEN, OPEN_CURRENT, OPEN_VISIBLE). The visibility states will be ignored if the program is already open.- Returns:
- null if the user canceled the "open" for the new program or an error occurred and was displayed.
-
openProgram
public void openProgram(Program program)
Description copied from interface:ProgramManager
Opens the program to the tool. In this case the program is already open, but this tool may not have it registered as open. The program is made the active program.- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
program
- the program to register as open with the tool.
-
openProgram
public void openProgram(Program program, boolean current)
Description copied from interface:ProgramManager
Opens the program to the tool. In this case the program is already open, but this tool may not have it registered as open. The program is made the active program.- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
program
- the program to register as open with the tool.current
- if true, the program is made the current active program. If false, then the program is made active only if it the first open program in the tool.
-
openProgram
public void openProgram(Program program, int state)
Description copied from interface:ProgramManager
Open the specified program in the tool.- Specified by:
openProgram
in interfaceProgramManager
- Parameters:
program
- the programstate
- initial open state (OPEN_HIDDEN, OPEN_CURRENT, OPEN_VISIBLE). The visibility states will be ignored if the program is already open.
-
releaseProgram
public void releaseProgram(Program program, java.lang.Object persistentOwner)
Description copied from interface:ProgramManager
Release the persistent ownership of a program.The program will automatically be closed if it is hidden or was marked as temporary. If any of these closures corresponds to a program with changes the user will be given an opportunity to save or keep the program open.
If persistentOwner is not the correct owner, the method will have no affect.
- Specified by:
releaseProgram
in interfaceProgramManager
- Parameters:
program
- the programpersistentOwner
- the owner defined byProgramManager.setPersistentOwner(Program, Object)
-
saveProgram
public void saveProgram()
Description copied from interface:ProgramManager
Saves the current program, possibly prompting the user for a new name.- Specified by:
saveProgram
in interfaceProgramManager
-
saveProgram
public void saveProgram(Program program)
Description copied from interface:ProgramManager
Saves the specified program, possibly prompting the user for a new name.- Specified by:
saveProgram
in interfaceProgramManager
- Parameters:
program
- the program
-
saveProgramAs
public void saveProgramAs()
Description copied from interface:ProgramManager
Prompts the user to save the current program to a selected file.- Specified by:
saveProgramAs
in interfaceProgramManager
-
saveProgramAs
public void saveProgramAs(Program program)
Description copied from interface:ProgramManager
Prompts the user to save the specified program to a selected file.- Specified by:
saveProgramAs
in interfaceProgramManager
- Parameters:
program
- the program
-
setCurrentProgram
public void setCurrentProgram(Program p)
Description copied from interface:ProgramManager
Sets the given program to be the current active program in the tool.- Specified by:
setCurrentProgram
in interfaceProgramManager
- Parameters:
p
- the program to make active.
-
setPersistentOwner
public boolean setPersistentOwner(Program program, java.lang.Object owner)
Description copied from interface:ProgramManager
Establish a persistent owner on an open program. This will cause the program manager to imply make a program hidden if it is closed.- Specified by:
setPersistentOwner
in interfaceProgramManager
- Parameters:
program
- the programowner
- the owner- Returns:
- true if program is open and another object is not already the owner, or the specified owner is already the owner.
- See Also:
ProgramManager.releaseProgram(Program, Object)
-
setSearchPriority
public void setSearchPriority(Program p, int priority)
-
isLocked
public boolean isLocked()
Description copied from interface:ProgramManager
Returns true if program manager is in the locked state- Specified by:
isLocked
in interfaceProgramManager
- Returns:
- true if program manager is in the locked state
-
lockDown
public void lockDown(boolean state)
Description copied from interface:ProgramManager
Allows program manager state to be locked/unlocked. While locked, the program manager will not support opening additional programs.- Specified by:
lockDown
in interfaceProgramManager
- Parameters:
state
- locked if true, unlocked if false
-
-