KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > imports > BinaryProjectFilter


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.wizards.imports;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.jdt.core.IJavaProject;
15 import org.eclipse.jface.viewers.Viewer;
16 import org.eclipse.jface.viewers.ViewerFilter;
17 import org.eclipse.pde.internal.core.WorkspaceModelManager;
18
19 public class BinaryProjectFilter extends ViewerFilter {
20
21     /**
22      * Returns <code>false</code> if the given element is a binary plug-in/feature project,
23      * and <code>true</code> otherwise.
24      *
25      * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
26      */

27     public boolean select(Viewer viewer, Object JavaDoc parentElement, Object JavaDoc element) {
28         IProject project = null;
29
30         if (element instanceof IJavaProject) {
31             project = ((IJavaProject) element).getProject();
32         } else if (element instanceof IProject) {
33             project = (IProject) element;
34         }
35         if (project != null) {
36             if (WorkspaceModelManager.isPluginProject(project)
37                     || WorkspaceModelManager.isFeatureProject(project)) {
38                 return !WorkspaceModelManager.isBinaryProject(project);
39             }
40         }
41         return true;
42     }
43     
44 }
45
Popular Tags