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: import org.eclipse.jdt.internal.ui.packageview.ClassPathContainer;
21:
22: /**
23: * The LibraryFilter is a filter used to determine whether
24: * a Java library is shown
25: */
26: public class LibraryFilter extends ViewerFilter {
27:
28: /* (non-Javadoc)
29: * Method declared on ViewerFilter.
30: */
31: public boolean select(Viewer viewer, Object parentElement,
32: Object element) {
33: if (element instanceof IPackageFragmentRoot) {
34: IPackageFragmentRoot root = (IPackageFragmentRoot) element;
35: if (root.isArchive()) {
36: // don't filter out JARs contained in the project itself
37: IResource resource = root.getResource();
38: if (resource != null) {
39: IProject jarProject = resource.getProject();
40: IProject container = root.getJavaProject()
41: .getProject();
42: return container.equals(jarProject);
43: }
44: return false;
45: }
46: } else if (element instanceof ClassPathContainer.RequiredProjectWrapper) {
47: return false;
48: }
49: return true;
50: }
51: }
|