diff options
Diffstat (limited to 'plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java')
-rw-r--r-- | plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java new file mode 100644 index 0000000..3ab24c0 --- /dev/null +++ b/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/wizards/bsp/YoctoBSPWizard.java | |||
@@ -0,0 +1,99 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010 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 | * Intel - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.remotetools.wizards.bsp; | ||
12 | |||
13 | import java.util.HashSet; | ||
14 | |||
15 | import org.eclipse.jface.dialogs.MessageDialog; | ||
16 | import org.eclipse.jface.wizard.IWizardPage; | ||
17 | import org.eclipse.jface.wizard.Wizard; | ||
18 | import org.yocto.sdk.remotetools.YoctoBspElement; | ||
19 | import org.yocto.sdk.remotetools.YoctoBspPropertyElement; | ||
20 | import org.yocto.sdk.remotetools.YoctoJSONHelper; | ||
21 | |||
22 | /** | ||
23 | * A wizard for creating Yocto BSP. | ||
24 | * | ||
25 | * @author jzhang | ||
26 | * | ||
27 | */ | ||
28 | public class YoctoBSPWizard extends Wizard { | ||
29 | private static final String CREATE_CMD = "/scripts/yocto-bsp create "; | ||
30 | private static final String PROPERTY_VALUE_FILE = "/tmp/propertyvalues.json"; | ||
31 | |||
32 | private MainPage mainPage; | ||
33 | private PropertiesPage propertiesPage; | ||
34 | private final YoctoBspElement bspElem; | ||
35 | |||
36 | public YoctoBSPWizard() { | ||
37 | super(); | ||
38 | bspElem = new YoctoBspElement(); | ||
39 | } | ||
40 | |||
41 | @Override | ||
42 | public IWizardPage getNextPage(IWizardPage page) { | ||
43 | propertiesPage.onEnterPage(mainPage.getBSPElement()); | ||
44 | return propertiesPage; | ||
45 | } | ||
46 | |||
47 | @Override | ||
48 | public void addPages() { | ||
49 | mainPage = new MainPage(bspElem); | ||
50 | addPage(mainPage); | ||
51 | propertiesPage = new PropertiesPage(bspElem); | ||
52 | addPage(propertiesPage); | ||
53 | } | ||
54 | |||
55 | private BSPAction createBSP(){ | ||
56 | YoctoBspElement element = mainPage.getBSPElement(); | ||
57 | String createBspCmd = element.getMetadataLoc() + CREATE_CMD + | ||
58 | element.getBspName() + " " + element.getKarch(); | ||
59 | |||
60 | if (!element.getBspOutLoc().isEmpty()) | ||
61 | createBspCmd = createBspCmd + " -o " + element.getBspOutLoc(); | ||
62 | else | ||
63 | createBspCmd = createBspCmd + " -o " + element.getMetadataLoc() + "/meta-" + element.getBspName(); | ||
64 | createBspCmd = createBspCmd + " -i " + PROPERTY_VALUE_FILE; | ||
65 | |||
66 | BSPProgressDialog progressDialog = new BSPProgressDialog(getShell(), new OutputCollectorThread(createBspCmd), "Creating BSP "); | ||
67 | progressDialog.run(true); | ||
68 | return progressDialog.getBspAction(); | ||
69 | } | ||
70 | |||
71 | @Override | ||
72 | public boolean performFinish() { | ||
73 | if (propertiesPage.validatePage()) { | ||
74 | HashSet<YoctoBspPropertyElement> properties = propertiesPage.getProperties(); | ||
75 | YoctoJSONHelper.createBspJSONFile(properties); | ||
76 | |||
77 | BSPAction createBSPAction = createBSP(); | ||
78 | if (createBSPAction.getMessage() != null && !createBSPAction.getMessage().isEmpty()) { | ||
79 | MessageDialog.openError(getShell(),"Yocto-BSP", createBSPAction.getMessage()); | ||
80 | return false; | ||
81 | } else { | ||
82 | String message = ""; | ||
83 | for (String item : createBSPAction.getItems()) | ||
84 | message += item + "\n"; | ||
85 | MessageDialog.openInformation(getShell(), "Yocto-BSP", message); | ||
86 | return true; | ||
87 | } | ||
88 | } else { | ||
89 | MessageDialog.openError(getShell(), "Yocto-BSP", "Property settings contains error!"); | ||
90 | return false; | ||
91 | } | ||
92 | |||
93 | } | ||
94 | |||
95 | @Override | ||
96 | public boolean canFinish() { | ||
97 | return (mainPage.validatePage() && propertiesPage.validatePage()); | ||
98 | } | ||
99 | } | ||