Package ghidra.framework.plugintool

# Class ToolServicesAdapter

java.lang.Object
ghidra.framework.plugintool.ToolServicesAdapter

All Implemented Interfaces:
  `ToolServices`

Direct Known Subclasses:
  `StandAloneApplication.StandAloneToolServices`

public class ToolServicesAdapter extends Object implements ToolServices

- ## Field Summary

  ### Fields inherited from interface ghidra.framework.model.ToolServices

  `DEFAULT_TOOLNAME`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ToolServicesAdapter()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canAutoSave(PluginTool tool)`
  Returns true if this tool should be saved base on the state of other running instances of the same tool
  `void`
  `closeTool(PluginTool tool)`
  Notify the framework that the tool is closing.
  `File`
  `exportTool(ToolTemplate tool)`
  Save the tool to the given location on the local file system.
  `Set<ToolTemplate>`
  `getCompatibleTools(Class<? extends DomainObject> domainClass)`
  Returns a set of tools that can open the given domain file class.
  `Set<ToolAssociationInfo>`
  `getContentTypeToolAssociations()`
  Returns the `associations`, which describe content types and the tools used to open them, for all content types known to the system.
  `ToolTemplate`
  `getDefaultToolTemplate(DomainFile domainFile)`
  Returns the default/preferred tool template which should be used to open the specified domain file, whether defined by the user or the system default.
  `ToolTemplate`
  `getDefaultToolTemplate(String contentType)`
  Returns the default/preferred tool template which should be used to open the specified domain file content type, whether defined by the user or the system default.
  `PluginTool[]`
  `getRunningTools()`
  Return array of running tools
  `ToolChest`
  `getToolChest()`
  Get the tool chest for the project
  `PluginTool`
  `launchDefaultTool(Collection<DomainFile> domainFile)`
  Launch the default `tool` and open the specified domainFiles.
  `PluginTool`
  `launchDefaultToolWithURL(URL url)`
  Launch the default tool and open the specified Ghidra URL resource.
  `PluginTool`
  `launchTool(String toolName, Collection<DomainFile> domainFile)`
  Launch the `tool` with the given name and open the specified domainFiles.
  `PluginTool`
  `launchToolWithURL(String toolName, URL url)`
  Launch the tool with the given name and attempt to open the specified Ghidra URL resource.
  `void`
  `saveTool(PluginTool tool)`
  Saves the tool's configuration in the standard tool location.
  `void`
  `setContentTypeToolAssociations(Set<ToolAssociationInfo> infos)`
  Sets the `associations`, which describe content types and the tools used to open them, for the system.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ToolServicesAdapter

    public ToolServicesAdapter()

- ## Method Details

  - ### canAutoSave

    public boolean canAutoSave(PluginTool tool)
    Description copied from interface: `ToolServices`
    Returns true if this tool should be saved base on the state of other running instances of the same tool
    Specified by:
      `canAutoSave` in interface `ToolServices`
    Parameters:
      `tool` - the tool to check for saving
    Returns:
      true if the tool should be saved

  - ### closeTool

    public void closeTool(PluginTool tool)
    Description copied from interface: `ToolServices`
    Notify the framework that the tool is closing.
    Specified by:
      `closeTool` in interface `ToolServices`
    Parameters:
      `tool` - tool that is closing

  - ### exportTool

    public File exportTool(ToolTemplate tool) throws FileNotFoundException, IOException
    Description copied from interface: `ToolServices`
    Save the tool to the given location on the local file system.
    Specified by:
      `exportTool` in interface `ToolServices`
    Parameters:
      `tool` - the tool template to write
    Returns:
      the file to which the tool was saved
    Throws:
      `FileNotFoundException` - thrown if the file's directory doesn't exist.
      `IOException` - thrown if there is an error writing the file.

  - ### getCompatibleTools

    public Set<ToolTemplate> getCompatibleTools(Class<? extends DomainObject> domainClass)
    Description copied from interface: `ToolServices`
    Returns a set of tools that can open the given domain file class.
    Specified by:
      `getCompatibleTools` in interface `ToolServices`
    Parameters:
      `domainClass` - The domain file class type for which to get tools
    Returns:
      the tools

  - ### getContentTypeToolAssociations

    public Set<ToolAssociationInfo> getContentTypeToolAssociations()
    Description copied from interface: `ToolServices`
    Returns the `associations`, which describe content types and the tools used to open them, for all content types known to the system.
    Specified by:
      `getContentTypeToolAssociations` in interface `ToolServices`
    Returns:
      the associations
    See Also:
      - `ToolServices.setContentTypeToolAssociations(Set)`

  - ### getDefaultToolTemplate

    public ToolTemplate getDefaultToolTemplate(DomainFile domainFile)
    Description copied from interface: `ToolServices`
    Returns the default/preferred tool template which should be used to open the specified domain file, whether defined by the user or the system default.
    Specified by:
      `getDefaultToolTemplate` in interface `ToolServices`
    Parameters:
      `domainFile` - The file whose preferred tool should be found.
    Returns:
      The preferred tool that should be used to open the given file or null if none found.

  - ### getDefaultToolTemplate

    public ToolTemplate getDefaultToolTemplate(String contentType)
    Description copied from interface: `ToolServices`
    Returns the default/preferred tool template which should be used to open the specified domain file content type, whether defined by the user or the system default.
    Specified by:
      `getDefaultToolTemplate` in interface `ToolServices`
    Parameters:
      `contentType` - The content type whose preferred tool should be found.
    Returns:
      The preferred tool that should be used to open the given file or null if none found.

  - ### getRunningTools

    public PluginTool[] getRunningTools()
    Description copied from interface: `ToolServices`
    Return array of running tools
    Specified by:
      `getRunningTools` in interface `ToolServices`
    Returns:
      array of Tools

  - ### getToolChest

    public ToolChest getToolChest()
    Description copied from interface: `ToolServices`
    Get the tool chest for the project
    Specified by:
      `getToolChest` in interface `ToolServices`
    Returns:
      the tool chest

  - ### launchDefaultTool

    public PluginTool launchDefaultTool(Collection<DomainFile> domainFile)
    Description copied from interface: `ToolServices`
    Launch the default `tool` and open the specified domainFiles. NOTE: running tool reuse is implementation dependent
    Specified by:
      `launchDefaultTool` in interface `ToolServices`
    Parameters:
      `domainFile` - the files to open. A null or empty list will results in an immediate return of a null `PluginTool`. Null entries are not permitted.
    Returns:
      the launched tool. Null returned if a suitable default tool for the file content type was not found or failed to launch.

  - ### launchTool

    public PluginTool launchTool(String toolName, Collection<DomainFile> domainFile)
    Description copied from interface: `ToolServices`
    Launch the `tool` with the given name and open the specified domainFiles. Only those domainFiles with a content type supported by the specified tool will be opened. NOTE: running tool reuse is implementation dependent.
    Specified by:
      `launchTool` in interface `ToolServices`
    Parameters:
      `toolName` - name of the `tool template` to launch or re-use
      `domainFile` - the files to open; may be null or empty. Null entries are not permitted.
    Returns:
      the resulting `tool` or null if the specified tool was not found or failed to launch

  - ### launchDefaultToolWithURL

    public PluginTool launchDefaultToolWithURL(URL url)
    Description copied from interface: `ToolServices`
    Launch the default tool and open the specified Ghidra URL resource. The tool chosen will be based upon the content type of the specified resource. NOTE: running tool re-use is implementation dependent
    Specified by:
      `launchDefaultToolWithURL` in interface `ToolServices`
    Parameters:
      `url` - resource to be opened (see `GhidraURL`)
    Returns:
      the launched tool. Null returned if a failure occurs while accessing the specified resource or a suitable default tool for the file content type was not found.

  - ### launchToolWithURL

    public PluginTool launchToolWithURL(String toolName, URL url)
    Description copied from interface: `ToolServices`
    Launch the tool with the given name and attempt to open the specified Ghidra URL resource.
    Specified by:
      `launchToolWithURL` in interface `ToolServices`
    Parameters:
      `toolName` - name of the tool to launch
      `url` - resource to be opened (see `GhidraURL`)
    Returns:
      the requested tool or null if the specified tool not found.

  - ### saveTool

    public void saveTool(PluginTool tool)
    Description copied from interface: `ToolServices`
    Saves the tool's configuration in the standard tool location.
    Specified by:
      `saveTool` in interface `ToolServices`
    Parameters:
      `tool` - tool to save.

  - ### setContentTypeToolAssociations

    public void setContentTypeToolAssociations(Set<ToolAssociationInfo> infos)
    Description copied from interface: `ToolServices`
    Sets the `associations`, which describe content types and the tools used to open them, for the system.
    Specified by:
      `setContentTypeToolAssociations` in interface `ToolServices`
    Parameters:
      `infos` - The associations to be applied
    See Also:
      - `ToolServices.getContentTypeToolAssociations()`