Package ghidra.framework.project.tool
Class ToolManagerImpl
- java.lang.Object
-
- ghidra.framework.project.tool.ToolManagerImpl
-
- All Implemented Interfaces:
ToolManager
,java.beans.PropertyChangeListener
,java.util.EventListener
public class ToolManagerImpl extends java.lang.Object implements ToolManager, java.beans.PropertyChangeListener
Tool manager that knows about all the running tools for each workspace in the project; the tool manager is responsible for launching new tools, and managing connections among tools.
-
-
Field Summary
-
Fields inherited from interface ghidra.framework.model.ToolManager
DEFAULT_WORKSPACE_NAME, WORKSPACE_NAME_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description ToolManagerImpl(Project project)
creates a tool manager for the project
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addWorkspaceChangeListener(WorkspaceChangeListener l)
Add the listener that will be notified when a tool is added or removed.boolean
canAutoSave(Tool tool)
void
clearWorkspaceChanged()
Clear the flag so the user does not get prompted to save the project; flag gets set to true when a workspace is created, and a workspace is created when a new project is created.void
close()
Close all running tools in the project.Workspace
createWorkspace(java.lang.String name)
Create a workspace with the given name.void
disconnectTool(Tool tool)
Remove all connection objects for the given tool.void
dispose()
void
dumpConnectionList()
Debug method for printing out the list of connections.Workspace
getActiveWorkspace()
Get the active workspaceToolConnection
getConnection(Tool producer, Tool consumer)
Get the connection object for the producer and consumer tools.Tool[]
getConsumerTools()
Get a list of tools that consume at least one tool event.Tool[]
getProducerTools()
Get a list of tools that produce at least one tool event.Tool[]
getRunningTools()
Get a list running tools across all workspaces.Tool
getTool(java.lang.String toolName)
Called by WorkspaceImpl when it is restoring its state.ToolServices
getToolServices()
Get any toolservices available from this tool.Workspace[]
getWorkspaces()
Get list of known workspaces.boolean
hasChanged()
Return whether any tools have changed, or if any tools were added or removed from any of the workspaces.void
propertyChange(java.beans.PropertyChangeEvent evt)
void
removeWorkspace(Workspace ws)
Remove the workspace.void
removeWorkspaceChangeListener(WorkspaceChangeListener l)
Remove the workspace listener.void
restoreFromXml(org.jdom.Element root)
restores the object from an XML elementboolean
saveSessionTools()
Save the tools that are opened and changed, that will be brought back up when the project is reopened.org.jdom.Element
saveToXml()
saves this object to an XML element.void
toolChanged(Tool tool)
A configuration change was made to the tool; a plugin was added or removed.void
toolSaved(Tool tool, boolean toolChanged)
-
-
-
Constructor Detail
-
ToolManagerImpl
public ToolManagerImpl(Project project)
creates a tool manager for the project
-
-
Method Detail
-
getActiveWorkspace
public Workspace getActiveWorkspace()
Description copied from interface:ToolManager
Get the active workspace- Specified by:
getActiveWorkspace
in interfaceToolManager
- Returns:
- the active workspace
-
getConsumerTools
public Tool[] getConsumerTools()
Description copied from interface:ToolManager
Get a list of tools that consume at least one tool event.- Specified by:
getConsumerTools
in interfaceToolManager
- Returns:
- zero-length array if no tool consumes any events
-
getProducerTools
public Tool[] getProducerTools()
Description copied from interface:ToolManager
Get a list of tools that produce at least one tool event.- Specified by:
getProducerTools
in interfaceToolManager
- Returns:
- zero-length array if no tool produces any events
-
getRunningTools
public Tool[] getRunningTools()
Description copied from interface:ToolManager
Get a list running tools across all workspaces.- Specified by:
getRunningTools
in interfaceToolManager
- Returns:
- zero-length array if there are no running tools.
-
getConnection
public ToolConnection getConnection(Tool producer, Tool consumer)
Description copied from interface:ToolManager
Get the connection object for the producer and consumer tools.- Specified by:
getConnection
in interfaceToolManager
- Parameters:
producer
- tool that is producing the tool eventconsumer
- tool that is consuming the tool event
-
createWorkspace
public Workspace createWorkspace(java.lang.String name) throws DuplicateNameException
Description copied from interface:ToolManager
Create a workspace with the given name.- Specified by:
createWorkspace
in interfaceToolManager
- Parameters:
name
- name of workspace- Throws:
DuplicateNameException
- if a workspace with this name already exists.
-
removeWorkspace
public void removeWorkspace(Workspace ws)
Description copied from interface:ToolManager
Remove the workspace.- Specified by:
removeWorkspace
in interfaceToolManager
- Parameters:
ws
- workspace to remove
-
getWorkspaces
public Workspace[] getWorkspaces()
Description copied from interface:ToolManager
Get list of known workspaces.- Specified by:
getWorkspaces
in interfaceToolManager
- Returns:
- an array of known workspaces
-
saveToXml
public org.jdom.Element saveToXml()
saves this object to an XML element.
-
restoreFromXml
public void restoreFromXml(org.jdom.Element root)
restores the object from an XML element- Parameters:
root
- root element of saved XML state
-
hasChanged
public boolean hasChanged()
Return whether any tools have changed, or if any tools were added or removed from any of the workspaces.
-
close
public void close()
Close all running tools in the project.
-
saveSessionTools
public boolean saveSessionTools()
Save the tools that are opened and changed, that will be brought back up when the project is reopened.
-
dispose
public void dispose()
-
dumpConnectionList
public void dumpConnectionList()
Debug method for printing out the list of connections.
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
addWorkspaceChangeListener
public void addWorkspaceChangeListener(WorkspaceChangeListener l)
Description copied from interface:ToolManager
Add the listener that will be notified when a tool is added or removed.- Specified by:
addWorkspaceChangeListener
in interfaceToolManager
- Parameters:
l
- workspace listener to add
-
removeWorkspaceChangeListener
public void removeWorkspaceChangeListener(WorkspaceChangeListener l)
Description copied from interface:ToolManager
Remove the workspace listener.- Specified by:
removeWorkspaceChangeListener
in interfaceToolManager
- Parameters:
l
- workspace listener to remove
-
clearWorkspaceChanged
public void clearWorkspaceChanged()
Clear the flag so the user does not get prompted to save the project; flag gets set to true when a workspace is created, and a workspace is created when a new project is created.
-
getToolServices
public ToolServices getToolServices()
Get any toolservices available from this tool.- Returns:
- ToolServices list of tool services this tool can provide.
-
toolChanged
public void toolChanged(Tool tool)
Description copied from interface:ToolManager
A configuration change was made to the tool; a plugin was added or removed.- Specified by:
toolChanged
in interfaceToolManager
- Parameters:
tool
- tool that changed
-
getTool
public Tool getTool(java.lang.String toolName)
Called by WorkspaceImpl when it is restoring its state.
-
disconnectTool
public void disconnectTool(Tool tool)
Remove all connection objects for the given tool.- Specified by:
disconnectTool
in interfaceToolManager
- Parameters:
tool
-
-
canAutoSave
public boolean canAutoSave(Tool tool)
-
toolSaved
public void toolSaved(Tool tool, boolean toolChanged)
-
-