public class FileChangesCollection extends Object implements IResourceVisitor, IResourceDeltaVisitor, IFolderFileChangeListener
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.
Modifier and Type | Field and Description |
---|---|
String |
description
The description of the visit.
|
protected IProgressMonitor |
monitor
A progress monitor if not null.
|
protected ProjectManager |
projectManager
The current Project Manager, null for none, to inform file changes.
|
Constructor and Description |
---|
FileChangesCollection(String description,
IFolder[] folders,
ProjectManager projectManager)
Constructs the instance with the specified folders.
|
FileChangesCollection(String description,
ProjectManager projectManager)
Constructs the instance without specified folders.
|
Modifier and Type | Method and Description |
---|---|
IFolder[] |
getFolders()
Gets the folders currently used.
|
MultiStatus |
getMultiStatus()
Gets the MultiStatus instance when visiting, in order to merge errors.
|
protected boolean |
isFileProcessed(IFile file)
Checks if file is processed.
|
boolean |
isProcessed(IResource resource)
Checks if the resource is one of the folders.
|
void |
onFileAdded(IFile file)
File has been added.
|
void |
onFileChanged(IFile file,
int flags)
File has been changed (markers, contents, etc).
|
void |
onFileMoved(IFile newFile,
IFile oldFile)
File has been moved.
|
void |
onFileRemoved(IFile file)
File has been removed.
|
void |
onFolderAdded(IFolder folder)
Folder has been added.
|
void |
onFolderMoved(IFolder newFolder,
IFolder oldFolder)
Folder has been moved.
|
void |
onFolderRemoved(IFolder folder)
Folder has been removed.
|
void |
onNewFolders(IFolder[] folders)
Called when new folders has been assigned, due to e.g.
|
void |
process(IResourceDelta delta)
Processes a delta, it is assumed a check for folder processing
has been done using
isProcessed(folder) prior to
calling this method. |
void |
setMultiStatus(MultiStatus multiStatus)
Assigns a MultiStatus before visit.
|
void |
setNewFolders(IFolder[] folders)
Assigns the folders to process.
|
void |
setProgressMonitor(IProgressMonitor monitor)
Assigns a progress monitor to cancel lengthy job.
|
boolean |
visit(IResource resource)
Called to visit the a resource in one of the processed folders.
|
boolean |
visit(IResourceDelta delta)
Called to visit the delta changes in one of the processed folders.
|
public final String description
protected final ProjectManager projectManager
protected IProgressMonitor monitor
public FileChangesCollection(String description, ProjectManager projectManager)
description
- Description of the visit, if it fails.projectManager
- Instance of Project Manager to inform of changes, null
not to inform...public FileChangesCollection(String description, IFolder[] folders, ProjectManager projectManager)
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...public void setProgressMonitor(IProgressMonitor monitor)
public final void setNewFolders(IFolder[] folders)
public void onNewFolders(IFolder[] folders)
Subclasses should override to process the event, no need to call the
super
method.
folders
- The new folders.public IFolder[] getFolders()
public final boolean isProcessed(IResource resource)
public final void process(IResourceDelta delta) throws CoreException
isProcessed(folder)
prior to
calling this method.delta
- The delta for resources.CoreException
- For visiting errors.public void setMultiStatus(MultiStatus multiStatus)
multiStatus
- The multi-status or null not to use it.public MultiStatus getMultiStatus()
public final boolean visit(IResource resource) throws CoreException
visit
in interface IResourceVisitor
CoreException
- For visiting errors.public final boolean visit(IResourceDelta delta) throws CoreException
visit
in interface IResourceDeltaVisitor
CoreException
- For visiting errors.protected boolean isFileProcessed(IFile file)
Subclasses must check if this resource is to be processed and return true if it's a valid file (typically the file extension).
file
- The file.public void onFileAdded(IFile file) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFileAdded
in interface IFolderFileChangeListener
file
- The file.CoreException
- For failures.public void onFileMoved(IFile newFile, IFile oldFile) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFileMoved
in interface IFolderFileChangeListener
newFile
- The new file.oldFile
- The old file.CoreException
- For failures.public void onFileChanged(IFile file, int flags) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFileChanged
in interface IFolderFileChangeListener
file
- The file.flags
- How the file was changed, from IResourceDelta, where the
important ones are CONTENT, MARKERS, ENCODING, LOCAL_CHANGE,
DERIVED_CHANGED, REPLACED.CoreException
- For failures.public void onFileRemoved(IFile file) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFileRemoved
in interface IFolderFileChangeListener
file
- The file.CoreException
- For failures.public void onFolderAdded(IFolder folder) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFolderAdded
in interface IFolderFileChangeListener
folder
- The folder.CoreException
- For failures.public void onFolderMoved(IFolder newFolder, IFolder oldFolder) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFolderMoved
in interface IFolderFileChangeListener
newFolder
- The new folder.oldFolder
- The old folder.CoreException
- For failures.public void onFolderRemoved(IFolder folder) throws CoreException
Subclasses should override to process the event, no need to call the
super
method.
onFolderRemoved
in interface IFolderFileChangeListener
folder
- The folder.CoreException
- For failures.iizi® is a registered trademark of Mindus SARL. © Copyright Mindus SARL, 2020. All rights reserved.