Class FileChangesCollection

java.lang.Object
com.iizigo.project.FileChangesCollection
All Implemented Interfaces:
IFolderFileChangeListener, IResourceDeltaVisitor, IResourceVisitor
Direct Known Subclasses:
JavaManager

public class FileChangesCollection extends Object implements IResourceVisitor, IResourceDeltaVisitor, IFolderFileChangeListener
Class used to process file changes to create a collection of added, removed or renamed/moved files from a list of folders upon a change in the file system.

The tables addedOrChanged, renamedOrMoved and removed are public, but care should be taken to only work on the snap-shot copy and not the "live" one, otherwise unpredictable results may occur.

Author:
Christopher Mindus
  • Field Details Link icon

    • description Link icon

      public final String description
      The description of the visit.
    • projectManager Link icon

      protected final ProjectManager projectManager
      The current Project Manager, null for none, to inform file changes.
    • monitor Link icon

      protected IProgressMonitor monitor
      A progress monitor if not null.
  • Constructor Details Link icon

    • FileChangesCollection Link icon

      public FileChangesCollection(String description, ProjectManager projectManager)
      Constructs the instance without specified folders.
      Parameters:
      description - Description of the visit, if it fails.
      projectManager - Instance of Project Manager to inform of changes, null not to inform...
    • FileChangesCollection Link icon

      public FileChangesCollection(String description, IFolder[] folders, ProjectManager projectManager)
      Constructs the instance with the specified folders.
      Parameters:
      description - Description of the visit, if it fails.
      folders - The folders to process.
      projectManager - Instance of Project Manager to inform of changes, null not to inform...
  • Method Details Link icon

    • setProgressMonitor Link icon

      public void setProgressMonitor(IProgressMonitor monitor)
      Assigns a progress monitor to cancel lengthy job.
    • setNewFolders Link icon

      public final void setNewFolders(IFolder[] folders)
      Assigns the folders to process.
    • onNewFolders Link icon

      public void onNewFolders(IFolder[] folders)
      Called when new folders has been assigned, due to e.g. Java project settings changed to add/remove a source folder.

      Subclasses should override to process the event, no need to call the super method.

      Parameters:
      folders - The new folders.
    • getFolders Link icon

      public IFolder[] getFolders()
      Gets the folders currently used.
    • isProcessed Link icon

      public final boolean isProcessed(IResource resource)
      Checks if the resource is one of the folders.
    • process Link icon

      public final void process(IResourceDelta delta) throws CoreException
      Processes a delta, it is assumed a check for folder processing has been done using isProcessed(folder) prior to calling this method.
      Parameters:
      delta - The delta for resources.
      Throws:
      CoreException - For visiting errors.
    • setMultiStatus Link icon

      public void setMultiStatus(MultiStatus multiStatus)
      Assigns a MultiStatus before visit. This helps catching the exception into this multiple status that is thrown upon return.
      Parameters:
      multiStatus - The multi-status or null not to use it.
    • getMultiStatus Link icon

      public MultiStatus getMultiStatus()
      Gets the MultiStatus instance when visiting, in order to merge errors.
    • visit Link icon

      public final boolean visit(IResource resource) throws CoreException
      Called to visit the a resource in one of the processed folders.
      Specified by:
      visit in interface IResourceVisitor
      Throws:
      CoreException - For visiting errors.
    • visit Link icon

      public final boolean visit(IResourceDelta delta) throws CoreException
      Called to visit the delta changes in one of the processed folders.
      Specified by:
      visit in interface IResourceDeltaVisitor
      Throws:
      CoreException - For visiting errors.
    • isFileProcessed Link icon

      protected boolean isFileProcessed(IFile file)
      Checks if file is processed.

      Subclasses must check if this resource is to be processed and return true if it's a valid file (typically the file extension).

      Parameters:
      file - The file.
      Returns:
      true if file is to be processed, false otherwise.
    • onFileAdded Link icon

      public void onFileAdded(IFile file) throws CoreException
      File has been added.

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFileAdded in interface IFolderFileChangeListener
      Parameters:
      file - The file.
      Throws:
      CoreException - For failures.
    • onFileMoved Link icon

      public void onFileMoved(IFile newFile, IFile oldFile) throws CoreException
      File has been moved.

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFileMoved in interface IFolderFileChangeListener
      Parameters:
      newFile - The new file.
      oldFile - The old file.
      Throws:
      CoreException - For failures.
    • onFileChanged Link icon

      public void onFileChanged(IFile file, int flags) throws CoreException
      File has been changed (markers, contents, etc).

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFileChanged in interface IFolderFileChangeListener
      Parameters:
      file - The file.
      flags - How the file was changed, from IResourceDelta, where the important ones are CONTENT, MARKERS, ENCODING, LOCAL_CHANGE, DERIVED_CHANGED, REPLACED.
      Throws:
      CoreException - For failures.
    • onFileRemoved Link icon

      public void onFileRemoved(IFile file) throws CoreException
      File has been removed.

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFileRemoved in interface IFolderFileChangeListener
      Parameters:
      file - The file.
      Throws:
      CoreException - For failures.
    • onFolderAdded Link icon

      public void onFolderAdded(IFolder folder) throws CoreException
      Folder has been added.

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFolderAdded in interface IFolderFileChangeListener
      Parameters:
      folder - The folder.
      Throws:
      CoreException - For failures.
    • onFolderMoved Link icon

      public void onFolderMoved(IFolder newFolder, IFolder oldFolder) throws CoreException
      Folder has been moved.

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFolderMoved in interface IFolderFileChangeListener
      Parameters:
      newFolder - The new folder.
      oldFolder - The old folder.
      Throws:
      CoreException - For failures.
    • onFolderRemoved Link icon

      public void onFolderRemoved(IFolder folder) throws CoreException
      Folder has been removed.

      Subclasses should override to process the event, no need to call the super method.

      Specified by:
      onFolderRemoved in interface IFolderFileChangeListener
      Parameters:
      folder - The folder.
      Throws:
      CoreException - For failures.