Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » How to notice a projects deletion or add
How to notice a projects deletion or add [message #253868] Fri, 18 June 2004 09:17 Go to next message
Eclipse UserFriend
Originally posted by: loemming.gmx.net

Hi,

I am new to ResourceChangeListeners and I was wondering how I can get
notified of a projects deletion or add. Is there any sample code?

I tried with if(event.getKind()==IResourceDelta.REMOVED) but that didnt
work for me.

So I am a bit stucked.

philipp
Re: How to notice a projects deletion or add [message #253902 is a reply to message #253868] Fri, 18 June 2004 10:33 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.NO.SPAM.us.ibm.com

You add a resource change listener with the pre_close and pre_delete mask.

Here is a simple one that I use:

project.getWorkspace().addResourceChangeListener(resourceTra cker,
IResourceChangeEvent.PRE_CLOSE | IResourceChangeEvent.PRE_DELETE);



private class ResourceTracker implements IResourceChangeListener{
public void resourceChanged(IResourceChangeEvent e) {
// About to close or delete the project and it is ours, so we need to
cleanup.
// Performance: It has been noted that dres.equals(...) can be slow
with the number
// of visits done. Checking just the last segment (getName()) first
before checking
// the entire resource provides faster testing. If the last segment is
not equal,
// then the entire resource could not be equal.
IResource eventResource = e.getResource();
if (eventResource.getName().equals(getProject().getName()) &&
eventResource.equals(getProject())) {
cleanup(false);
return;
}
// Note: the BeaninfoModelSynchronizer takes care of both .classpath
and .beaninfoconfig changes
// in this project and any required projects.
}


--
Thanks, Rich Kulp

Previous Topic:How does a plugin contribute jars to a project?
Next Topic:adding classpath to jdk but not acceptable by eclipse
Goto Forum:
  


Current Time: Sat Jul 19 19:17:36 EDT 2025

Powered by FUDForum. Page generated in 0.04629 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top