@@ -0,0 +1,1708 @@
+/*******************************************************************************%0A * Copyright (c) 2015 Pivotal, Inc.%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A *%0A * Contributors:%0A *     Pivotal, Inc. - initial API and implementation%0A *******************************************************************************/%0Apackage org.springsource.ide.eclipse.commons.frameworks.core.workspace;%0A%0Aimport org.eclipse.core.resources.IProject;%0Aimport org.eclipse.core.resources.IResource;%0Aimport org.eclipse.core.resources.IResourceChangeEvent;%0Aimport org.eclipse.core.resources.IResourceChangeListener;%0Aimport org.eclipse.core.resources.IWorkspace;%0A%0A/**%0A * @author Kris De Volder%0A */%0Apublic class ProjectDeletionListenerManager implements IResourceChangeListener %7B%0A%0A%09public interface ProjectDeletionListener %7B%0A%09%09void projectAboutToBeDeleted(IProject project);%0A%09%7D%0A%0A%09private IWorkspace workspace;%0A%09private ProjectDeletionListener listener;%0A%0A%09public ProjectDeletionListenerManager(IWorkspace workspace, ProjectDeletionListener listener) %7B%0A%09%09this.workspace = workspace;%0A%09%09this.listener = listener;%0A%09%09this.workspace.addResourceChangeListener(this, IResourceChangeEvent.PRE_DELETE);%0A%09%7D%0A%0A%09@Override%0A%09public void resourceChanged(IResourceChangeEvent event) %7B%0A%09%09IResource rsrc = event.getResource();%0A%09%09if (rsrc instanceof IProject) %7B%0A%09%09%09listener.projectAboutToBeDeleted((IProject) rsrc);%0A%09%09%7D%0A%09%7D%0A%0A%09public void dispose() %7B%0A%09%09if (listener!=null) %7B%0A%09%09%09workspace.removeResourceChangeListener(this);%0A%09%09%09listener = null;%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add a reusable adapter to listen for project deletions in workspace