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 protectedDefaultProjectManager()Construct the single project manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDefaultTools(ToolChest toolChest)Add the default tools to the given tool chest.ProjectcreateProject(ProjectLocator projectLocator, RepositoryAdapter repAdapter, boolean remember)Create a project on the local filesystem.booleandeleteProject(ProjectLocator projectLocator)Delete the project in the given location and remove it from the list of known projects.voidforgetViewedProject(java.net.URL url)Remove the project url from the list of known viewed projects.ProjectgetActiveProject()Get the project that is currently open.ProjectLocatorgetLastOpenedProject()Get the last opened (active) project.ServerInfogetMostRecentServerInfo()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.RepositoryServerAdaptergetRepositoryServerAdapter(java.lang.String host, int portNumber, boolean forceConnect)Establish a connection to the given host and port number.ToolChestgetUserToolChest()Return the user's ToolChestProjectopenProject(ProjectLocator projectLocator, boolean doRestore, boolean resetOwner)Open a project from the file system.booleanprojectExists(ProjectLocator projectLocator)Returns true if the specified project exists.voidrememberProject(ProjectLocator projectLocator)Keep the specified project on the list of known projects.voidrememberViewedProject(java.net.URL url)Keep the url on the list of known projects.voidsetLastOpenedProject(ProjectLocator projectLocator)Update the last opened project preference.
-
-
-
Method Detail
-
getActiveProject
public Project getActiveProject()
Description copied from interface:ProjectManagerGet the project that is currently open.- Specified by:
getActiveProjectin 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:ProjectManagerCreate a project on the local filesystem.- Specified by:
createProjectin 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:ProjectManagerOpen a project from the file system. Add the project url to the list of known projects.- Specified by:
openProjectin 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:
getRecentProjectsin interfaceProjectManager- Returns:
- list of project locations
-
getRecentViewedProjects
public java.net.URL[] getRecentViewedProjects()
Description copied from interface:ProjectManagerGet list of projects that user most recently viewed.- Specified by:
getRecentViewedProjectsin interfaceProjectManager- Returns:
- list of project URLs
-
getLastOpenedProject
public ProjectLocator getLastOpenedProject()
Get the last opened (active) project.- Specified by:
getLastOpenedProjectin 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:
setLastOpenedProjectin 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:
deleteProjectin 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:
rememberProjectin interfaceProjectManager- Parameters:
projectLocator- project location
-
forgetViewedProject
public void forgetViewedProject(java.net.URL url)
Description copied from interface:ProjectManagerRemove the project url from the list of known viewed projects.- Specified by:
forgetViewedProjectin interfaceProjectManager- Parameters:
url- project identifier
-
rememberViewedProject
public void rememberViewedProject(java.net.URL url)
Description copied from interface:ProjectManagerKeep the url on the list of known projects.- Specified by:
rememberViewedProjectin interfaceProjectManager- Parameters:
url- project identifier
-
projectExists
public boolean projectExists(ProjectLocator projectLocator)
Returns true if the specified project exists.- Specified by:
projectExistsin interfaceProjectManager- Parameters:
projectLocator- project location
-
getRepositoryServerAdapter
public RepositoryServerAdapter getRepositoryServerAdapter(java.lang.String host, int portNumber, boolean forceConnect)
Description copied from interface:ProjectManagerEstablish a connection to the given host and port number.- Specified by:
getRepositoryServerAdapterin 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:ProjectManagerGet the information that was last used to access a repository managed by a Ghidra server.- Specified by:
getMostRecentServerInfoin 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:ProjectManagerReturn the user's ToolChest- Specified by:
getUserToolChestin interfaceProjectManager
-
-