I have a requirement to close an open IFile in editor if it is deleted in Project Explorer.
As I understand IResourceChangeListener can be used to listens to changes in project workspace but how can I get the perticular file which has been deleted.
event.getResource() returns a IProject being changed it seems .
How can I locate the file which has been deleted and close that file in editor if its open?
Best How To :
A resource change event usually contains information about changes to all related resources. For a file change this will be the file, parent folders and the project. The
getResource method of
IResourceChangeEvent just returns you the top most resource that has been changed.
IResourceDelta returned by
getDelta contains the full set of resources that the resource change event covers:
IResourceDelta delta = event.getDelta();
You can search the delta for a particular file with:
IResourceDelta fileDelta = delta.findMember(file.getFullPath());
You can also use the
accept method to call a 'visitor' on each resource.