1 11 package org.eclipse.jdt.internal.ui.filters; 12 13 14 import org.eclipse.core.resources.IFolder; 15 import org.eclipse.core.resources.IProject; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IPath; 18 19 import org.eclipse.jface.viewers.Viewer; 20 import org.eclipse.jface.viewers.ViewerFilter; 21 22 import org.eclipse.jdt.core.IClasspathEntry; 23 import org.eclipse.jdt.core.IJavaProject; 24 import org.eclipse.jdt.core.JavaCore; 25 26 27 36 public class OutputFolderFilter extends ViewerFilter { 37 38 46 public boolean select(Viewer viewer, Object parent, Object element) { 47 if (element instanceof IFolder) { 48 IFolder folder= (IFolder)element; 49 IProject proj= folder.getProject(); 50 try { 51 if (!proj.hasNature(JavaCore.NATURE_ID)) 52 return true; 53 54 IJavaProject jProject= JavaCore.create(folder.getProject()); 55 if (jProject == null || !jProject.exists()) 56 return true; 57 58 IPath defaultOutputLocation= jProject.getOutputLocation(); 60 IPath folderPath= folder.getFullPath(); 61 if (defaultOutputLocation != null && defaultOutputLocation.equals(folderPath)) 62 return false; 63 64 IClasspathEntry[] cpEntries= jProject.getRawClasspath(); 66 for (int i= 0, length= cpEntries.length; i < length; i++) { 67 IPath outputLocation= cpEntries[i].getOutputLocation(); 68 if (outputLocation != null && outputLocation.equals(folderPath)) 69 return false; 70 } 71 } catch (CoreException ex) { 72 return true; 73 } 74 } 75 return true; 76 } 77 } 78 | Popular Tags |