| java.lang.Object org.netbeans.api.project.ProjectManager
ProjectManager | final public class ProjectManager (Code) | | Manages loaded projects.
author: Jesse Glick |
Method Summary | |
public void | clearNonProjectCache() Clear the cached list of folders thought not to be projects.
This may be useful after creating project metadata in a folder, etc.
Cached project objects, i.e. | public Project | findProject(FileObject projectDirectory) Find an open project corresponding to a given project directory.
Will be created in memory if necessary.
Acquires read access.
It is not guaranteed that the returned instance will be identical
to that which is created by the appropriate
ProjectFactory . | public static ProjectManager | getDefault() Returns the singleton project manager instance. | public Set<Project> | getModifiedProjects() Get a list of all projects which are modified and need to be saved. | public boolean | isModified(Project p) Check whether a given project is current modified. | public boolean | isProject(FileObject projectDirectory) Check whether a given directory is likely to contain a project without
actually loading it.
Should be faster and use less memory than
ProjectManager.findProject 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 true but
ProjectManager.findProject will return false), 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
ProjectManager.findProject afterwards. | public boolean | isValid(Project p) Checks whether a project is still valid. | public static Mutex | mutex() Get a read/write lock to be used for all project metadata accesses.
All methods relating to recognizing and loading projects, saving them,
getting or setting their metadata, etc. | void | reset() Clear internal state. | public void | saveAllProjects() Save all modified projects. | public void | saveProject(Project p) Save one project (if it was in fact modified).
Acquires write access.
Although the project infrastructure permits a modified project to be saved
at any time, current UI principles dictate that the "save project" concept
should be internal only - i.e. |
clearNonProjectCache | public void clearNonProjectCache()(Code) | | Clear the cached list of folders thought not to be projects.
This may be useful after creating project metadata in a folder, etc.
Cached project objects, i.e. folders that are known to be
projects, are not affected.
|
findProject | public Project findProject(FileObject projectDirectory) throws IOException, IllegalArgumentException(Code) | | Find an open project corresponding to a given project directory.
Will be created in memory if necessary.
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.
Parameters: projectDirectory - the project top directory the project (object identity may or may not vary between calls)or null if the directory is not recognized as a project by anyregistered ProjectFactory(might be null even if ProjectManager.isProject returns true) throws: IOException - if the project was recognized but could not be loaded throws: IllegalArgumentException - if the supplied file object is null or not a folder |
getDefault | public static ProjectManager getDefault()(Code) | | Returns the singleton project manager instance.
the default instance |
getModifiedProjects | public Set<Project> getModifiedProjects()(Code) | | Get a list of all projects which are modified and need to be saved.
Acquires read access.
an immutable set of projects |
isModified | public boolean isModified(Project p) throws IllegalArgumentException(Code) | | Check whether a given project is current modified.
Acquires read access.
Parameters: p - a project loaded by this manager true if it is modified, false if has been saved since the last modification throws: IllegalArgumentException - if the project was not created through this manager |
isProject | public boolean isProject(FileObject projectDirectory) throws IllegalArgumentException(Code) | | Check whether a given directory is likely to contain a project without
actually loading it.
Should be faster and use less memory than
ProjectManager.findProject 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 true but
ProjectManager.findProject will return false), 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
ProjectManager.findProject afterwards. It is intended for only those clients which would discard the
result of
ProjectManager.findProject other than to check for null, and which
can also tolerate false positives.
Parameters: projectDirectory - a directory which may be some project's top directory true if the directory is likely to contain a project according tosome registered ProjectFactory throws: IllegalArgumentException - if the supplied file object is null or not a folder |
isValid | public boolean isValid(Project p)(Code) | | Checks whether a project is still valid.
Acquires read access.
since: 1.6 Parameters: p - a project loaded by this manager true if the project is still valid, false if it has been deleted |
mutex | public static Mutex mutex()(Code) | | Get a read/write lock to be used for all project metadata accesses.
All methods relating to recognizing and loading projects, saving them,
getting or setting their metadata, etc. should be controlled by this
mutex and be marked as read operations or write operations. Unless
otherwise stated, project-related methods automatically acquire the
mutex for you, so you do not necessarily need to pay attention to it;
but you may directly acquire the mutex in order to ensure that a block
of reads does not have any interspersed writes, or in order to ensure
that a write is not clobbering an unrelated write, etc.
a general read/write lock for project metadata operations of all sorts |
reset | void reset()(Code) | | Clear internal state.
Useful from unit tests.
|
saveAllProjects | public void saveAllProjects() throws IOException(Code) | | Save all modified projects.
Acquires write access.
throws: IOException - if any of them cannot be saved |
saveProject | public void saveProject(Project p) throws IOException, IllegalArgumentException(Code) | | Save one project (if it was in fact modified).
Acquires write access.
Although the project infrastructure permits a modified project to be saved
at any time, current UI principles dictate that the "save project" concept
should be internal only - i.e. a project customizer should automatically
save the project when it is closed e.g. with an "OK" button. Currently there
is no UI display of modified projects; this module does not ensure that modified projects
are saved at system exit time the way modified files are, though the Project UI
implementation module currently does this check.
Parameters: p - the project to save throws: IOException - if it cannot be saved throws: IllegalArgumentException - if the project was not created through this manager |
|
|