diff options
Diffstat (limited to 'plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java')
-rw-r--r-- | plugins/org.yocto.bc.ui/src/org/yocto/bc/ui/wizards/newproject/BBConfigurationInitializeOperation.java | 69 |
1 files changed, 69 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 | *******************************************************************************/ | ||
12 | package org.yocto.bc.ui.wizards.newproject; | ||
13 | |||
14 | import java.io.Writer; | ||
15 | import java.lang.reflect.InvocationTargetException; | ||
16 | |||
17 | import org.eclipse.core.runtime.IProgressMonitor; | ||
18 | import org.eclipse.jface.operation.IRunnableWithProgress; | ||
19 | |||
20 | import org.yocto.bc.bitbake.BBSession; | ||
21 | import org.yocto.bc.bitbake.ProjectInfoHelper; | ||
22 | import org.yocto.bc.ui.Activator; | ||
23 | import org.yocto.bc.ui.model.ProjectInfo; | ||
24 | import org.yocto.remote.utils.RemoteHelper; | ||
25 | |||
26 | public 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 | } | ||