Package ghidra.framework.project

# Class DefaultProject

java.lang.Object
ghidra.framework.project.DefaultProject

All Implemented Interfaces:
  `Project`, `AutoCloseable`, `Iterable<DomainFile>`

Direct Known Subclasses:
  `PyGhidraProject`

public class DefaultProject extends Object implements Project
Implementation for a Project.

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `DefaultProject(DefaultProjectManager projectManager, DefaultProjectData projectData)`
  Construct a project with specific project manager and data
  `protected`
  `DefaultProject(DefaultProjectManager projectManager, ProjectLocator projectLocator, boolean resetOwner)`
  Constructor for opening a project.
  `protected`
  `DefaultProject(DefaultProjectManager projectManager, ProjectLocator projectLocator, RepositoryAdapter repository)`
  Constructor for creating a New project

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ProjectData`
  `addProjectView(URL url, boolean visible)`
  Add the given project URL to this project's list project views.
  `void`
  `addProjectViewListener(ProjectViewListener listener)`
  Add a listener to be notified when a visible project view is added or removed.
  `void`
  `close()`
  Close the project.
  `ToolChest`
  `getLocalToolChest()`
  Get the local tool chest for the user logged in.
  `String`
  `getName()`
  Returns the name of this project.
  `List<DomainFile>`
  `getOpenData()`
  Get list of domain files that are open.
  `DefaultProjectData`
  `getProjectData()`
  Returns the root domain data folder in the project.
  `ProjectData`
  `getProjectData(ProjectLocator locator)`
  Returns the Project Data for the given Project locator.
  `ProjectData`
  `getProjectData(URL url)`
  Returns the Project Data for the given Project URL.
  `ProjectLocator`
  `getProjectLocator()`
  Get the project URL for this project.
  `ProjectManager`
  `getProjectManager()`
  Returns the project manager of this project.
  `ProjectLocator[]`
  `getProjectViews()`
  Returns the list of visible project views in this project.
  `RepositoryAdapter`
  `getRepository()`
  Get the repository that this project is associated with.
  `SaveState`
  `getSaveableData(String key)`
  Returns the user data previously stored to the project.
  `ToolManager`
  `getToolManager()`
  Returns the tool manager for this project.
  `ToolServices`
  `getToolServices()`
  Get the tool services for this project.
  `ToolTemplate`
  `getToolTemplate(String tag)`
  Get the tool template with the given tag.
  `ProjectData[]`
  `getViewedProjectData()`
  Get the project data for visible viewed projects that are managed by this project.
  `boolean`
  `hasChanged()`
  Returns whether the project configuration has changed.
  `boolean`
  `isClosed()`
  Returns whether this project instance has been closed.
  `void`
  `releaseFiles(Object consumer)`
  Releases all DomainObjects used by the given consumer
  `void`
  `removeProjectView(URL url)`
  Remove the view from this project.
  `void`
  `removeProjectViewListener(ProjectViewListener listener)`
  Remove a project view listener previously added.
  `void`
  `restore()`
  Restore this project's state.
  `void`
  `save()`
  Save the project and the list of project views.
  `boolean`
  `saveSessionTools()`
  Saves any tools that are associated with the opened project when the project is closed.
  `void`
  `saveToolTemplate(String tag, ToolTemplate template)`
  Save the given tool template as part of the project.
  `void`
  `setSaveableData(String key, SaveState saveState)`
  Allows the user to store data related to the project.
  `String`
  `toString()`

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

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

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

  ### Methods inherited from interface ghidra.framework.model.Project

  `iterator`

- ## Constructor Details

  - ### DefaultProject

    protected DefaultProject(DefaultProjectManager projectManager, ProjectLocator projectLocator, RepositoryAdapter repository) throws IOException, LockException
    Constructor for creating a New project
    Parameters:
      `projectManager` - the manager of this project
      `projectLocator` - location and name of project
      `repository` - shared repository associated with the new project. Can be null for non-shared projects
    Throws:
      `IOException` - if I/O error occurs.
      `LockException` - if unable to establish project lock

  - ### DefaultProject

    protected DefaultProject(DefaultProjectManager projectManager, ProjectLocator projectLocator, boolean resetOwner) throws IOException, NotOwnerException, LockException
    Constructor for opening a project.
    Parameters:
      `projectManager` - the manager of this project
      `projectLocator` - location and name of project
      `resetOwner` - if true, set the owner to the current user
    Throws:
      `FileNotFoundException` - project directory not found
      `IOException` - if I/O error occurs.
      `NotOwnerException` - if userName is not the owner of the project.
      `LockException` - if unable to establish project lock

  - ### DefaultProject

    protected DefaultProject(DefaultProjectManager projectManager, DefaultProjectData projectData)
    Construct a project with specific project manager and data
    Parameters:
      `projectManager` - the manager of this project
      `projectData` - the project data

- ## Method Details

  - ### getProjectManager

    public ProjectManager getProjectManager()
    Description copied from interface: `Project`
    Returns the project manager of this project.
    Specified by:
      `getProjectManager` in interface `Project`
    Returns:
      the project manager of this project

  - ### getProjectLocator

    public ProjectLocator getProjectLocator()
    Get the project URL for this project.
    Specified by:
      `getProjectLocator` in interface `Project`
    Returns:
      the project locator for this project

  - ### addProjectViewListener

    public void addProjectViewListener(ProjectViewListener listener)
    Description copied from interface: `Project`
    Add a listener to be notified when a visible project view is added or removed.
    Specified by:
      `addProjectViewListener` in interface `Project`
    Parameters:
      `listener` - project view listener

  - ### removeProjectViewListener

    public void removeProjectViewListener(ProjectViewListener listener)
    Description copied from interface: `Project`
    Remove a project view listener previously added.
    Specified by:
      `removeProjectViewListener` in interface `Project`
    Parameters:
      `listener` - project view listener

  - ### addProjectView

    public ProjectData addProjectView(URL url, boolean visible) throws IOException
    Description copied from interface: `Project`
    Add the given project URL to this project's list project views. The project view allows users to look at data files from another project. If the URL corresponds to this project its ProjectData will be returned.
    Specified by:
      `addProjectView` in interface `Project`
    Parameters:
      `url` - identifier for the project view (ghidra protocol only).
      `visible` - true if project may be made visible or false if hidden. Hidden viewed projects are used when only life-cycle management is required (e.g., close view project when this project is closed).
    Returns:
      project data for this view
    Throws:
      `IOException` - if this project is closed, an invalid URL is specified, or failed to open/connect to project/repository.

  - ### getProjectData

    public ProjectData getProjectData(URL url)
    Description copied from interface: `Project`
    Returns the Project Data for the given Project URL. The Project URL must be either the current active project or a currently open project view. The returned view may not be visible.
    Specified by:
      `getProjectData` in interface `Project`
    Parameters:
      `url` - identifier for the project view (ghidra protocol only).
    Returns:
      project data for this view or null

  - ### removeProjectView

    public void removeProjectView(URL url)
    Remove the view from this project.
    Specified by:
      `removeProjectView` in interface `Project`
    Parameters:
      `url` - identifier for the project

  - ### getToolServices

    public ToolServices getToolServices()
    Get the tool services for this project.
    Specified by:
      `getToolServices` in interface `Project`
    Returns:
      the tool services for this project

  - ### getLocalToolChest

    public ToolChest getLocalToolChest()
    Get the local tool chest for the user logged in.
    Specified by:
      `getLocalToolChest` in interface `Project`
    Returns:
      the tool chest

  - ### getName

    public String getName()
    Description copied from interface: `Project`
    Returns the name of this project.
    Specified by:
      `getName` in interface `Project`
    Returns:
      the name of this project

  - ### getToolManager

    public ToolManager getToolManager()
    Description copied from interface: `Project`
    Returns the tool manager for this project.
    Specified by:
      `getToolManager` in interface `Project`
    Returns:
      the tool manager for this project

  - ### hasChanged

    public boolean hasChanged()
    Description copied from interface: `Project`
    Returns whether the project configuration has changed.
    Specified by:
      `hasChanged` in interface `Project`
    Returns:
      whether the project configuration has changed

  - ### getProjectViews

    public ProjectLocator[] getProjectViews()
    Description copied from interface: `Project`
    Returns the list of visible project views in this project.
    Specified by:
      `getProjectViews` in interface `Project`
    Returns:
      the list of visible project views in this project

  - ### getRepository

    public RepositoryAdapter getRepository()
    Description copied from interface: `Project`
    Get the repository that this project is associated with.
    Specified by:
      `getRepository` in interface `Project`
    Returns:
      null if the project is not associated with a remote repository

  - ### close

    public void close()
    Description copied from interface: `Project`
    Close the project.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `Project`

  - ### isClosed

    public boolean isClosed()
    Description copied from interface: `Project`
    Returns whether this project instance has been closed.
    Specified by:
      `isClosed` in interface `Project`
    Returns:
      whether this project instance has been closed

  - ### saveSessionTools

    public boolean saveSessionTools()
    Description copied from interface: `Project`
    Saves any tools that are associated with the opened project when the project is closed.
    Specified by:
      `saveSessionTools` in interface `Project`
    Returns:
      True if the save was not cancelled.

  - ### restore

    public void restore()
    Description copied from interface: `Project`
    Restore this project's state.
    Specified by:
      `restore` in interface `Project`

  - ### save

    public void save()
    Description copied from interface: `Project`
    Save the project and the list of project views.
    Specified by:
      `save` in interface `Project`

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### saveToolTemplate

    public void saveToolTemplate(String tag, ToolTemplate template)
    Description copied from interface: `Project`
    Save the given tool template as part of the project.
    Specified by:
      `saveToolTemplate` in interface `Project`
    Parameters:
      `tag` - ID or name for the tool template
      `template` - template to save

  - ### getToolTemplate

    public ToolTemplate getToolTemplate(String tag)
    Description copied from interface: `Project`
    Get the tool template with the given tag.
    Specified by:
      `getToolTemplate` in interface `Project`
    Parameters:
      `tag` - ID or name for the tool template to get
    Returns:
      tool template

  - ### getOpenData

    public List<DomainFile> getOpenData()
    Description copied from interface: `Project`
    Get list of domain files that are open.
    Specified by:
      `getOpenData` in interface `Project`
    Returns:
      the files; empty if no files

  - ### getProjectData

    public DefaultProjectData getProjectData()
    Description copied from interface: `Project`
    Returns the root domain data folder in the project.
    Specified by:
      `getProjectData` in interface `Project`
    Returns:
      the root domain data folder in the project

  - ### setSaveableData

    public void setSaveableData(String key, SaveState saveState)
    Description copied from interface: `Project`
    Allows the user to store data related to the project. See `Project.getSaveableData(String)` for future retieval of data.
    Specified by:
      `setSaveableData` in interface `Project`
    Parameters:
      `key` - a value used to store and lookup saved data
      `saveState` - a container of data that will be written out when persisted

  - ### getSaveableData

    public SaveState getSaveableData(String key)
    Description copied from interface: `Project`
    Returns the user data previously stored to the project. See `Project.setSaveableData(String, SaveState)`.
    Specified by:
      `getSaveableData` in interface `Project`
    Parameters:
      `key` - a value used to store and lookup saved data
    Returns:
      the user data previously stored to the project

  - ### getProjectData

    public ProjectData getProjectData(ProjectLocator locator)
    Description copied from interface: `Project`
    Returns the Project Data for the given Project locator. The Project locator must be either the current active project or an currently open project view. The returned view may not be visible.
    Specified by:
      `getProjectData` in interface `Project`
    Parameters:
      `locator` - project locator object used to open project
    Returns:
      requested project data

  - ### getViewedProjectData

    public ProjectData[] getViewedProjectData()
    Description copied from interface: `Project`
    Get the project data for visible viewed projects that are managed by this project.
    Specified by:
      `getViewedProjectData` in interface `Project`
    Returns:
      zero length array if there are no visible viewed projects open

  - ### releaseFiles

    public void releaseFiles(Object consumer)
    Description copied from interface: `Project`
    Releases all DomainObjects used by the given consumer
    Specified by:
      `releaseFiles` in interface `Project`
    Parameters:
      `consumer` - object no longer using any DomainObjects.