Package ghidra.framework.project
Class DefaultProjectManager
- java.lang.Object
-
- ghidra.framework.project.DefaultProjectManager
-
- All Implemented Interfaces:
ProjectManager
- Direct Known Subclasses:
TestProjectManager
public class DefaultProjectManager extends java.lang.Object implements ProjectManager
Implementation for a ProjectManager; creates, opens, and deletes Projects. It also keeps track of recently opened projects.
-
-
Field Summary
-
Fields inherited from interface ghidra.framework.model.ProjectManager
APPLICATION_TOOL_EXTENSION, APPLICATION_TOOLS_DIR_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultProjectManager()
Construct the single project manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDefaultTools(ToolChest toolChest)
Add the default tools to the given tool chest.Project
createProject(ProjectLocator projectLocator, RepositoryAdapter repAdapter, boolean remember)
Create a project on the local filesystem.boolean
deleteProject(ProjectLocator projectLocator)
Delete the project in the given location and remove it from the list of known projects.void
forgetViewedProject(java.net.URL url)
Remove the project url from the list of known viewed projects.Project
getActiveProject()
Get the project that is currently open.ProjectLocator
getLastOpenedProject()
Get the last opened (active) project.ServerInfo
getMostRecentServerInfo()
Get the information that was last used to access a repository managed by a Ghidra server.ProjectLocator[]
getRecentProjects()
Get list of project locations that user most recently opened.java.net.URL[]
getRecentViewedProjects()
Get list of projects that user most recently viewed.RepositoryServerAdapter
getRepositoryServerAdapter(java.lang.String host, int portNumber, boolean forceConnect)
Establish a connection to the given host and port number.ToolChest
getUserToolChest()
Return the user's ToolChestProject
openProject(ProjectLocator projectLocator, boolean doRestore, boolean resetOwner)
Open a project from the file system.boolean
projectExists(ProjectLocator projectLocator)
Returns true if the specified project exists.void
rememberProject(ProjectLocator projectLocator)
Keep the specified project on the list of known projects.void
rememberViewedProject(java.net.URL url)
Keep the url on the list of known projects.void
setLastOpenedProject(ProjectLocator projectLocator)
Update the last opened project preference.
-
-
-
Method Detail
-
getActiveProject
public Project getActiveProject()
Description copied from interface:ProjectManager
Get the project that is currently open.- Specified by:
getActiveProject
in interfaceProjectManager
- Returns:
- currently open project, return null if there is no project opened
-
createProject
public Project createProject(ProjectLocator projectLocator, RepositoryAdapter repAdapter, boolean remember) throws java.io.IOException
Description copied from interface:ProjectManager
Create a project on the local filesystem.- Specified by:
createProject
in interfaceProjectManager
- Parameters:
projectLocator
- location for where the project should be createdrepAdapter
- repository adapter if this project is to be a shared project; may be null if the project is not shared.remember
- if false the new project should not be remembered (i.e., recently opened, etc.)- Returns:
- the new project
- Throws:
java.io.IOException
- if user cannot access/write the project location
-
openProject
public Project openProject(ProjectLocator projectLocator, boolean doRestore, boolean resetOwner) throws NotFoundException, NotOwnerException, LockException
Description copied from interface:ProjectManager
Open a project from the file system. Add the project url to the list of known projects.- Specified by:
openProject
in interfaceProjectManager
- Parameters:
projectLocator
- project locationdoRestore
- true if the project should be restoredresetOwner
- if true, the owner of the project will be changed to the current user.- Returns:
- opened project
- Throws:
NotFoundException
- if the file for the project was not found.NotOwnerException
- if the project owner is not the userLockException
- if the project is already opened by another user
-
getRecentProjects
public ProjectLocator[] getRecentProjects()
Get list of project locations that user most recently opened.- Specified by:
getRecentProjects
in interfaceProjectManager
- Returns:
- list of project locations
-
getRecentViewedProjects
public java.net.URL[] getRecentViewedProjects()
Description copied from interface:ProjectManager
Get list of projects that user most recently viewed.- Specified by:
getRecentViewedProjects
in interfaceProjectManager
- Returns:
- list of project URLs
-
getLastOpenedProject
public ProjectLocator getLastOpenedProject()
Get the last opened (active) project.- Specified by:
getLastOpenedProject
in interfaceProjectManager
- Returns:
- project last opened by the user; returns NULL if a project was never opened OR the last opened project is no longer valid
-
setLastOpenedProject
public void setLastOpenedProject(ProjectLocator projectLocator)
Update the last opened project preference.- Specified by:
setLastOpenedProject
in interfaceProjectManager
- Parameters:
projectLocator
- project location of last project that was opened
-
deleteProject
public boolean deleteProject(ProjectLocator projectLocator)
Delete the project in the given location and remove it from the list of known projects.- Specified by:
deleteProject
in interfaceProjectManager
- Parameters:
projectLocator
- project location- Returns:
- false if no project was deleted.
-
rememberProject
public void rememberProject(ProjectLocator projectLocator)
Keep the specified project on the list of known projects.- Specified by:
rememberProject
in interfaceProjectManager
- Parameters:
projectLocator
- project location
-
forgetViewedProject
public void forgetViewedProject(java.net.URL url)
Description copied from interface:ProjectManager
Remove the project url from the list of known viewed projects.- Specified by:
forgetViewedProject
in interfaceProjectManager
- Parameters:
url
- project identifier
-
rememberViewedProject
public void rememberViewedProject(java.net.URL url)
Description copied from interface:ProjectManager
Keep the url on the list of known projects.- Specified by:
rememberViewedProject
in interfaceProjectManager
- Parameters:
url
- project identifier
-
projectExists
public boolean projectExists(ProjectLocator projectLocator)
Returns true if the specified project exists.- Specified by:
projectExists
in interfaceProjectManager
- Parameters:
projectLocator
- project location
-
getRepositoryServerAdapter
public RepositoryServerAdapter getRepositoryServerAdapter(java.lang.String host, int portNumber, boolean forceConnect)
Description copied from interface:ProjectManager
Establish a connection to the given host and port number.- Specified by:
getRepositoryServerAdapter
in interfaceProjectManager
- Parameters:
host
- server name or IP addressportNumber
- server port or 0 for defaultforceConnect
- if true and currently not connected, an attempt will be be to connect- Returns:
- a handle to the remote server containing shared repositories
-
getMostRecentServerInfo
public ServerInfo getMostRecentServerInfo()
Description copied from interface:ProjectManager
Get the information that was last used to access a repository managed by a Ghidra server.- Specified by:
getMostRecentServerInfo
in interfaceProjectManager
-
addDefaultTools
public void addDefaultTools(ToolChest toolChest)
Add the default tools to the given tool chest. This method does not attempt to merge the user's previous tools, as doesinstallTools(ToolChest)
.- Parameters:
toolChest
- tool chest which to add the default tools
-
getUserToolChest
public ToolChest getUserToolChest()
Description copied from interface:ProjectManager
Return the user's ToolChest- Specified by:
getUserToolChest
in interfaceProjectManager
-
-