How can I correctly distinguish inside the IResourceChangeListener that is added via ResourcePlugin.getWorkspace().addResourceChangeListener(...) that the project has been deleted / renamed?
Having tried, it would seem that IResourceChangeEvent.getDelta() -> IResourceDelta will be the answer.
From the Eclipse API :
Sequential periodic reports of arbitrary creations, deletions, and changes to one or more resources, expressed as a hierarchical resource delta. The event type is POST_CHANGE, and getDelta returns a hierarchical delta. The resource delta is embedded in the root workspace. These events are relayed to stakeholders after a set of resource changes and occur regardless of whether auto-processing is enabled. The workspace is closed for change at the time of notification of these Events. The delta reported in this event loop is identical to all listeners registered for this type of event.
EDIT: adding my results so far
So, Event.getType() is POST_CHANGE , and should be either
delta containing a child of IResourceDelta that has getKind() == REMOVED for deletion, and delta getResource().getType() == PROJECT so that we know it as a project (this IResourceDelta should not have children)
a getDelta() , which contains two child IResourceDelta , which have getKind() == REMOVED and getKind() == ADDED , also getResource().getType() == PROJECT , and those IResourceDelta do not contain child Deltas (I noticed that when a file is renamed / deleted, the IProject resource belongs to the one in the first line of the children of the parent Delta ...)
Can anyone confirm this assumption? Is it really necessary to search for the depth of the tree for children to implement if the event has a rename / delete project or file / folder?
source share