diff options
Diffstat (limited to 'org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install')
11 files changed, 1656 insertions, 0 deletions
diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/BBCProjectPage.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/BBCProjectPage.java new file mode 100644 index 0000000..a234bca --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/BBCProjectPage.java @@ -0,0 +1,244 @@ +/***************************************************************************** + * 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.openembedded.bc.ui.wizards.install; + +import java.io.File; +import java.util.Hashtable; +import java.util.Map; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.openembedded.bc.ui.wizards.FiniteStateWizardPage; + + +/** + * Main property page for new project wizard. + * @author kgilmer + * + */ +public class BBCProjectPage extends FiniteStateWizardPage { + + private class FileOpenSelectionAdapter extends SelectionAdapter { + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog fd = new FileDialog(PlatformUI.getWorkbench() + .getDisplay().getActiveShell(), SWT.OPEN); + + fd.setText("Open Configuration Script"); + fd.setFilterPath(txtProjectLocation.getText()); + + String selected = fd.open(); + + if (selected != null) { + txtInit.setText(selected); + updateModel(); + } + } + } + public static final String PAGE_TITLE = "BitBake Commander Project"; + public static final String INIT_SCRIPT_KEY = "Init Script"; + public static final String INSTALL_DIRECTORY_KEY = "Install Directory"; + public static final String PROJECT_NAME_KEY = "Project Name"; + + private Text txtProjectLocation; + + private Text txtInit; + private ValidationListener validationListener; + private Text txtProjectName; + + public BBCProjectPage(Map model) { + super(PAGE_TITLE, model); + setMessage("Enter information to create a BitBake Commander project."); + } + + public void createControl(Composite parent) { + GridData gdFillH = new GridData(GridData.FILL_HORIZONTAL); + GridData gdVU = new GridData(GridData.VERTICAL_ALIGN_BEGINNING); + + Composite top = new Composite(parent, SWT.NONE); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + top.setLayout(new GridLayout()); + + Composite projectNameComp = new Composite(top, SWT.NONE); + GridData gdProjName = new GridData(GridData.FILL_HORIZONTAL); + projectNameComp.setLayoutData(gdProjName); + projectNameComp.setLayout(new GridLayout(2, false)); + Label lblProjectName = new Label(projectNameComp, SWT.NONE); + lblProjectName.setText("N&ame:"); + + txtProjectName = new Text(projectNameComp, SWT.BORDER); + txtProjectName.setLayoutData(gdFillH); + txtProjectName.setFocus(); + validationListener = new ValidationListener(); + + txtProjectName.addModifyListener(validationListener); + + Label lblProjectLocation = new Label(projectNameComp, SWT.None); + lblProjectLocation.setText("&Location:"); + + Composite locComposite = new Composite(projectNameComp, SWT.NONE); + GridData gd = new GridData(GridData.VERTICAL_ALIGN_END + | GridData.FILL_HORIZONTAL); + gd.horizontalIndent = 0; + locComposite.setLayoutData(gd); + GridLayout gl = new GridLayout(2, false); + gl.marginWidth = 0; + locComposite.setLayout(gl); + + txtProjectLocation = new Text(locComposite, SWT.BORDER); + txtProjectLocation.setLayoutData(gdFillH); + txtProjectLocation.addModifyListener(validationListener); + + Button button = new Button(locComposite, SWT.PUSH); + button.setText("Browse..."); + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + handleBrowse(); + } + }); + + Label lblInit = new Label(projectNameComp, SWT.NONE); + lblInit.setText("Init Script:"); + + Composite initComposite = new Composite(projectNameComp, SWT.NONE); + gd = new GridData(GridData.VERTICAL_ALIGN_END + | GridData.FILL_HORIZONTAL); + gd.horizontalIndent = 0; + initComposite.setLayoutData(gd); + gl = new GridLayout(2, false); + gl.marginWidth = 0; + initComposite.setLayout(gl); + + txtInit = new Text(initComposite, SWT.BORDER); + GridData gdi = new GridData(GridData.FILL_HORIZONTAL); + txtInit.setLayoutData(gdi); + txtInit.addModifyListener(validationListener); + + Button btnLoadInit = new Button(initComposite, SWT.PUSH); + btnLoadInit.setLayoutData(gdVU); + btnLoadInit.setText("Choose..."); + btnLoadInit.addSelectionListener(new FileOpenSelectionAdapter()); + + if (System.getenv("OEROOT") != null) { + txtProjectLocation.setText(System.getenv("OEROOT")); + } + + setControl(top); + } + + private void handleBrowse() { + DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.None); + String dir = dialog.open(); + if (dir != null) { + txtProjectLocation.setText(dir); + } + } + + private String getFileSegment(String initScriptPath) { + //return the first segment of " " seperated array, or full string if no " " exists + return initScriptPath.split(" ")[0]; + } + + private boolean isValidProjectName(String projectName) { + if (projectName.indexOf('$') > -1) { + return false; + } + + return true; + } + + + @Override + public void pageCleanup() { + + } + + @Override + public void pageDisplay() { + + } + + @Override + protected void updateModel() { + Map props = (Map) model.get(OptionsPage.OPTION_MAP); + + if (props == null) { + props = new Hashtable(); + model.put(OptionsPage.OPTION_MAP, props); + } + + props.put(INIT_SCRIPT_KEY, txtInit.getText()); + props.put(INSTALL_DIRECTORY_KEY, txtProjectLocation.getText()); + props.put(PROJECT_NAME_KEY, txtProjectName.getText()); + } + + + @Override + protected boolean validatePage() { + IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); + + IStatus validate = ResourcesPlugin.getWorkspace().validateName(txtProjectName.getText(), IResource.PROJECT); + + if (!validate.isOK() || !isValidProjectName(txtProjectName.getText())) { + setErrorMessage("Invalid project name: " + txtProjectName.getText()); + return false; + } + + IProject proj = wsroot.getProject(txtProjectName.getText()); + if (proj.exists()) { + setErrorMessage("A project with the name " + txtProjectName.getText() + + " already exists"); + return false; + } + + if (txtProjectLocation.getText().trim().length() == 0) { + setErrorMessage("Set directory to an OpenEmbedded or Poky project root (OEROOT)"); + return false; + } + + File f = new File(txtProjectLocation.getText()); + if (!f.exists() || !f.isDirectory()) { + setErrorMessage("Invalid Directory"); + return false; + } + + if (txtInit.getText().length() == 0) { + setErrorMessage("Set configuration file before bitbake is launched."); + return false; + } + + File f2 = new File(getFileSegment(txtInit.getText())); + if (!f2.exists() || f2.isDirectory()) { + setErrorMessage("The configuration file is invalid."); + return false; + } + + setErrorMessage(null); + + return true; + } +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/BitbakePage.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/BitbakePage.java new file mode 100644 index 0000000..09e58b9 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/BitbakePage.java @@ -0,0 +1,154 @@ +package org.openembedded.bc.ui.wizards.install; + +import java.io.File; +import java.io.IOException; +import java.io.Writer; +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + +import org.eclipse.core.commands.ParameterValueConversionException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.openembedded.bc.ui.Activator; +import org.openembedded.bc.ui.model.ProjectInfo; +import org.openembedded.bc.ui.wizards.FiniteStateWizard; +import org.openembedded.bc.ui.wizards.FiniteStateWizardPage; +import org.openembedded.bc.ui.wizards.importProject.ImportOEProjectWizard; +import org.openembedded.bc.ui.wizards.newproject.BBConfigurationInitializeOperation; + + +/** + * Bitbake console view. + * + * @author kgilmer + * + */ +public class BitbakePage extends FiniteStateWizardPage { + + private boolean valid = false; + + public BitbakePage(Map model) { + super("Bitbake Console Page", model); + setTitle("Extracting BitBake Environment"); + setMessage("Output of 'bitbake -e' command"); + } + + private Text txtConsole; + + @Override + public void createControl(Composite parent) { + Composite top = new Composite(parent, SWT.NONE); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + top.setLayout(new GridLayout()); + + txtConsole = new Text(top, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); + txtConsole.setLayoutData(new GridData(GridData.FILL_BOTH)); + txtConsole.setEditable(false); + txtConsole.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); + + setControl(top); + } + + @Override + public void pageCleanup() { + Activator.resetBBSession((String) model.get(ImportOEProjectWizard.KEY_LOCATION)); + } + + @Override + public void pageDisplay() { + Map props = (Map) model.get(OptionsPage.OPTION_MAP); + + try { + String initPath = InstallJob.substitute((String) props.get(BBCProjectPage.INIT_SCRIPT_KEY), model); + String location = InstallJob.substitute((String) props.get(BBCProjectPage.INSTALL_DIRECTORY_KEY), model); + String name = null; + if (props.containsKey(BBCProjectPage.PROJECT_NAME_KEY)) { + name = InstallJob.substitute((String) props.get(BBCProjectPage.PROJECT_NAME_KEY), model); + } else { + name = parseName((String) props.get("Install Directory")); + } + + ProjectInfo pinfo = new ProjectInfo(); + pinfo.setInitScriptPath(initPath); + pinfo.setLocation(location); + pinfo.setName(name); + + ConsoleWriter cw = new ConsoleWriter(); + this.getContainer().run(false, false, new BBConfigurationInitializeOperation(pinfo, cw)); + txtConsole.setText(cw.getContents()); + valid = true; + model.put(InstallWizard.KEY_PINFO, pinfo); + } catch (InvocationTargetException e) { + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getTargetException().getMessage(), e)); + setErrorMessage("Failed to create project."); + txtConsole.setText(e.getTargetException().getMessage()); + valid = false; + setPageComplete(valid); + return; + } catch (InterruptedException e) { + } catch (ParameterValueConversionException e) { + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); + setErrorMessage("Failed to create project: " + e.getMessage()); + valid = false; + setPageComplete(valid); + return; + } + + setPageComplete(valid); + ((FiniteStateWizard) this.getWizard()).setCanFinish(true); + } + + private String parseName(String name) { + String[] e = name.split(File.separator); + return e[e.length - 1]; + } + + @Override + protected void updateModel() { + + } + + @Override + protected boolean validatePage() { + return valid; + } + + private class ConsoleWriter extends Writer { + + private StringBuffer sb; + + public ConsoleWriter() { + sb = new StringBuffer(); + } + + @Override + public void close() throws IOException { + } + + public String getContents() { + return sb.toString(); + } + + @Override + public void flush() throws IOException { + } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + txtConsole.getText().concat(new String(cbuf)); + } + + @Override + public void write(String str) throws IOException { + sb.append(str); + } + + } + +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/Flavor.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/Flavor.java new file mode 100644 index 0000000..7462047 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/Flavor.java @@ -0,0 +1,50 @@ +/** + * + */ +package org.openembedded.bc.ui.wizards.install; + +import java.io.IOException; + +// # Flavor Label (shows in UI)| description text| image URL| script URL + +/** + * Data class for flavor definition. + * @author kgilmer + * + */ +public class Flavor { + private final String label; + private final String description; + private final String imageURL; + private final String scriptURL; + + public Flavor(String line) throws IOException { + String [] e = line.split("\\|"); + + if (e.length != 4) { + throw new IOException("Invalid flavor line: " + line); + } + + label = e[0]; + description = e[1]; + imageURL = e[2]; + scriptURL = e[3]; + } + + public String getLabel() { + return label; + } + + public String getDescription() { + return description; + } + + public String getImageURL() { + return imageURL; + } + + public String getScriptURL() { + return scriptURL; + } + +}
\ No newline at end of file diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/FlavorPage.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/FlavorPage.java new file mode 100644 index 0000000..db75c98 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/FlavorPage.java @@ -0,0 +1,182 @@ +package org.openembedded.bc.ui.wizards.install; + +import java.io.IOException; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TableColumn; +import org.openembedded.bc.ui.Activator; +import org.openembedded.bc.ui.wizards.FiniteStateWizardPage; + + +/** + * Select which flavor of OE is to be installed. + * + * @author kgilmer + * + */ +public class FlavorPage extends FiniteStateWizardPage { + protected static final String OE_FLAVOR = "FLAVOR"; + protected static final String OE_FLAVOR_TITLE = "OE_FLAVOR_TITLE"; + protected static final String INSTALL_SCRIPT = "INSTALL_SCRIPT"; + + private boolean controlsCreated; + private TableViewer flavorList; + + protected FlavorPage(Map model) { + super("Flavor", model); + setTitle("Select OpenEmbedded Flavor"); + setMessage("Select the flavor of OpenEmbedded you wish to install..."); + } + + + public void createControl(Composite parent) { + Composite top = new Composite(parent, SWT.None); + top.setLayout(new GridLayout()); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + + flavorList = new TableViewer(top, SWT.BORDER); + flavorList.setContentProvider(new FlavorContentProvider()); + flavorList.setLabelProvider(new FlavorLabelProvider()); + flavorList.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); + flavorList.addSelectionChangedListener(new ValidationListener()); + + TableColumn tc = new TableColumn(flavorList.getTable(), SWT.LEFT); + tc.setText("Image"); + tc.setWidth(128); + + tc = new TableColumn(flavorList.getTable(), SWT.LEFT); + tc.setText("Title"); + tc.setWidth(300); + /* + tc = new TableColumn(flavorList.getTable(), SWT.LEFT); + tc.setText("Description"); + tc.setWidth(300);*/ + + + setControl(top); + } + + + public void pageCleanup() { + + } + + + public void pageDisplay() { + getContainer().getShell().setSize(getContainer().getShell().getSize().x, 600); + if (!controlsCreated) { + try { + flavorList.setInput(InstallScriptHelper.getFlavors("scripts/install_flavors.txt")); + controlsCreated = true; + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + + protected void updateModel() { + Flavor f = (Flavor) ((IStructuredSelection) flavorList.getSelection()).getFirstElement(); + model.put(OE_FLAVOR, f); + model.put(OE_FLAVOR_TITLE, f.getLabel()); + try { + model.put(INSTALL_SCRIPT, InstallScriptHelper.loadFile(f.getScriptURL())); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + + protected boolean validatePage() { + return flavorList.getSelection() != null; + } + + private class FlavorContentProvider implements IStructuredContentProvider { + + + public Object[] getElements(Object arg0) { + return ((List) arg0).toArray(); + } + + + public void dispose() { + } + + + public void inputChanged(Viewer arg0, Object arg1, Object arg2) { + } + + } + + private class FlavorLabelProvider implements ITableLabelProvider { + private Map imageMap = new Hashtable(); + + + public Image getColumnImage(Object arg0, int arg1) { + Flavor f = (Flavor) arg0; + Image i = null; + + if (arg1 == 0) { + i = (Image) imageMap.get(f); + if (i == null) { + i = Activator.getImageDescriptor(f.getImageURL()).createImage(); + imageMap.put(f, i); + } + } + + return i; + } + + + public String getColumnText(Object arg0, int arg1) { + Flavor f = (Flavor) arg0; + if (arg1 == 1) { + return f.getLabel(); + } else if (arg1 == 2) { + return f.getDescription(); + } + + return null; + } + + + public void addListener(ILabelProviderListener arg0) { + + } + + + public void dispose() { + // TODO Auto-generated method stub + + } + + + public boolean isLabelProperty(Object arg0, String arg1) { + // TODO Auto-generated method stub + return false; + } + + + public void removeListener(ILabelProviderListener arg0) { + // TODO Auto-generated method stub + + } + + } + +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallJob.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallJob.java new file mode 100644 index 0000000..5b2b0a7 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallJob.java @@ -0,0 +1,170 @@ +/** + * + */ +package org.openembedded.bc.ui.wizards.install; + +import java.io.BufferedReader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.commands.ParameterValueConversionException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.openembedded.bc.bitbake.ICommandResponseHandler; +import org.openembedded.bc.bitbake.ShellSession; +import org.openembedded.bc.ui.Activator; + + +class InstallJob extends Job { + + private final Map mod; + private UICommandResponseHandler cmdOut; + private boolean errorOccurred = false; + private String errorMessage = ""; + + public InstallJob(Map model, ProgressPage progressPage) { + super("Install OpenEmbedded"); + mod = model; + cmdOut = new UICommandResponseHandler(progressPage); + } + + @Override + protected IStatus run(IProgressMonitor monitor) { + BufferedReader reader = new BufferedReader(new StringReader( + (String) mod.get(FlavorPage.INSTALL_SCRIPT))); + String line = null; + Map vars = loadVariables(); + + try { + ShellSession shell = new ShellSession(ShellSession.SHELL_TYPE_BASH, + null, null, null); + while ((line = reader.readLine()) != null && !errorOccurred) { + line = line.trim(); + if (line.length() > 0 && !line.startsWith("#")) { + line = substitute(line, vars); + cmdOut.printCmd(line); + System.out.println("Running: " + line); + shell.execute(line, cmdOut); + } else if (line.startsWith("#")) { + cmdOut.printDialog(line.substring(1).trim()); + } + } + + if (errorOccurred) { + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, + "Failed to install OpenEmbedded: " + errorMessage); + } + } catch (Exception e) { + e.printStackTrace(); + return new Status(IStatus.ERROR, Activator.PLUGIN_ID, + "Failed to install OpenEmbedded", e); + } + + return Status.OK_STATUS; + } + + private Map loadVariables() { + return (Map) mod.get(OptionsPage.OPTION_MAP); + } + + /** + * Return a string with variable substitutions in place. + * + * @param expression + * @return Input string with any substitutions from this file. + * @throws ParameterValueConversionException + */ + public static String substitute(String expression, Map mo) + throws ParameterValueConversionException { + + List vars; + int literals = 0; + + while ((vars = parseVars(expression)).size() > literals) { + for (Iterator i = vars.iterator(); i.hasNext();) { + String varName = (String) i.next(); + String varToken = "${" + varName + "}"; + + if (mo.containsKey(varName)) { + expression = expression.replace(varToken, (String) mo + .get(varName)); + } else if (System.getProperty(varName) != null) { + expression = expression.replace(varToken, System + .getProperty(varName)); + } else if (varName.toUpperCase().equals("HOME")) { + expression = expression.replace(varToken, System + .getProperty("user.home")); + } else { + //throw new ParameterValueConversionException( + // "Unable to match parameter: " + expression); + // Leave the value, treat as a literal. + literals++; + } + } + } + + return expression; + } + + /** + * + * @param line + * @return A list of variables in $[variable name] format. + */ + public static List parseVars(String line) { + List l = new ArrayList(); + + int i = 0; + + while ((i = line.indexOf("${", i)) > -1) { + int i2 = line.indexOf("}", i); + + String var = line.subSequence(i + 2, i2).toString().trim(); + + if (var.length() > 0 && !l.contains(var)) { + l.add(var); + } + i++; + } + + return l; + } + + private class UICommandResponseHandler implements ICommandResponseHandler { + + private final ProgressPage progressPage; + + public UICommandResponseHandler(ProgressPage progressPage) { + this.progressPage = progressPage; + } + + public void printDialog(String msg) { + progressPage.printDialog(msg); + } + + public void response(String line, boolean isError) { + if (isError) { + progressPage.printLine(line, ProgressPage.PRINT_ERR); + //errorOccurred = true; + //errorMessage = line; + } else { + progressPage.printLine(line, ProgressPage.PRINT_OUT); + if (line.endsWith("!!OTEWIZARDSTOP")) { + errorOccurred = true; + errorMessage = line; + } + } + } + + public void printCmd(String cmd) { + progressPage.printLine(cmd, ProgressPage.PRINT_CMD); + } + + } + +}
\ No newline at end of file diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallParameter.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallParameter.java new file mode 100644 index 0000000..517a0fe --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallParameter.java @@ -0,0 +1,99 @@ +/** + * + */ +package org.openembedded.bc.ui.wizards.install; + +class InstallParameter { + public static final int DT_TEXT = 1; + public static final int DT_COMBO = 2; + public static final int DT_LIST = 3; + public static final int DT_NUMBER = 4; + public static final int DT_DIRECTORY = 5; + public static final int DT_FILE = 6; + public static final int DT_CHECKBOX = 7; + + private boolean valid = false; + private int type; + private String label; + private boolean required; + private String data; + private String helpURL; + private String helpText; + + public int getType() { + return type; + } + + public String getLabel() { + return label; + } + + public boolean isRequired() { + return required; + } + + public String getData() { + return data; + } + + public String getHelpURL() { + return helpURL; + } + + public String getHelpText() { + return helpText; + } + + public InstallParameter(String var) { + // {|Datatype|Label|UnRequired|Data|Help|} + // {|T|Distribution|R|angstrom-2008.1|http://wiki.openembedded.net/index.php/Getting_started#Create_local_configuration|} + + String[] elems = var.split("\\|"); + + if (elems.length == 5 || elems.length == 6) { + if (elems[0].equals("T")) { + type = DT_TEXT; + } else if (elems[0].equals("D")) { + type = DT_DIRECTORY; + } else if (elems[0].equals("F")) { + type = DT_FILE; + } else if (elems[0].equals("C")) { + type = DT_COMBO; + } else if (elems[0].equals("B")) { + type = DT_CHECKBOX; + } else { + throw new RuntimeException("Invalid field format: " + var); + } + + label = elems[1]; + + if (elems[2].equals("R")) { + required = true; + } else if (elems[2].equals("U")) { + required = false; + } else { + throw new RuntimeException("Invalid field format: " + var); + } + + data = elems[3].trim(); + + if (elems[4].trim().length() > 0) { + helpURL = elems[4].trim(); + } + + if (elems.length == 6) { + helpText = elems[5]; + } + + valid = true; + } else { + throw new RuntimeException("Invalid field format: " + var); + } + } + + public boolean isValid() { + + return valid; + } + +}
\ No newline at end of file diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallScriptHelper.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallScriptHelper.java new file mode 100644 index 0000000..5225929 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallScriptHelper.java @@ -0,0 +1,52 @@ +package org.openembedded.bc.ui.wizards.install; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.List; + +import org.openembedded.bc.ui.Activator; + + +/** + * Helper for loading install scripts. + * @author kgilmer + * + */ +public class InstallScriptHelper { + + public static List getFlavors(String filePath) throws IOException { + InputStream is = Activator.getDefault().getBundle().getResource(filePath).openStream(); + List list = new ArrayList(); + + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line = null; + + while ((line = br.readLine()) != null) { + line = line.trim(); + + if (line.length() > 0 && !line.startsWith("#")) { + list.add(new Flavor(line)); + } + } + + return list; + } + + public static String loadFile(String fileName) throws IOException { + InputStream is = Activator.getDefault().getBundle().getResource(fileName).openStream(); + + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + String line = null; + StringBuffer sb = new StringBuffer(); + + while ((line = br.readLine()) != null) { + sb.append(line); + sb.append('\n'); + } + + return sb.toString(); + } +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallWizard.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallWizard.java new file mode 100644 index 0000000..2297939 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/InstallWizard.java @@ -0,0 +1,105 @@ +package org.openembedded.bc.ui.wizards.install; + +import java.lang.reflect.InvocationTargetException; +import java.util.Hashtable; +import java.util.Map; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; +import org.openembedded.bc.ui.Activator; +import org.openembedded.bc.ui.model.ProjectInfo; +import org.openembedded.bc.ui.wizards.FiniteStateWizard; +import org.openembedded.bc.ui.wizards.newproject.CreateBBCProjectOperation; + + +/** + * A wizard for installing a fresh copy of an OE system. + * + * @author kgilmer + * + */ +public class InstallWizard extends FiniteStateWizard implements IWorkbenchWizard { + + static final String KEY_PINFO = "KEY_PINFO"; + private Map model; + + public InstallWizard() { + this.model = new Hashtable(); + setWindowTitle("BitBake Commander"); + setNeedsProgressMonitor(false); + setDefaultPageImageDescriptor(Activator.getImageDescriptor("icons/OE_logo_96.png")); + } + + public InstallWizard(IStructuredSelection selection) { + model = new Hashtable(); + } + + /*@Override + public IWizardPage getNextPage(IWizardPage page) { + if (page instanceof WelcomePage) { + if (model.containsKey(WelcomePage.ACTION_USE)) { + return bbcProjectPage; + } + } else if (page instanceof ProgressPage) { + return bitbakePage; + } + + if (super.getNextPage(page) != null) { + System.out.println("next page: " + super.getNextPage(page).getClass().getName()); + } else { + System.out.println("end page"); + } + + return super.getNextPage(page); + } + + @Override + public boolean canFinish() { + System.out.println("can finish: " + super.canFinish()); + return super.canFinish(); + } +*/ + @Override + public void addPages() { + // flavorPage = new FlavorPage(model); + // bitbakePage = new BitbakePage(model); + // bbcProjectPage = new BBCProjectPage(model); + //addPage(new WelcomePage(model)); + addPage(new FlavorPage(model)); + addPage(new OptionsPage(model)); + addPage(new ProgressPage(model)); + //addPage(bbcProjectPage); + addPage(new BitbakePage(model)); + } + + @Override + public Map getModel() { + return model; + } + + @Override + public boolean performFinish() { + ProjectInfo pinfo = (ProjectInfo) model.get(KEY_PINFO); + Activator.putProjInfo(pinfo.getRootPath(), pinfo); + try { + getContainer().run(false, false, new CreateBBCProjectOperation(pinfo)); + } catch (InvocationTargetException e) { + e.printStackTrace(); + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); + this.getContainer().getCurrentPage().setTitle("Failed to create project: " + e.getTargetException().getMessage()); + return false; + } catch (Exception e) { + Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e)); + this.getContainer().getCurrentPage().setTitle("Failed to create project: " + e.getMessage()); + return false; + } + + return true; + } + + public void init(IWorkbench workbench, IStructuredSelection selection) { + } +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/OptionsPage.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/OptionsPage.java new file mode 100644 index 0000000..97115f1 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/OptionsPage.java @@ -0,0 +1,313 @@ +package org.openembedded.bc.ui.wizards.install; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.openembedded.bc.ui.wizards.FiniteStateWizardPage; + + +/** + * Select which flavor of OE is to be installed. + * + * @author kgilmer + * + */ +public class OptionsPage extends FiniteStateWizardPage { + + private Map vars; + private Composite c1; + private Composite top; + protected static final String OPTION_MAP = "OPTION_MAP"; + private static final String DEFAULT_MESSAGE = "Enter these parameters to install."; + private List controlList; + private boolean controlsCreated = false; + + protected OptionsPage(Map model) { + super("Options", model); + setTitle("Installing..."); + setMessage(DEFAULT_MESSAGE); + } + + @Override + public void createControl(Composite parent) { + top = new Composite(parent, SWT.None); + top.setLayout(new GridLayout()); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + + c1 = new Composite(top, SWT.None); + c1.setLayout(new GridLayout(3, false)); + c1.setLayoutData(new GridData(GridData.FILL_BOTH)); + + setControl(top); + } + + private void createControls(Composite comp, Map v, List cl) { + ValidationListener listener = new ValidationListener(); + + for (Iterator i = v.keySet().iterator(); i.hasNext();) { + + String label = (String) i.next(); + final InstallParameter ip = (InstallParameter) v.get(label); + + if (ip.getType() != InstallParameter.DT_CHECKBOX) { + Label title = new Label(comp, SWT.None); + title.setText(ip.getLabel() + ": "); + if (ip.getHelpText() != null) { + title.setToolTipText(ip.getHelpText()); + } + } else { + //If we are creating checkbox, layout differently. + new Label(comp, SWT.None); + } + + Control toolTipControl = null; + switch (ip.getType()) { + case InstallParameter.DT_TEXT: + Text field = new Text(comp, SWT.BORDER); + field.setData(ip); + field.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + field.addModifyListener(listener); + field.setText(ip.getData()); + cl.add(field); + toolTipControl = field; + break; + case InstallParameter.DT_DIRECTORY: + Composite locComposite = new Composite(comp, SWT.NONE); + GridData gd = new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_HORIZONTAL); + gd.horizontalIndent = 0; + locComposite.setLayoutData(gd); + GridLayout gl = new GridLayout(2, false); + gl.marginWidth = 0; + locComposite.setLayout(gl); + + final Text location = new Text(locComposite, SWT.BORDER); + location.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + location.setText(ip.getData()); + location.addModifyListener(listener); + location.setData(ip); + toolTipControl = location; + cl.add(location); + + Button button = new Button(locComposite, SWT.PUSH); + button.setText("..."); + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + DirectoryDialog fd = new DirectoryDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.OPEN); + + fd.setText(ip.getLabel()); + + String selected = fd.open(); + + if (selected != null) { + location.setText(selected); + // updateModel(); + } + } + }); + break; + case InstallParameter.DT_FILE: + Composite fileComposite = new Composite(comp, SWT.NONE); + gd = new GridData(GridData.VERTICAL_ALIGN_END | GridData.FILL_HORIZONTAL); + gd.horizontalIndent = 0; + fileComposite.setLayoutData(gd); + gl = new GridLayout(2, false); + gl.marginWidth = 0; + fileComposite.setLayout(gl); + + final Text fileLocation = new Text(fileComposite, SWT.BORDER); + fileLocation.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + fileLocation.setText(ip.getData()); + fileLocation.addModifyListener(listener); + fileLocation.setData(ip); + toolTipControl = fileLocation; + cl.add(fileLocation); + + button = new Button(fileComposite, SWT.PUSH); + button.setText("..."); + button.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog fd = new FileDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.OPEN); + + fd.setText(ip.getLabel()); + + String selected = fd.open(); + + if (selected != null) { + fileLocation.setText(selected); + // updateModel(); + } + } + }); + break; + case InstallParameter.DT_COMBO: + Combo cfield = new Combo(comp, SWT.READ_ONLY); + cfield.setData(ip); + // cfield.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + cfield.addModifyListener(listener); + cfield.setItems(ip.getData().split(",")); + cfield.setText(ip.getData().split(",")[0]); + toolTipControl = cfield; + cl.add(cfield); + break; + case InstallParameter.DT_CHECKBOX: + Button bfield = new Button(comp, SWT.CHECK); + bfield.setData(ip); + bfield.setText(ip.getLabel()); + // bfield.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + bfield.addSelectionListener(listener); + if (ip.getData().trim().toUpperCase().equals("TRUE")) { + bfield.setSelection(true); + } + toolTipControl = bfield; + cl.add(bfield); + break; + default: + throw new RuntimeException("Unknown or unimplemented field: " + ip.getType()); + } + + // Setup tool tips and wizard help. + if (toolTipControl != null) { + if (ip.getHelpText() != null) { + toolTipControl.setToolTipText(ip.getHelpText()); + toolTipControl.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + } + + public void focusGained(FocusEvent e) { + setMessage(ip.getHelpText()); + } + }); + } else { + toolTipControl.addFocusListener(new FocusListener() { + + public void focusLost(FocusEvent e) { + } + + public void focusGained(FocusEvent e) { + setMessage(DEFAULT_MESSAGE); + ; + } + }); + } + } + + // Create a hyperlink to help content if exists, or invisible label if not. + if (ip.getHelpURL() != null) { + Link l = new Link(comp, SWT.None); + l.setText("<a>Help...</a>"); + l.addSelectionListener(new SelectionListener() { + + public void widgetSelected(SelectionEvent e) { + org.eclipse.swt.program.Program.launch(ip.getHelpURL()); + } + + public void widgetDefaultSelected(SelectionEvent e) { + // TODO Auto-generated method stub + + } + }); + } else { + new Label(comp, SWT.None); + } + } + } + + @Override + public void pageCleanup() { + + } + + @Override + public void pageDisplay() { + if (!controlsCreated) { + controlList = new ArrayList(); + + vars = parseVars((String) model.get(FlavorPage.INSTALL_SCRIPT)); + + createControls(c1, vars, controlList); + c1.layout(); + + controlsCreated = true; + setTitle(((String) model.get(FlavorPage.OE_FLAVOR_TITLE)).trim() + " Options"); + } + updateModel(); + } + + public static Map parseVars(String line) { + Map l = new LinkedHashMap(); + + int i = 0; + + while ((i = line.indexOf("{|", i)) > -1) { + int i2 = line.indexOf("|}", i); + + String var = line.subSequence(i + 2, i2).toString().trim(); + + if (var.length() > 0) { + InstallParameter ip = new InstallParameter(var + " "); + + if (ip.isValid() && !l.containsKey(ip.getLabel())) { + l.put(ip.getLabel(), ip); + } + } + i++; + } + + return l; + } + + @Override + protected void updateModel() { + Map m = new Hashtable(); + + for (Iterator i = controlList.iterator(); i.hasNext();) { + Control t = (Control) i.next(); + String val = null; + InstallParameter ip = (InstallParameter) t.getData(); + + if (t instanceof Text) { + val = ((Text) t).getText(); + } else if (t instanceof Combo) { + val = ((Combo) t).getText(); + } else if (t instanceof Button) { + val = Boolean.toString(((Button) t).getSelection()); + } else { + throw new RuntimeException("Unknown control type: " + t.getClass().getName()); + } + + m.put(ip.getLabel(), val); + } + model.put(OPTION_MAP, m); + } + + @Override + protected boolean validatePage() { + return true; + } + +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/ProgressPage.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/ProgressPage.java new file mode 100644 index 0000000..6a54a6b --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/ProgressPage.java @@ -0,0 +1,191 @@ +package org.openembedded.bc.ui.wizards.install; + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.StringReader; +import java.util.Map; + +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.IJobChangeListener; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.ProgressBar; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.PlatformUI; +import org.openembedded.bc.ui.wizards.FiniteStateWizardPage; + + +/** + * Select which flavor of OE is to be installed. + * @author kgilmer + * + */ +public class ProgressPage extends FiniteStateWizardPage { + + private static final String STARTED_INSTALL = "STARTED_INSTALL"; + private Text txtConsole; + private StringBuffer consoleBuffer; + private ProgressBar pbProgress; + private String lastError; + + protected static final int PRINT_CMD = 1; + protected static final int PRINT_OUT = 2; + protected static final int PRINT_ERR = 3; + + protected ProgressPage(Map model) { + super("Progress", model); + setTitle("Installing OpenEmbedded"); + setMessage(""); + } + + public void createControl(Composite parent) { + Composite top = new Composite(parent, SWT.None); + top.setLayout(new GridLayout()); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + + txtConsole = new Text(top, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); + txtConsole.setLayoutData(new GridData(GridData.FILL_BOTH)); + txtConsole.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT)); + txtConsole.setEditable(false); + + Label s = new Label(top, SWT.SEPARATOR | SWT.HORIZONTAL); + s.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + pbProgress = new ProgressBar(top, SWT.HORIZONTAL | SWT.BORDER); + + setControl(top); + } + + protected void printLine(String line, final int type) { + if (consoleBuffer == null) { + consoleBuffer = new StringBuffer(); + } + + if (type == PRINT_CMD) { + consoleBuffer.append("$ "); + } else if (type == PRINT_ERR) { + consoleBuffer.append("ERROR: "); + lastError = line; + } + + consoleBuffer.append(line); + consoleBuffer.append('\n'); + + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + + + public void run() { + txtConsole.setText(consoleBuffer.toString()); + txtConsole.setSelection(txtConsole.getText().length() - 1); + + if (type == PRINT_CMD) { + pbProgress.setSelection(pbProgress.getSelection() + 1); + } + } + + }); + } + + public void pageCleanup() { + + } + + public void pageDisplay() { + if (!model.containsKey(STARTED_INSTALL)) { + model.put(STARTED_INSTALL, new Boolean(true)); + + try { + pbProgress.setMaximum(getLineCount((String) model.get(FlavorPage.INSTALL_SCRIPT))); + } catch (IOException e) { + //TODO add logging here. + e.printStackTrace(); + return; + } + + executeInstall(); + } + } + + private int getLineCount(String str) throws IOException { + int count = 0; + + BufferedReader br = new BufferedReader(new StringReader(str)); + + while (br.readLine() != null) { + count++; + } + + return count; + } + + private void executeInstall() { + InstallJob j = new InstallJob(model, this); + j.addJobChangeListener(new IJobChangeListener() { + + public void aboutToRun(IJobChangeEvent event) { + } + + + public void awake(IJobChangeEvent event) { + } + + + public void done(final IJobChangeEvent event) { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + + + public void run() { + if (event.getResult().isOK()) { + setMessage("Installation complete, next is to load into workspace."); + pbProgress.setVisible(false); + setPageComplete(true); + } else { + setErrorMessage("An error occurred while installing OpenEmbedded:\n" + lastError); + } + } + + }); + } + + public void running(IJobChangeEvent event) { + } + + + public void scheduled(IJobChangeEvent event) { + } + + + public void sleeping(IJobChangeEvent event) { + } + + }); + setMessage("Installing OpenEmbedded..."); + j.schedule(); + } + + + protected void updateModel() { + } + + + protected boolean validatePage() { + + return true; + } + + public void printDialog(final String msg) { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + + + public void run() { + setMessage(msg); + } + }); + } + +} diff --git a/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/WelcomePage.java b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/WelcomePage.java new file mode 100644 index 0000000..cbb4317 --- /dev/null +++ b/org.openembedded.bc.ui/src/org/openembedded/bc/ui/wizards/install/WelcomePage.java @@ -0,0 +1,96 @@ +package org.openembedded.bc.ui.wizards.install; + +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.openembedded.bc.ui.wizards.FiniteStateWizardPage; + + +public class WelcomePage extends FiniteStateWizardPage { + + public static final String ACTION_INSTALL = "ACTION_INSTALL"; + public static final String ACTION_USE = "ACTION_USE"; + private Button installButton; + private Button useButton; + + protected WelcomePage(Map model) { + super("Introduction", model); + setTitle("Select Project Type"); + } + + @Override + public void createControl(Composite parent) { + Composite top = new Composite(parent, SWT.None); + top.setLayout(new GridLayout()); + top.setLayoutData(new GridData(GridData.FILL_BOTH)); + + ValidationListener listener = new ValidationListener(); + + installButton = new Button(top, SWT.RADIO | SWT.WRAP); + installButton.setText("Install a flavor of OpenEmbedded on your computer."); + Composite lc = new Composite(top, SWT.None); + lc.setLayout(new GridLayout(2, false)); + lc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Label spacer = new Label(lc, SWT.None); + spacer.setText(" "); + Label installLabel = new Label(lc, SWT.WRAP); + installLabel.setText( + "This will install a flavor of OpenEmbedded in your Eclipse workspace. It is the " + + "recommended option for new projects in Eclipse." + ); + installLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + installButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + installButton.addSelectionListener(listener); + + useButton = new Button(top, SWT.RADIO | SWT.WRAP); + useButton.setText("Use an existing local copy of OpenEmbedded."); + lc = new Composite(top, SWT.None); + lc.setLayout(new GridLayout(2, false)); + lc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + spacer = new Label(lc, SWT.None); + spacer.setText(" "); + installLabel = new Label(lc, SWT.WRAP); + installLabel.setText( + "A working install " + + "of a flavor of OpenEmbedded is required. An init script will need to be selected to initialize " + + "the environment."); + installLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + useButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + useButton.addSelectionListener(listener); + + setControl(top); + } + + @Override + public void pageCleanup() { + } + + @Override + public void pageDisplay() { + setMessage("Choose to install a new instance or an existing one."); + } + + @Override + protected void updateModel() { + model.remove(ACTION_INSTALL); + model.remove(ACTION_USE); + + if (installButton.getSelection()) { + model.put(ACTION_INSTALL, ACTION_INSTALL); + } else if (useButton.getSelection()) { + model.put(ACTION_USE, ACTION_USE); + } + } + + @Override + protected boolean validatePage() { + return useButton.getSelection() || installButton.getSelection(); + } +} |