Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » IResourceChangeListener: remove vs workspace close
IResourceChangeListener: remove vs workspace close [message #903144] Wed, 22 August 2012 04:10
Lars Schmidt is currently offline Lars Schmidt
Messages: 1
Registered: August 2012
Junior Member
Hi!

I've implementated an IResourceChangeListener in Eclipse for tracking deleted files. Everything is fine due to one exception: The event is also raised on workspace close. Understandable - the resources are removed. How can I distinguish these events?

Here some code:
IResourceChangeListener listener = new IResourceChangeListener() {
	public void resourceChanged(final IResourceChangeEvent event) {
		IResourceDelta rootDelta = event.getDelta();
		if(rootDelta != null) {
			traverseDelta(rootDelta);
		}
	}
};


private void traverseDelta(final IResourceDelta delta) {
	int kind = delta.getKind();
	if (kind == IResourceDelta.REMOVED) {
		if (delta.getResource() instanceof IFile) {
			final IFile f = (IFile) delta.getResource();
			System.out.println(f.getName() + " deleted. State: " + delta.getFlags());

		} else if (delta.getResource() instanceof IProject) {
			// Method for whole Project
		} else {
			// Method for others
		}
	}

	for (IResourceDelta d : delta.getAffectedChildren()) {
		traverseDelta(d);
	}
}


Any suggestions?

Thank you very much!
Previous Topic:View icons not wrapping in 4.x?
Next Topic:Variable reference in classpath
Goto Forum:
  


Current Time: Mon Jul 28 06:19:07 EDT 2014

Powered by FUDForum. Page generated in 0.01961 seconds