summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject')
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java69
-rw-r--r--plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java93
2 files changed, 162 insertions, 0 deletions
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
new file mode 100644
index 0000000..c44b7b5
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java
@@ -0,0 +1,69 @@
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.wizards.newproject;
13
14import java.io.Writer;
15import java.lang.reflect.InvocationTargetException;
16
17import org.eclipse.core.runtime.IProgressMonitor;
18import org.eclipse.jface.operation.IRunnableWithProgress;
19
20import org.yocto.bc.bitbake.BBSession;
21import org.yocto.bc.bitbake.ProjectInfoHelper;
22import org.yocto.bc.ui.Activator;
23import org.yocto.bc.ui.model.ProjectInfo;
24import org.yocto.remote.utils.RemoteHelper;
25
26public class BBConfigurationInitializeOperation implements IRunnableWithProgress {
27
28 private final ProjectInfo pinfo;
29 private final Writer writer;
30 private boolean errorOccured = false;
31 private String errorMessage = "";
32
33 public BBConfigurationInitializeOperation(ProjectInfo pinfo) {
34 this.pinfo = pinfo;
35 writer = null;
36 }
37 public boolean hasErrorOccured() {
38 return errorOccured;
39 }
40 public BBConfigurationInitializeOperation(ProjectInfo pinfo, Writer writer) {
41 this.pinfo = pinfo;
42 this.writer = writer;
43 }
44
45 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
46 BBSession session;
47 try {
48 System.out.println("Initialize bitbake session ...");
49 monitor.beginTask("Initialize bitbake session ...", RemoteHelper.TOTALWORKLOAD);
50 session = Activator.getBBSession(pinfo, writer, monitor);
51 session.initialize();
52 monitor.worked(90);
53 monitor.done();
54 errorOccured = session.hasErrorOccured();
55 errorMessage = session.getErrorLines();
56 if (!errorOccured) {
57 System.out.println("Bitbake session initialized successfully.");
58 errorMessage = "";
59 } else
60 System.out.println("An error occured and Bitbake session was not initialized.");
61 } catch (Exception e) {
62 throw new InvocationTargetException(e);
63 }
64 }
65
66 public String getErrorMessage() {
67 return errorMessage;
68 }
69}
diff --git a/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
new file mode 100644
index 0000000..54f16c3
--- /dev/null
+++ b/plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/CreateBBCProjectOperation.java
@@ -0,0 +1,93 @@
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.wizards.newproject;
13
14import java.io.IOException;
15import java.lang.reflect.InvocationTargetException;
16import java.net.URI;
17import java.net.URISyntaxException;
18import java.util.Arrays;
19import java.util.Vector;
20
21import org.eclipse.core.resources.IProject;
22import org.eclipse.core.resources.IProjectDescription;
23import org.eclipse.core.resources.IWorkspace;
24import org.eclipse.core.resources.IWorkspaceRoot;
25import org.eclipse.core.resources.ResourcesPlugin;
26import org.eclipse.core.runtime.CoreException;
27import org.eclipse.core.runtime.IProgressMonitor;
28import org.eclipse.core.runtime.IStatus;
29import org.eclipse.core.runtime.QualifiedName;
30import org.eclipse.core.runtime.Status;
31import org.eclipse.ui.actions.WorkspaceModifyOperation;
32
33import org.yocto.bc.bitbake.ProjectInfoHelper;
34import org.yocto.bc.ui.Activator;
35import org.yocto.bc.ui.builder.BitbakeCommanderNature;
36import org.yocto.bc.ui.model.ProjectInfo;
37
38
39/**
40 * Creates a bbc project
41 * @author kgilmer
42 *
43 */
44public class CreateBBCProjectOperation extends WorkspaceModifyOperation {
45
46 public static final String OEFS_SCHEME = "OEFS://";
47 public static final QualifiedName BBC_PROJECT_INIT = new QualifiedName(null, "BBC_PROJECT_INIT");
48 public static void addNatureToProject(IProject proj, String nature_id, IProgressMonitor monitor) throws CoreException {
49 IProjectDescription desc = proj.getDescription();
50 Vector natureIds = new Vector();
51
52 natureIds.add(nature_id);
53 natureIds.addAll(Arrays.asList(desc.getNatureIds()));
54 desc.setNatureIds((String[]) natureIds.toArray(new String[natureIds.size()]));
55
56 proj.setDescription(desc, monitor);
57 }
58
59 private ProjectInfo projInfo;
60
61 public CreateBBCProjectOperation(ProjectInfo projInfo) {
62 this.projInfo = projInfo;
63 }
64
65 protected void addNatures(IProject proj, IProgressMonitor monitor) throws CoreException {
66 addNatureToProject(proj, BitbakeCommanderNature.NATURE_ID, monitor);
67 }
68
69 private IProjectDescription createProjectDescription(IWorkspace workspace, ProjectInfo projInfo) throws CoreException {
70 IProjectDescription desc = workspace.newProjectDescription(projInfo.getProjectName());
71
72 desc.setLocationURI(projInfo.getOEFSURI());
73 return desc;
74 }
75
76 @Override
77 protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
78 IProjectDescription desc = createProjectDescription(ResourcesPlugin.getWorkspace(), projInfo);
79
80 IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot();
81
82 IProject proj = wsroot.getProject(projInfo.getProjectName());
83 proj.create(desc, monitor);
84
85 proj.open(monitor);
86
87 addNatures(proj, monitor);
88 }
89
90 public ProjectInfo getProjectInfo() {
91 return projInfo;
92 }
93}