upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / internal / ui / filters / NonCProjectsFilter.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 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  *     Anton Leherbauer (Wind River Systems)
11  *******************************************************************************/
12 package org.eclipse.cdt.internal.ui.filters;
13
14
15 import org.eclipse.core.resources.IProject;
16 import org.eclipse.jface.viewers.Viewer;
17 import org.eclipse.jface.viewers.ViewerFilter;
18
19 import org.eclipse.cdt.core.model.CoreModel;
20 import org.eclipse.cdt.core.model.ICProject;
21
22
23 /**
24  * Filters (open) non-C projects.
25  */
26 public class NonCProjectsFilter extends ViewerFilter {
27
28         /*
29          * @see ViewerFilter
30          */
31         @Override
32         public boolean select(Viewer viewer, Object parent, Object element) {
33                 if (element instanceof ICProject) {
34                         return true;
35                 } else if (element instanceof IProject) {
36                         IProject project = (IProject)element;
37                         if (!project.isOpen()) {
38                                 return true;
39                         }
40                         if (CoreModel.hasCNature(project)) {
41                                 return true;
42                         }
43                         return false;
44                 }
45                 return true;
46         }
47 }