blob: 7e29e7af95670a87ccd90bd73c0d76ef98cd9323 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*****************************************************************************
* Copyright (c) 2009 Ken Gilmer
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Ken Gilmer - initial API and implementation
*******************************************************************************/
package org.yocto.bc.ui.views;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.yocto.bc.bitbake.BBSession;
import org.yocto.bc.ui.Activator;
import org.yocto.bc.ui.builder.BitbakeCommanderNature;
class RecipeContentProvider implements IStructuredContentProvider {
public void dispose() {
}
public Object[] getElements(Object parent) {
List recipes = new ArrayList();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
IProjectNature nature = null;
for (int i = 0; i < projects.length; ++i) {
try {
if (projects[i].isOpen() && projects[i].hasNature(BitbakeCommanderNature.NATURE_ID)) {
recipes.addAll(getRecipesFromProject(projects[i]));
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return recipes.toArray();
}
private Collection getRecipesFromProject(IProject project) throws Exception {
BBSession session = Activator.getBBSession(project.getLocationURI().getPath(), null);
return session.getRecipeFiles(project);
}
public void inputChanged(Viewer v, Object oldInput, Object newInput) {
}
}
|