01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.ui.filters;
11:
12: import org.eclipse.core.resources.IProject;
13: import org.eclipse.core.resources.IResource;
14:
15: import org.eclipse.jface.viewers.Viewer;
16: import org.eclipse.jface.viewers.ViewerFilter;
17:
18: import org.eclipse.jdt.core.IPackageFragmentRoot;
19:
20: /**
21: * The LibraryFilter is a filter used to determine whether
22: * a Java internal library is shown
23: */
24: public class ContainedLibraryFilter extends ViewerFilter {
25:
26: /* (non-Javadoc)
27: * Method declared on ViewerFilter.
28: */
29: public boolean select(Viewer viewer, Object parentElement,
30: Object element) {
31: if (element instanceof IPackageFragmentRoot) {
32: IPackageFragmentRoot root = (IPackageFragmentRoot) element;
33: if (root.isArchive()) {
34: // don't filter out JARs contained in the project itself
35: IResource resource = root.getResource();
36: if (resource != null) {
37: IProject jarProject = resource.getProject();
38: IProject container = root.getJavaProject()
39: .getProject();
40: return !container.equals(jarProject);
41: }
42: }
43: }
44: return true;
45: }
46: }
|