mProjectListeners.add(listener);
// we need to look at the opened projects and give them to the listener.
// get the list of opened android projects.
IWorkspaceRoot workspaceRoot = mWorkspace.getRoot();
IJavaModel javaModel = JavaCore.create(workspaceRoot);
IJavaProject[] androidProjects = BaseProjectHelper.getAndroidProjects(javaModel);
for (IJavaProject androidProject : androidProjects) {
listener.projectOpenedWithWorkspace(androidProject.getProject());
}
// notify the event listeners of a start.
for (IResourceEventListener listener : mEventListeners) {
listener.resourceChangeEventStart();
}
if (event.getType() == IResourceChangeEvent.PRE_DELETE) {
// a project is being deleted. Lets get the project object and remove
// its compiled resource list.
IResource r = event.getResource();
IProject project = r.getProject();
// notify the listeners.
for (IProjectListener pl : mProjectListeners) {
pl.projectDeleted(project);
}
} else {
// this a regular resource change. We get the delta and go through it with a visitor.
IResourceDelta delta = event.getDelta();
DeltaVisitor visitor = new DeltaVisitor();
try {
delta.accept(visitor);
} catch (CoreException e) {
}
}
// we're done, notify the event listeners.
for (IResourceEventListener listener : mEventListeners) {
listener.resourceChangeEventEnd();
}