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.java61
1 files changed, 61 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..2346031
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/views/RecipeContentProvider.java
@@ -0,0 +1,61 @@
1/*****************************************************************************
2 * Copyright (c) 2013 Ken Gilmer, Intel Corporation
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 * Ioana Grigoropol (Intel) - adapt class for remote support
11 *******************************************************************************/
12package org.yocto.bc.ui.views;
13
14import java.util.ArrayList;
15import java.util.Collection;
16import java.util.List;
17
18import org.eclipse.core.resources.IProject;
19import org.eclipse.core.resources.IProjectNature;
20import org.eclipse.core.resources.ResourcesPlugin;
21import org.eclipse.core.runtime.CoreException;
22import org.eclipse.jface.viewers.IStructuredContentProvider;
23import org.eclipse.jface.viewers.Viewer;
24
25import org.yocto.bc.bitbake.BBSession;
26import org.yocto.bc.ui.Activator;
27import org.yocto.bc.ui.builder.BitbakeCommanderNature;
28
29class RecipeContentProvider implements IStructuredContentProvider {
30 public void dispose() {
31 }
32
33 public Object[] getElements(Object parent) {
34 List recipes = new ArrayList();
35 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
36 IProjectNature nature = null;
37 for (int i = 0; i < projects.length; ++i) {
38 try {
39 if (projects[i].isOpen() && projects[i].hasNature(BitbakeCommanderNature.NATURE_ID)) {
40 recipes.addAll(getRecipesFromProject(projects[i]));
41 }
42 } catch (CoreException e) {
43 // TODO Auto-generated catch block
44 e.printStackTrace();
45 } catch (Exception e) {
46 // TODO Auto-generated catch block
47 e.printStackTrace();
48 }
49 }
50
51 return recipes.toArray();
52 }
53
54 private Collection getRecipesFromProject(IProject project) throws Exception {
55 BBSession session = Activator.getBBSession(Activator.getProjInfo(project.getLocationURI()), null);
56 return session.getRecipeFiles(project);
57 }
58
59 public void inputChanged(Viewer v, Object oldInput, Object newInput) {
60 }
61}