public interface ProjectManagerImplementation
ProjectManager
.Modifier and Type | Interface and Description |
---|---|
static class |
ProjectManagerImplementation.ProjectManagerCallBack
Callback to notify the
ProjectManager about changes. |
Modifier and Type | Method and Description |
---|---|
void |
clearNonProjectCache()
Clear the cached list of folders thought not to be projects.
|
Project |
findProject(FileObject projectDirectory)
Find an open project corresponding to a given project directory.
|
Set<Project> |
getModifiedProjects()
Get a list of all projects which are modified and need to be saved.
|
Mutex |
getMutex()
Get a read/write lock to be used for all project metadata accesses.
|
Mutex |
getMutex(boolean autoSave,
Project project,
Project... otherProjects)
Get a read/write lock to be used for project metadata accesses.
|
void |
init(ProjectManagerImplementation.ProjectManagerCallBack callBack)
Configures
ProjectManagerImplementation . |
boolean |
isModified(Project p)
Check whether a given project is current modified.
|
ProjectManager.Result |
isProject(FileObject projectDirectory)
Check whether a given directory is likely to contain a project without
actually loading it.
|
boolean |
isValid(Project p)
Checks whether a project is still valid.
|
void |
saveAllProjects()
Save all modified projects.
|
void |
saveProject(Project p)
Save one project (if it was in fact modified).
|
void init(@NonNull ProjectManagerImplementation.ProjectManagerCallBack callBack)
ProjectManagerImplementation
.
Called before the ProjectManager
starts to use
the implementation.callBack
- the callBack@NonNull Mutex getMutex()
@NonNull Mutex getMutex(boolean autoSave, @NonNull Project project, @NonNull Project... otherProjects)
autoSave
- if true the other most write operation automatically saves
the passed project(s)project
- the project to lockotherProjects
- other projects to lock@CheckForNull Project findProject(@NonNull FileObject projectDirectory) throws IOException, IllegalArgumentException
Acquires read access.
It is not guaranteed that the returned instance will be identical
to that which is created by the appropriate ProjectFactory
. In
particular, the project manager is free to return only wrapper Project
instances which delegate to the factory's implementation. If you know your
factory created a particular project, you cannot safely cast the return value
of this method to your project type implementation class; you should instead
place an implementation of some suitable private interface into your project's
lookup, which would be safely proxied.
projectDirectory
- the project top directoryProjectFactory
(might be null even if ProjectManagerImplementation.isProject(org.openide.filesystems.FileObject)
returns true)IOException
- if the project was recognized but could not be loadedIllegalArgumentException
- if the supplied file object is null or not a folder@CheckForNull ProjectManager.Result isProject(@NonNull FileObject projectDirectory) throws IllegalArgumentException
ProjectManager.Result
object contains additional
information about the found project.
Should be faster and use less memory than ProjectManagerImplementation.findProject(org.openide.filesystems.FileObject)
when called
on a large number of directories.
The result is not guaranteed to be accurate; there may be false positives
(directories for which isProject
is non-null but ProjectManagerImplementation.findProject(org.openide.filesystems.FileObject)
will return null), for example if there is trouble loading the project.
False negatives are possible only if there are bugs in the project factory.
Acquires read access.
You do not need to call this method if you just plan to call ProjectManagerImplementation.findProject(org.openide.filesystems.FileObject)
afterwards. It is intended for only those clients which would discard the
result of ProjectManagerImplementation.findProject(org.openide.filesystems.FileObject)
other than to check for null, and which
can also tolerate false positives.
projectDirectory
- a directory which may be some project's top directoryProjectFactory
, or null if not a project folder.IllegalArgumentException
- if the supplied file object is null or not a foldervoid clearNonProjectCache()
@NonNull Set<Project> getModifiedProjects()
Acquires read access.
boolean isModified(@NonNull Project p)
Acquires read access.
p
- a project loaded by this managerboolean isValid(@NonNull Project p)
Acquires read access.
p
- a projectvoid saveProject(@NonNull Project p) throws IOException
Acquires write access.
p
- the project to saveIOException
- if it cannot be savedProjectFactory.saveProject(org.netbeans.api.project.Project)
void saveAllProjects() throws IOException
Acquires write access.
IOException
- if any of them cannot be savedProjectFactory.saveProject(org.netbeans.api.project.Project)