upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / internal / ui / workingsets / CElementWorkingSetPageContentProvider.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.workingsets;
13
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.eclipse.core.resources.IProject;
18 import org.eclipse.core.resources.IWorkspaceRoot;
19
20 import org.eclipse.cdt.core.model.CoreModel;
21 import org.eclipse.cdt.core.model.ICProject;
22
23 import org.eclipse.cdt.internal.ui.BaseCElementContentProvider;
24
25 class CElementWorkingSetPageContentProvider extends BaseCElementContentProvider {
26
27         /*
28          * @see org.eclipse.cdt.internal.ui.BaseCElementContentProvider#getChildren(java.lang.Object)
29          */
30         @Override
31         public Object[] getChildren(Object element) {
32                 if (element instanceof IWorkspaceRoot) {
33                         IWorkspaceRoot root = (IWorkspaceRoot)element;
34                         IProject[] projects = root.getProjects();
35                         List<ICProject> list = new ArrayList<ICProject>(projects.length);
36                         for (int i = 0; i < projects.length; i++) {
37                                 if (CoreModel.hasCNature(projects[i])) {
38                                         list.add(CoreModel.getDefault().create(projects[i]));
39                                 }
40                         }
41                         return list.toArray();
42                 }
43                 return super.getChildren(element);
44         }
45 }