summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java')
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
new file mode 100644
index 0000000..7e29e7a
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
@@ -0,0 +1,60 @@
1/*****************************************************************************
2 * Copyright (c) 2009 Ken Gilmer
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 * Ken Gilmer - initial API and implementation
10 *******************************************************************************/
11package org.yocto.bc.ui.views;
12
13import java.util.ArrayList;
14import java.util.Collection;
15import java.util.List;
16
17import org.eclipse.core.resources.IProject;
18import org.eclipse.core.resources.IProjectNature;
19import org.eclipse.core.resources.ResourcesPlugin;
20import org.eclipse.core.runtime.CoreException;
21import org.eclipse.jface.viewers.IStructuredContentProvider;
22import org.eclipse.jface.viewers.Viewer;
23
24import org.yocto.bc.bitbake.BBSession;
25import org.yocto.bc.ui.Activator;
26import org.yocto.bc.ui.builder.BitbakeCommanderNature;
27
28class RecipeContentProvider implements IStructuredContentProvider {
29 public void dispose() {
30 }
31
32 public Object[] getElements(Object parent) {
33 List recipes = new ArrayList();
34 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
35 IProjectNature nature = null;
36 for (int i = 0; i < projects.length; ++i) {
37 try {
38 if (projects[i].isOpen() && projects[i].hasNature(BitbakeCommanderNature.NATURE_ID)) {
39 recipes.addAll(getRecipesFromProject(projects[i]));
40 }
41 } catch (CoreException e) {
42 // TODO Auto-generated catch block
43 e.printStackTrace();
44 } catch (Exception e) {
45 // TODO Auto-generated catch block
46 e.printStackTrace();
47 }
48 }
49
50 return recipes.toArray();
51 }
52
53 private Collection getRecipesFromProject(IProject project) throws Exception {
54 BBSession session = Activator.getBBSession(project.getLocationURI().getPath(), null);
55 return session.getRecipeFiles(project);
56 }
57
58 public void inputChanged(Viewer v, Object oldInput, Object newInput) {
59 }
60} \ No newline at end of file