Bug 17618 Changing output location should delete all derived resources
F1 1) create a project (autobuild on) 2) import Java sources and resources 3) change output folder to project/bin ->all class files are removed (fine) 4) change output folder back to be the project -> all class files are removed (fine) 5) open project/bin -> all resources are still there Note: When opening the properties dialog on such a resource it is tagged as "Derived". Thus, it should be possible to remove all derived resources as long as they have been created by the Java builder.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/BuildPathsBlock.java
}
			}
		}
		return false;
	}
	
	public static void removeOldClassfiles(IResource resource) throws CoreException {
		if (resource.isDerived() && "class".equals(resource.getFileExtension())) { 
			resource.delete(false, null);
		}
		if (resource instanceof IContainer) {
			IResource[] members= ((IContainer) resource).members();
			for (int i= 0; i < members.length; i++) {
				removeOldClassfiles(members[i]);
			}
		}
	}
	
	public static IRemoveOldBinariesQuery getRemoveOldBinariesQuery(final Shell shell) {
		return new IRemoveOldBinariesQuery() {
			public boolean doQuery(final IPath oldOutputLocation) throws InterruptedException {
				final int[] res= new int[] { 1 };
				shell.getDisplay().syncExec(new Runnable() {
					public void run() {
						String title= NewWizardMessages.getString("BuildPathsBlock.RemoveBinariesDialog.title"); 
						String message= NewWizardMessages.getFormattedString("BuildPathsBlock.RemoveBinariesDialog.description", oldOutputLocation.toString()); 
						MessageDialog dialog= new MessageDialog(shell, title, null, message, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL }, 2);
						res[0]= dialog.open();
					}
				});