Interface ProjectManagerImplementation


public interface ProjectManagerImplementation
The SPI class for ProjectManager.
Since:
1.59
  • Method Details

    • init

      Configures ProjectManagerImplementation. Called before the ProjectManager starts to use the implementation.
      Parameters:
      callBack - the callBack
    • getMutex

      @NonNull org.openide.util.Mutex getMutex()
      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.
      Returns:
      a general read/write lock for project metadata operations of all sorts
    • getMutex

      @NonNull org.openide.util.Mutex getMutex(boolean autoSave, @NonNull Project project, @NonNull Project... otherProjects)
      Get a read/write lock to be used for project metadata accesses. The returned lock may be optimized to limit contention only on given project(s).
      Parameters:
      autoSave - if true the other most write operation automatically saves the passed project(s)
      project - the project to lock
      otherProjects - other projects to lock
      Returns:
      a general read/write lock for project metadata operations
    • findProject

      @CheckForNull Project findProject(@NonNull org.openide.filesystems.FileObject projectDirectory) throws IOException, IllegalArgumentException
      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
      Returns:
      the project (object identity may or may not vary between calls) or null if the directory is not recognized as a project by any registered ProjectFactory (might be null even if isProject(org.openide.filesystems.FileObject) returns true)
      Throws:
      IOException - if the project was recognized but could not be loaded
      IllegalArgumentException - if the supplied file object is null or not a folder
    • isProject

      @CheckForNull ProjectManager.Result isProject(@NonNull org.openide.filesystems.FileObject projectDirectory) throws IllegalArgumentException
      Check whether a given directory is likely to contain a project without actually loading it. The returned ProjectManager.Result object contains additional information about the found project. Should be faster and use less memory than 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 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 findProject(org.openide.filesystems.FileObject) afterwards. It is intended for only those clients which would discard the result of findProject(org.openide.filesystems.FileObject) 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
      Returns:
      Result object if the directory is likely to contain a project according to some registered ProjectFactory, or null if not a project folder.
      Throws:
      IllegalArgumentException - if the supplied file object is null or not a folder
    • clearNonProjectCache

      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. folders that are known to be projects, are not affected.
    • getModifiedProjects

      @NonNull Set<Project> getModifiedProjects()
      Get a list of all projects which are modified and need to be saved.

      Acquires read access.

      Returns:
      an immutable set of projects
    • isModified

      boolean isModified(@NonNull Project p)
      Check whether a given project is current modified.

      Acquires read access.

      Parameters:
      p - a project loaded by this manager
      Returns:
      true if it is modified, false if has been saved since the last modification
    • isValid

      boolean isValid(@NonNull Project p)
      Checks whether a project is still valid.

      Acquires read access.

      Parameters:
      p - a project
      Returns:
      true if the project is still valid, false if it has been deleted
    • saveProject

      void saveProject(@NonNull Project p) throws IOException
      Save one project (if it was in fact modified).

      Acquires write access.

      Parameters:
      p - the project to save
      Throws:
      IOException - if it cannot be saved
      See Also:
    • saveAllProjects

      void saveAllProjects() throws IOException
      Save all modified projects.

      Acquires write access.

      Throws:
      IOException - if any of them cannot be saved
      See Also: