01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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:
14: import org.eclipse.team.core.RepositoryProvider;
15:
16: import org.eclipse.jface.viewers.Viewer;
17: import org.eclipse.jface.viewers.ViewerFilter;
18:
19: import org.eclipse.jdt.core.IJavaProject;
20:
21: /**
22: * Filters non-shared projects and Java projects. Non-shared projects are
23: * projects that are not controlled by a team provider.
24: *
25: * @since 2.1
26: */
27: public class NonSharedProjectFilter extends ViewerFilter {
28:
29: /*
30: * @see ViewerFilter
31: */
32: public boolean select(Viewer viewer, Object parent, Object element) {
33: if (element instanceof IProject)
34: return isSharedProject((IProject) element);
35:
36: if (element instanceof IJavaProject)
37: return isSharedProject(((IJavaProject) element)
38: .getProject());
39:
40: return true;
41: }
42:
43: private boolean isSharedProject(IProject project) {
44: return !project.isAccessible()
45: || RepositoryProvider.isShared(project);
46: }
47: }
|