1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.filters;
13 import net.sourceforge.phpdt.core.IClasspathEntry;
14 import net.sourceforge.phpdt.core.IJavaProject;
15 import net.sourceforge.phpdt.core.JavaCore;
16 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
18 import org.eclipse.core.resources.IFolder;
19 import org.eclipse.core.resources.IProject;
20 import org.eclipse.core.runtime.CoreException;
21 import org.eclipse.core.runtime.IPath;
22 import org.eclipse.jface.viewers.Viewer;
23 import org.eclipse.jface.viewers.ViewerFilter;
26 * Filters out all output folders.
28 * Note: Folder which are direct children of a Java element are already filtered
34 public class OutputFolderFilter extends ViewerFilter {
37 * Returns the result of this filter, when applied to the given element.
41 * @return <code>true</code> if element should be included
44 public boolean select(Viewer viewer, Object parent, Object element) {
45 if (element instanceof IFolder) {
46 IFolder folder = (IFolder) element;
47 IProject proj = folder.getProject();
49 if (!proj.hasNature(PHPeclipsePlugin.PHP_NATURE_ID))
52 IJavaProject jProject = JavaCore.create(folder.getProject());
53 if (jProject == null || !jProject.exists())
56 // Check default output location
57 IPath defaultOutputLocation = jProject.getOutputLocation();
58 IPath folderPath = folder.getFullPath();
59 if (defaultOutputLocation != null
60 && defaultOutputLocation.equals(folderPath))
63 // Check output location for each class path entry
64 IClasspathEntry[] cpEntries = jProject.getRawClasspath();
65 for (int i = 0, length = cpEntries.length; i < length; i++) {
66 IPath outputLocation = cpEntries[i].getOutputLocation();
67 if (outputLocation != null
68 && outputLocation.equals(folderPath))
71 } catch (CoreException ex) {