[Esbox-commits] r868 - in branches/sdkPlugins/maemosdk: org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1 org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/internal org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/provider org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/preferences org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2 org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/internal org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/provider org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/preferences org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard

baranov at garage.maemo.org baranov at garage.maemo.org
Tue Oct 14 10:11:53 EEST 2008


Author: baranov
Date: 2008-10-14 10:11:52 +0300 (Tue, 14 Oct 2008)
New Revision: 868

Added:
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/AbstractSB1Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/CreateTargetCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetCurrentTargetCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetGdbQemuCommandPatternCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetVersionScratchboxCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/KillallCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCompilersCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCputranspCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListDevkitsCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListSessionsCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListTargetsCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RemoveTargetCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ResetTargetCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RootstrapCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/SelectTargetCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ShowTargetCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/IScratchbox1SDK.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/SB1PreferenceConstants.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1FileSystemMapping.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDK.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDKTarget.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/internal/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/internal/Activator.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1EnvironmentProvider.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncher.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncherFactory.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/ScratchboxTargetSwitcher.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/provider/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/provider/Scratchbox1SDKProvider.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/preferences/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/preferences/Scratchbox1PreferencesPage.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/NewScratchbox1TargetWizard.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/TargetWizardDevkitsPage.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/AbstractSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateMaemoRootstrapSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateTargetSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetCurrentTargetSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetGdbQemuCommandPatternCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetMaemoRootstrapLocationCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetVersionScratchboxCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCompilersSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCputranspSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListTargetsCommand.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/MaemoRootstrapSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveMaemoRootstrapSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveTargetSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ShowPathMappingSb2Command.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/IScratchbox2SDK.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/SB2PreferenceConstants.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2FileSystemMapping.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDK.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDKTarget.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/internal/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/internal/Activator.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2EnvironmentProvider.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncher.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncherFactory.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/provider/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/provider/Scratchbox2SDKProvider.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/preferences/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/preferences/Scratchbox2PreferencesPage.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/NewScratchbox2TargetWizard.java
   branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java
Log:
add missing files

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/AbstractSB1Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/AbstractSB1Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/AbstractSB1Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.security.InvalidParameterException;
+
+import org.maemo.esbox.maemosdk.core.command.AbstractSDKCommand;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * @author baranov
+ * 
+ */
+public abstract class AbstractSB1Command extends AbstractSDKCommand {
+
+	/**
+	 * @param commandAbstractor
+	 */
+	public AbstractSB1Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		// TODO Auto-generated constructor stub
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.command.AbstractSDKCommand#
+	 * replaceScratchboxConfigCommand(java.lang.String, java.lang.String[])
+	 */
+	public String replaceScratchboxConfigCommand(String action, String[] options)
+			throws InvalidParameterException {
+		String sboxCommand;
+
+		sboxCommand = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SBOX_COMMAND);
+
+		return replaceScratchboxCommand(sboxCommand, action, options);
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/CreateTargetCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/CreateTargetCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/CreateTargetCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Creates a new target, if it does not exist. This command wraps the callback
+ * to service sb-conf setup [<TARGET>] [--compiler=<COMPILER>]
+ * [--devkits=<LIST>] [--cputransp=<METHOD>] [--force]
+ * 
+ */
+public class CreateTargetCommand extends AbstractSB1Command {
+
+	private IScratchbox1SDK sdk;
+
+	public CreateTargetCommand(IScratchbox1SDK sdk,
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param) throws ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String compilerName = param.get(1);
+		String devkitsNames = param.get(2);
+		String cputranspName = param.get(3);
+
+		String setupTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_ACT);
+
+		String[] setupActionOptionsReplaced = this.replaceActions(targetName,
+				compilerName, devkitsNames, cputranspName);
+		String setupTargetCommand = this.replaceScratchboxConfigCommand(
+				setupTargetAction, setupActionOptionsReplaced);
+
+		Process process = createProcess(setupTargetCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	/**
+	 * Replace the options of action SETUP. The options of SETUP action are
+	 * different from the other ones, so this method replaces the variables
+	 * properly.
+	 * 
+	 * @param targetName
+	 *            the name of the target.
+	 * 
+	 * @param compiler
+	 *            the compiler name of the target.
+	 * @param devkits
+	 *            the devkits of the target.
+	 * @param cputransp
+	 *            the cputransp method of the target.
+	 * @return an array of String with the options already modified with the
+	 *         options.
+	 */
+	protected String[] replaceActions(String targetName, String compiler,
+			String devkits, String cputransp) {
+		String[] setupActions = new String[4];
+		setupActions[0] = targetName;
+		setupActions[1] = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_OPT_COMPILER);
+		setupActions[2] = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_OPT_DEVKITS);
+		setupActions[3] = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SETUP_OPT_CPUTRANSP);
+
+		setupActions[1] = setupActions[1].replaceAll("\\$\\{COMPILER\\}",
+				compiler);
+		setupActions[2] = setupActions[2].replaceAll("\\$\\{LIST\\}", devkits);
+		setupActions[3] = setupActions[3].replaceAll("\\$\\{METHOD\\}",
+				cputransp);
+
+		return setupActions;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 4;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetCurrentTargetCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetCurrentTargetCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetCurrentTargetCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Get the current Scratchbox 1 target. This command wraps the callback to
+ * service sb-conf current
+ */
+public class GetCurrentTargetCommand extends AbstractSB1Command {
+
+	private final IScratchbox1SDK sdk;
+
+	public GetCurrentTargetCommand(ICommandAbstractor commandAbstractor,
+			IScratchbox1SDK sdk) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		if (sdk.getCachedCurrentTarget() != null)
+			return sdk.getCachedCurrentTarget();
+
+		String currentTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_CURRENT_ACT);
+		String currentTargetCommand = this
+				.replaceScratchboxConfigCommand(currentTargetAction);
+
+		Process process = createProcess(currentTargetCommand, null);
+
+		String currentTarget = getInputFromProcessAndWait(process, true, 0);
+
+		sdk.setCachedCurrentTarget(currentTarget);
+		return currentTarget;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetGdbQemuCommandPatternCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetGdbQemuCommandPatternCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetGdbQemuCommandPatternCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IStatus;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDKTarget;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+import org.osgi.framework.Version;
+
+/**
+ * Get the command pattern for launching qemu with the debugger
+ * 
+ * @author eswartz
+ * 
+ */
+public class GetGdbQemuCommandPatternCommand extends AbstractSB1Command {
+
+	private Scratchbox1SDKTarget sdkTarget;
+
+	public GetGdbQemuCommandPatternCommand(Scratchbox1SDKTarget sdkTarget,
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String commandPattern = null;
+
+		String architecture = param.get(0);
+
+		if (architecture.equals(IScratchboxSDKTarget.ARCHITECTURE_ARMEL)) {
+			// scratchbox often misconfigures the softlinks, so explicitly
+			// launch the qemu configured for the target
+			String qemu = getConfiguredQemu();
+			if (qemu == null) {
+				// fallback
+				Activator
+						.getErrorLogger()
+						.log(
+								IStatus.WARNING,
+								"Target "
+										+ sdkTarget
+										+ " does not seem to use qemu, so assuming qemu-arm for debugging",
+								null);
+				qemu = "qemu-arm";
+			}
+			// get the version
+			Version version = null;
+			Pattern versionPattern = Pattern
+					.compile("qemu-.*((\\d+)\\.(\\d+)\\.(\\d+))-.*");
+			Matcher matcher = versionPattern.matcher(qemu);
+			if (matcher.matches()) {
+				version = new Version(matcher.group(1));
+			}
+
+			// For ARM emulator debug, use "qemu-arm" command.
+			commandPattern = sdkTarget
+					.getPreferenceValue(SB1PreferenceConstants.SB1_GDB_REMOTE_QEMU);
+
+			if (version != null && version.compareTo(new Version(0, 8, 0)) < 0) {
+				// hide ${PORT}, which doesn't exist in 0.7.x
+				commandPattern = commandPattern.replace("${PORT}", "");
+				// Activator.getErrorLogger().log(IStatus.WARNING,
+				// "The version of qemu-arm in use (" + version +
+				// ") is too old -- debugging may not work.  Check your softlinks in /scratchbox/devkits/cputransp/bin/.",
+				// null);
+			}
+
+			commandPattern = commandPattern.replace("${QEMU}", qemu);
+
+		} else {
+			// The others, just standard "gdbserver" command.
+			commandPattern = sdkTarget
+					.getPreferenceValue(MaemoPreferenceConstants.SBOX_GDB_REMOTE);
+		}
+
+		return commandPattern;
+	}
+
+	/**
+	 * Find what qemu is configured for this target.
+	 * 
+	 * @return qemu name, or <code>null</code> if not using qemu
+	 */
+	protected String getConfiguredQemu() throws ESboxException {
+
+		// we use sb-select show <target> to find out if qemu is even used for
+		// this target.
+		String showAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SHOW_ACT);
+		String showInfoCommandString = this.replaceScratchboxConfigCommand(
+				showAction, new String[] { sdkTarget.getName() });
+
+		Process process = createProcess(showInfoCommandString, null);
+
+		List<String> lines = getLineInputFromProcessAndWait(process, true, 0);
+
+		// see if this is the line describing CPU transparency
+		Pattern namePattern = Pattern.compile(".*/(qemu-\\S+).*");
+		for (String line : lines) {
+			Matcher matcher = namePattern.matcher(line);
+			if (matcher.matches()) {
+				return matcher.group(1);
+			}
+		}
+
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 1;
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetVersionScratchboxCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetVersionScratchboxCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/GetVersionScratchboxCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Get the version of Scratchbox installed. This command wraps the callback to
+ * service sb-conf version.
+ * 
+ */
+public class GetVersionScratchboxCommand extends AbstractSB1Command {
+
+	public GetVersionScratchboxCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.ScratchboxCommand#getParametersSize()
+	 */
+	public int getParametersSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .util.List)
+	 */
+	public String performCommand(List<String> params)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String sboxVersionAction;
+		sboxVersionAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_VERSION_ACT);
+		String currentSboxVersionCommand = this
+				.replaceScratchboxConfigCommand(sboxVersionAction);
+
+		Process process = createProcess(currentSboxVersionCommand, null);
+
+		String currentVersion = getInputFromProcessAndWait(process, false, 0);
+
+		return currentVersion;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/KillallCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/KillallCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/KillallCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Kill all Scratchbox sessions. This command wraps the callback to service
+ * sb-conf killall [-signal=<SIGNAL>]
+ * 
+ */
+public class KillallCommand extends AbstractSB1Command {
+
+	public KillallCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String signalValue = "";
+		if (param.size() > 0)
+			signalValue = param.get(0);
+
+		String killallAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_KILLALL_ACT);
+		String signalOption = this.replaceSignal(signalValue);
+		String killallCommand = this.replaceScratchboxConfigCommand(
+				killallAction, new String[] { signalOption });
+
+		Process process = createProcess(killallCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		return true;
+	}
+
+	/**
+	 * Replace the value of SIGNAL option of killall action.
+	 * 
+	 * @param signalValue
+	 *            the value of the signal to be replaced.
+	 * @return the signal option of killall action replaced with the given
+	 *         signal value.
+	 */
+	private String replaceSignal(String signalValue) {
+		if (signalValue.equals(""))
+			return "";
+		String killallSignalOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_KILLALL_OPT_SIGNAL);
+
+		String signalReplaced = killallSignalOption.replaceAll(
+				"\\$\\{SIGNAL\\}", signalValue);
+
+		return signalReplaced;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 1;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.command.ScratchboxCommand#checkParameters
+	 * (java.util.List)
+	 */
+	protected boolean checkParameters(List<String> param) {
+		// TODO Auto-generated method stub
+		return getParametersSize() <= 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCompilersCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCompilersCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCompilersCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * List the installed compilers. This command wraps the callback to service
+ * sb-conf list --compilers
+ * 
+ */
+public class ListCompilersCommand extends AbstractSB1Command {
+
+	public ListCompilersCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String compilersOptions = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_COMPILERS);
+		String listCompilersCommand = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { compilersOptions });
+
+		Process process = createProcess(listCompilersCommand, null);
+
+		List<String> compilersAvailable = getLineInputFromProcessAndWait(
+				process, true, 0);
+
+		return compilersAvailable;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.command.ScratchboxCommand#getParametersSize
+	 * ()
+	 */
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCputranspCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCputranspCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListCputranspCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * List the installed cpu-transparency. This command wraps the callback to
+ * service sb-conf list --cputransps
+ * 
+ */
+public class ListCputranspCommand extends AbstractSB1Command {
+
+	public ListCputranspCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String cputranpOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_CPU);
+		String listCputranspsCommandString = this
+				.replaceScratchboxConfigCommand(listAction,
+						new String[] { cputranpOption });
+
+		Process process = createProcess(listCputranspsCommandString, null);
+
+		List<String> cputranspsAvailable = getLineInputFromProcessAndWait(
+				process, true, 0);
+
+		return cputranspsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListDevkitsCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListDevkitsCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListDevkitsCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * List the installed devkits. This command wraps the callback to service
+ * sb-conf list --devkits
+ * 
+ */
+public class ListDevkitsCommand extends AbstractSB1Command {
+
+	public ListDevkitsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String devkitsOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_DEVKITS);
+		String listDevkitsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { devkitsOption });
+
+		Process process = createProcess(listDevkitsCommandString, null);
+
+		List<String> devkitsAvailable = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		return devkitsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListSessionsCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListSessionsCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListSessionsCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * List the current Scratchbox sessions. This command wraps the callback to
+ * service sb-conf list --sessions
+ * 
+ */
+public class ListSessionsCommand extends AbstractSB1Command {
+
+	public ListSessionsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		String sessionsOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_SESSIONS);
+		String listSessionsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { sessionsOption });
+
+		Process process = createProcess(listSessionsCommandString, null);
+
+		List<String> sessionLines = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		List<String> sessionsAvailable = new ArrayList<String>();
+
+		// remove prefix text
+		for (String line : sessionLines) {
+			int idx = line.indexOf(':');
+			if (idx >= 0) {
+				String[] pids = line.substring(idx + 1).split("\\s+");
+				for (String pid : pids) {
+					pid = pid.trim();
+					if (pid.length() > 0)
+						sessionsAvailable.add(pid);
+				}
+			}
+		}
+
+		return sessionsAvailable;
+	}
+
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListTargetsCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListTargetsCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ListTargetsCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * List the installed targets. This command wraps the callback to service (sb1)
+ * sb-conf list --targets or sb2-config -l (sb2)
+ * 
+ */
+public class ListTargetsCommand extends AbstractSB1Command {
+
+	public ListTargetsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction;
+		String targetsOption;
+		listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_ACT);
+		targetsOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LIST_OPT_TARGETS);
+		String listTargetsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { targetsOption });
+
+		Process process = createProcess(listTargetsCommandString, null);
+
+		List<String> targetsAvailable = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		return targetsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RemoveTargetCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RemoveTargetCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RemoveTargetCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.sdk.ISDK;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Remove a Scratchbox target. This command wraps the callback to service
+ * sb-conf remove [<TARGET>]
+ * 
+ */
+public class RemoveTargetCommand extends AbstractSB1Command {
+
+	private ISDK sdk;
+
+	public RemoveTargetCommand(ISDK sdk, ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetToRemove = param.get(0);
+		if (!targetExist(targetToRemove))
+			throw new ScratchboxInvalidParameterException("Target "
+					+ targetToRemove + " does not exist.");
+
+		String removeTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_REMOVE_ACT);
+		String forceRemoveTargetOption = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_REMOVE_OPT_FORCE);
+		String removeTargetCommand = this.replaceScratchboxConfigCommand(
+				removeTargetAction, new String[] { targetToRemove,
+						forceRemoveTargetOption });
+
+		Process process = createProcess(removeTargetCommand, null);
+
+		getInputFromProcessAndWait(process, true, 0);
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	/**
+	 * Verify if a target exists.
+	 * 
+	 * @param targetToRemove
+	 *            the target to verify.
+	 * 
+	 * @return true, if the target exists in Scratchbox; false, otherwise.
+	 * @throws ScratchboxException
+	 *             if some problem occurrs while requesting Scratchbox services.
+	 */
+	private boolean targetExist(String targetToRemove) throws ESboxException {
+		List<String> targetsAvailable = new ListTargetsCommand(
+				commandAbstractor).performCommand(new ArrayList<String>());
+		return targetsAvailable.contains(targetToRemove);
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ResetTargetCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ResetTargetCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ResetTargetCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Reset a Scratchbox target. This command wraps the callback to service sb-conf
+ * reset [<TARGET>]
+ * 
+ */
+public class ResetTargetCommand extends AbstractSB1Command {
+
+	public ResetTargetCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .util.List)
+	 */
+	public Object performCommand(List<String> params)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String resetTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_RESET_ACT);
+		String resetTargetCommand = this.replaceScratchboxConfigCommand(
+				resetTargetAction, new String[] {});
+
+		Process process = createProcess(resetTargetCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RootstrapCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RootstrapCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/RootstrapCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * This command wraps the callback to service sb-conf rootstrap [<TARGET>]
+ * <FILE>|<URL>
+ */
+public class RootstrapCommand extends AbstractSB1Command {
+
+	public RootstrapCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String fileOrURL = param.get(0);
+
+		String rootstrapAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_ROOTSTRAP_ACT);
+		String rootstrapCommand = this.replaceScratchboxConfigCommand(
+				rootstrapAction, new String[] { fileOrURL });
+
+		Process process = createProcess(rootstrapCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/SelectTargetCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/SelectTargetCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/SelectTargetCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Select a Scratchbox target. This command wraps the callback to service
+ * sb-conf select [<TARGET>]
+ * 
+ */
+public class SelectTargetCommand extends AbstractSB1Command {
+
+	private final IScratchboxSDK sdk;
+
+	public SelectTargetCommand(ICommandAbstractor commandAbstractor,
+			IScratchboxSDK sdk) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetToSelect = param.get(0);
+
+		String selectTargetAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SELECT_ACT);
+		String selectTargetCommand = this.replaceScratchboxConfigCommand(
+				selectTargetAction, new String[] { targetToSelect });
+
+		Process process = createProcess(selectTargetCommand, null);
+
+		getInputFromProcessAndWait(process, false, 0);
+
+		sdk.setCachedCurrentTarget(targetToSelect);
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ShowTargetCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ShowTargetCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/command/ShowTargetCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.command;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxTarget;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+
+/**
+ * Show the settings of a Scratchbox target. This command wraps the callback to
+ * service sb-conf show [<TARGET>]
+ * 
+ */
+public class ShowTargetCommand extends AbstractSB1Command {
+
+	public ShowTargetCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.core.internal.command.ICommand#performCommand(java.util
+	 * .List)
+	 */
+	public ScratchboxTarget performCommand(List<String> params)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction = commandAbstractor
+				.getPreferenceValue(SB1PreferenceConstants.SB1_SHOW_ACT);
+		String showTargetCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { params.get(0) });
+
+		Process process = createProcess(showTargetCommandString, null);
+
+		ScratchboxTarget target = null;
+		List<String> targetInfo = getLineInputFromProcessAndWait(process,
+				false, 0);
+		target = createTarget(params.get(0), targetInfo);
+
+		return target;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.core.scratchbox.internal.command.ScratchboxCommand#
+	 * getParametersSize()
+	 */
+	@Override
+	public int getParametersSize() {
+		// TODO Auto-generated method stub
+		return 1;
+	}
+
+	private ScratchboxTarget createTarget(String targetName,
+			List<String> targetInfo) {
+		ScratchboxTarget target = new ScratchboxTarget();
+
+		target.setName(targetName);
+
+		String compilerField = targetInfo.get(0);
+		String compiler = compilerField.substring(
+				compilerField.indexOf(":") + 1).trim();
+		target.setCompiler(compiler);
+
+		String devkitsField = targetInfo.get(1);
+		devkitsField = devkitsField.substring(devkitsField.indexOf(":") + 1);
+		StringTokenizer tokens = new StringTokenizer(devkitsField);
+		List<String> devkits = new ArrayList<String>();
+		while (tokens.hasMoreTokens()) {
+			devkits.add(tokens.nextToken());
+		}
+		target.setDevkits(devkits);
+
+		String cputranspField = targetInfo.get(2);
+		String cpuTransp = cputranspField.substring(
+				cputranspField.indexOf(":") + 1).trim();
+		target.setCputransp(cpuTransp);
+
+		return target;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/IScratchbox1SDK.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/IScratchbox1SDK.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/IScratchbox1SDK.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.core;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+
+/**
+ * @author baranov
+ * 
+ */
+public interface IScratchbox1SDK extends IScratchboxSDK {
+	public static final String NAME = "Scratchbox 1";
+
+	/**
+	 * Return the list of available devkits at Scratchbox.
+	 * 
+	 * @return a list with the available devkits at Scratchbox.
+	 * @throws ESboxException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public List<String> getDevkits() throws ESboxException;
+
+	/**
+	 * Return the current sessions of Scratchbox.
+	 * 
+	 * @return a list with current sessions Scratchbox.
+	 * @throws ESboxException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public List<String> getSessions() throws ESboxException;
+
+	/**
+	 * Select another available target as current Scratchbox target.
+	 * 
+	 * @param targetName
+	 *            the name of the new target.
+	 * @return true, if the operation is performed successfully.
+	 * @throws ESboxException
+	 *             if the target to be selected does not exists or if some
+	 *             problem related to Scratchbox communication occurs.
+	 */
+	public boolean selectTarget(String targetName) throws ESboxException;
+
+	/**
+	 * Kill an Scratchbox process.
+	 * 
+	 * @return true, if the is performed successfully.
+	 * @throws ESboxException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean killProcess() throws ESboxException;
+
+	/**
+	 * Kill an Scratchbox process.
+	 * 
+	 * @param signal
+	 *            the signal emitted to scratchbox processes.
+	 * @return true, if the is performed successfully.
+	 * @throws ESboxException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean killProcess(String signal) throws ESboxException;
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/SB1PreferenceConstants.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/SB1PreferenceConstants.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/SB1PreferenceConstants.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb1.core;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+
+/**
+ * This class encapsulates the keys for preference constants defined by
+ * Scratchbox 1.
+ * 
+ * @author eswartz
+ * 
+ */
+public class SB1PreferenceConstants {
+	public static final int VERSION_MAJOR = 17;
+	public static final int VERSION_MINOR = 0;
+
+	/** Get the preference store that contains these preferences */
+	public static IPreferenceStore getPreferenceStore() {
+		return Activator.getDefault().getPreferenceStore();
+	}
+
+	/* SB1 configuration options */
+
+	public static final String RUN_SCRIPT_LOC = "RUN_SCRIPT_LOC";
+
+	public static final String SB1_GDB_REMOTE_QEMU = "SB1_GDB_REMOTE_QEMU";
+	public static final String SB1_CURRENT_ACT = "SB1_CURRENT_ACT";
+	public static final String SB1_SBOX_COMMAND = "SB1_SBOX_COMMAND";
+	public static final String SB1_REMOVE_ACT = "SB1_REMOVE_ACT";
+	public static final String SB1_REMOVE_OPT_FORCE = "SB1_REMOVE_OPT_FORCE";
+	public static final String SB1_RESET_ACT = "SB1_RESET_ACT";
+	public static final String SB1_ROOTSTRAP_ACT = "SB1_ROOTSTRAP_ACT";
+	public static final String SB1_ROOTSTRAP_OPT_FORCE = "SB1_ROOTSTRAP_OPT_FORCE";
+	public static final String SB1_INSTALL_ACT = "SB1_INSTALL_ACT";
+	public static final String SB1_INSTALL_OPT_CLIB = "SB1_INSTALL_OPT_CLIB";
+	public static final String SB1_INSTALL_OPT_DEVKITS = "SB1_INSTALL_OPT_DEVKITS";
+	public static final String SB1_INSTALL_OPT_ETC = "SB1_INSTALL_OPT_ETC";
+	public static final String SB1_INSTALL_OPT_FAKE = "SB1_INSTALL_OPT_FAKE";
+	public static final String SB1_INSTALL_OPT_GDB = "SB1_INSTALL_OPT_GDB";
+	public static final String SB1_INSTALL_OPT_STRACE = "SB1_INSTALL_OPT_STRACE";
+	public static final String SB1_KILLALL_ACT = "SB1_KILLALL_ACT";
+	public static final String SB1_KILLALL_OPT_SIGNAL = "SB1_KILLALL_OPT_SIGNAL";
+	public static final String SB1_LIST_ACT = "SB1_LIST_ACT";
+	public static final String SB1_LIST_OPT_COMPILERS = "SB1_LIST_OPT_COMPILERS";
+	public static final String SB1_LIST_OPT_CPU = "SB1_LIST_OPT_CPU";
+	public static final String SB1_LIST_OPT_DEVKITS = "SB1_LIST_OPT_DEVKITS";
+	public static final String SB1_LIST_OPT_SESSIONS = "SB1_LIST_OPT_SESSIONS";
+	public static final String SB1_LIST_OPT_TARGETS = "SB1_LIST_OPT_TARGETS";
+	public static final String SB1_LOGIN_COMMAND = "SB1_LOGIN_COMMAND";
+	public static final String SB1_SBOX_SANDBOX = "SB1_SBOX_SANDBOX";
+	public static final String SB1_SELECT_ACT = "SB1_SELECT_ACT";
+	public static final String SB1_SETUP_ACT = "SB1_SETUP_ACT";
+	public static final String SB1_SETUP_OPT_COMPILER = "SB1_SETUP_OPT_COMPILER";
+	public static final String SB1_SETUP_OPT_CPUTRANSP = "SB1_SETUP_OPT_CPUTRANSP";
+	public static final String SB1_SETUP_OPT_DEVKITS = "SB1_SETUP_OPT_DEVKITS";
+	public static final String SB1_SETUP_OPT_FORCE = "SB1_SETUP_OPT_FORCE";
+	public static final String SB1_SHOW_ACT = "SB1_SHOW_ACT";
+	public static final String SB1_SHOW_OPT_COMP_ARCH = "SB1_SHOW_OPT_COMP_ARCH";
+	public static final String SB1_SHOW_OPT_COMP_CLIB = "SB1_SHOW_OPT_COMP_CLIB";
+	public static final String SB1_SHOW_OPT_COMP_SUBARCH = "SB1_SHOW_OPT_COMP_SUBARCH";
+	public static final String SB1_SHOW_OPT_COMPILERS = "SB1_SHOW_OPT_COMPILERS";
+	public static final String SB1_SHOW_OPT_CPU = "SB1_SHOW_OPT_CPU";
+	public static final String SB1_SHOW_OPT_DEVKITS = "SB1_SHOW_OPT_DEVKITS";
+	public static final String SB1_VERSION_ACT = "SB1_VERSION_ACT";
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1FileSystemMapping.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1FileSystemMapping.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1FileSystemMapping.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,70 @@
+/**
+ * (c) 2008 Nokia
+ */
+package org.maemo.esbox.maemosdk.sb1.core;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.internal.api.core.machine.FileSystemMapping;
+
+import com.nokia.cpp.internal.api.utils.core.Pair;
+
+/**
+ * Represent the mappings from the machine to a Scratchbox 1 target running on
+ * the machine. This represents the direct mappings with all softlinks resolved
+ * (so, not "/scratchbox/users/user/usr" but
+ * "/scratchbox/users/user/targets/CHINOOK_ARMEL/usr")
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1FileSystemMapping extends FileSystemMapping {
+
+	/**
+	 * Construct with default Linux path canonicalizers and add mappings for
+	 * paths known to be mapped.
+	 * 
+	 * @param targetRoot
+	 * @param target
+	 */
+	public Scratchbox1FileSystemMapping(IPath scratchboxBase, String target,
+			String user) {
+
+		super(FileSystemMapping.getMachineCanonicalizer(true),
+				FileSystemMapping.getMachineCanonicalizer(true));
+
+		List<Pair<IPath, IPath>> mappings = getHostToTargetRootMappings();
+		mappings.clear();
+
+		// directories that are the same for all targets
+		String[] topLevelDirs = { "dev", "home", "host_usr", "proc",
+				"scratchbox", "sys", "targets" };
+
+		IPath sharedBase = scratchboxBase;
+		map(mappings, sharedBase, new Path("/"));
+		for (String topLevelDir : topLevelDirs) {
+			map(mappings, sharedBase.append(topLevelDir), new Path(topLevelDir)
+					.makeAbsolute());
+		}
+
+		// directories that depend on the current target
+		String[] topLevelLinks = { "bin", "boot", "cdrom", "etc", "floppy",
+				"initrd", "lib", "media", "mnt", "opt", "root", "sbin", "srv",
+				"usr", "var" };
+
+		IPath perTargetBase = scratchboxBase.append("targets").append(target);
+		for (String topLevelDir : topLevelLinks) {
+			map(mappings, perTargetBase.append(topLevelDir), new Path(
+					topLevelDir).makeAbsolute());
+		}
+
+		setHostToTargetRootMappings(mappings);
+	}
+
+	private void map(List<Pair<IPath, IPath>> mappings, IPath from, IPath to) {
+		mappings.add(new Pair<IPath, IPath>(from, to));
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDK.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDK.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDK.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.machine.IMachine;
+import org.maemo.esbox.core.sdk.IPreferenceProvider;
+import org.maemo.esbox.core.sdk.ISDKPlatform;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.internal.api.core.sdk.BaseSDKPlatform;
+import org.maemo.esbox.maemosdk.core.MaemoSDKEngine;
+import org.maemo.esbox.maemosdk.core.MaemoSDKInfo;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDK;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.core.sdk.MachineUtils;
+import org.maemo.esbox.maemosdk.core.sdk.CacheUtils;
+import org.maemo.esbox.maemosdk.sb1.command.CreateTargetCommand;
+import org.maemo.esbox.maemosdk.sb1.command.GetCurrentTargetCommand;
+import org.maemo.esbox.maemosdk.sb1.command.GetVersionScratchboxCommand;
+import org.maemo.esbox.maemosdk.sb1.command.KillallCommand;
+import org.maemo.esbox.maemosdk.sb1.command.ListCompilersCommand;
+import org.maemo.esbox.maemosdk.sb1.command.ListCputranspCommand;
+import org.maemo.esbox.maemosdk.sb1.command.ListDevkitsCommand;
+import org.maemo.esbox.maemosdk.sb1.command.ListSessionsCommand;
+import org.maemo.esbox.maemosdk.sb1.command.ListTargetsCommand;
+import org.maemo.esbox.maemosdk.sb1.command.RemoveTargetCommand;
+import org.maemo.esbox.maemosdk.sb1.command.SelectTargetCommand;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+
+public class Scratchbox1SDK extends AbstractScratchboxSDK implements
+		IScratchbox1SDK {
+
+	private IPath sdkRoot;
+	/** String for URI of machine where we detected scratchbox 1 */
+	static final String SB1_MACHINE = "sb1_machine";
+	/** String for scratchbox 1 version or <code>null</code> */
+	static final String SB1_VERSION = "sb1_version";
+
+	public Scratchbox1SDK(IMachine machine, String version,
+			IPreferenceProvider prefProvider) {
+		super(machine, version, IScratchbox1SDK.NAME, "sb1_machine",
+				"sb1_version", "sb1_targets", 1);
+		this.sdkRoot = null;
+		this.prefProvider = prefProvider;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDK#refresh()
+	 */
+	public void refresh() {
+		super.refresh();
+		try {
+			List<String> targetNames = getTargets();
+			List<ISDKTarget> newTargets = new ArrayList<ISDKTarget>();
+			for (String target : targetNames) {
+				IPath sb1TargetRoot = getSDKRoot()
+						.append("targets").append(target); //$NON-NLS-1$
+				ISDKTarget sdkTarget = new Scratchbox1SDKTarget(this,
+						getPlatform(target), getArchitecture(target), target,
+						sb1TargetRoot);
+				newTargets.add(sdkTarget);
+			}
+			this.targets = newTargets;
+		} catch (ESboxException e) {
+			Activator.getErrorLogger().logError("Could not refresh targets", e);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDK#getCommandAbstractor
+	 * ()
+	 */
+	public ICommandAbstractor getCommandAbstractor() throws ESboxException {
+		return getSb1WrappedAbstractor(super.getCommandAbstractor(), this
+				.getMachine());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#createTarget(java.lang
+	 * .String, java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public boolean createTarget(String targetName, String compiler,
+			String devkits, String cputransp) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(compiler);
+		params.add(devkits);
+		params.add(cputransp);
+
+		CreateTargetCommand createTargetCommand = new CreateTargetCommand(this,
+				getCommandAbstractor());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+		return (Boolean) createTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getCompilers()
+	 */
+	public List<String> getCompilers() throws ESboxException {
+		ListCompilersCommand listCompilersCommand = new ListCompilersCommand(
+				getCommandAbstractor());
+		return listCompilersCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getCputransp()
+	 */
+	public List<String> getCputransp() throws ESboxException {
+		ListCputranspCommand listCputranspCommand = new ListCputranspCommand(
+				getCommandAbstractor());
+		return listCputranspCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/**
+	 * Return the current version of Scratchbox 1.
+	 * 
+	 * @param machine
+	 * @return the current version of Scratchbox 1.
+	 * @throws ESboxException
+	 *             if any problem related to Scratchbox communication occurs,
+	 *             including no scratchbox 1 detected
+	 */
+	public static String getCurrentSboxVersion(IMachine machine)
+			throws ESboxException {
+		// find cached value
+		MachineUtils.ensureCurrentMachine(SB1_MACHINE, machine);
+		String version = (String) CacheUtils.getInstance().getCachedValue(
+				SB1_VERSION);
+		if (version != null)
+			return version;
+
+		// do the hard work
+		MachineUtils.acquireMachine(machine);
+		ICommandAbstractor commandAbstractor = MachineUtils
+				.getHostCommandAbstractor(machine);
+		commandAbstractor = getSb1WrappedAbstractor(commandAbstractor, machine);
+		GetVersionScratchboxCommand getVersionCommand = new GetVersionScratchboxCommand(
+				commandAbstractor);
+
+		String currentVersion = getVersionCommand
+				.performCommand(new ArrayList<String>());
+
+		// remember cached value
+		CacheUtils.getInstance().setCachedValue(SB1_VERSION, currentVersion);
+
+		return currentVersion;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getCurrentTarget()
+	 */
+	public String getCurrentTarget() throws ESboxException {
+		GetCurrentTargetCommand getCurrentTargetCommand = new GetCurrentTargetCommand(
+				getCommandAbstractor(), this);
+		return (String) getCurrentTargetCommand
+				.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getTargets()
+	 */
+	public List<String> getTargets() throws ESboxException {
+		MachineUtils.ensureCurrentMachine(SB_MACHINE, this.getMachine());
+
+		String[] targetsArray = (String[]) CacheUtils.getInstance()
+				.getCachedValue(SB_TARGETS);
+		if (targetsArray != null)
+			return Arrays.asList(targetsArray);
+
+		ListTargetsCommand listTargetsCommand = new ListTargetsCommand(
+				getCommandAbstractor());
+		List<String> targets = listTargetsCommand
+				.performCommand(new ArrayList<String>());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS,
+				(String[]) targets.toArray(new String[targets.size()]));
+
+		return targets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDK#getSDKRoot()
+	 */
+	public IPath getSDKRoot() {
+		if (sdkRoot == null) {
+			String userPath = prefProvider
+					.getPreferenceValue(SB1PreferenceConstants.SB1_SBOX_SANDBOX);
+			sdkRoot = new Path(userPath);
+		}
+		return sdkRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#removeTarget(java.lang
+	 * .String)
+	 */
+	public boolean removeTarget(String targetName) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+
+		RemoveTargetCommand removeTargetCommand;
+
+		removeTargetCommand = new RemoveTargetCommand(this,
+				getCommandAbstractor());
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+
+		return (Boolean) removeTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK#getDevkits()
+	 */
+	public List<String> getDevkits() throws ESboxException {
+		ListDevkitsCommand listDevkitsCommand = new ListDevkitsCommand(
+				getCommandAbstractor());
+		return listDevkitsCommand.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK#getSessions()
+	 */
+	public List<String> getSessions() throws ESboxException {
+		ListSessionsCommand listSessionsCommand = new ListSessionsCommand(
+				getCommandAbstractor());
+		return listSessionsCommand.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK#killProcess()
+	 */
+	public boolean killProcess() throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		KillallCommand killallCommand = new KillallCommand(
+				getCommandAbstractor());
+		return (Boolean) killallCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK#killProcess(java.lang
+	 * .String)
+	 */
+	public boolean killProcess(String signal) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(signal);
+		KillallCommand killallCommand = new KillallCommand(
+				getCommandAbstractor());
+		return (Boolean) killallCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.sb1.core.IScratchbox1SDK#selectTarget(java.lang
+	 * .String)
+	 */
+	public boolean selectTarget(String targetName) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+
+		SelectTargetCommand selectTargetCommand = new SelectTargetCommand(
+				getCommandAbstractor(), this);
+
+		return (Boolean) selectTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.maemosdk.core.sdk.
+	 * IScratchboxSDKPlatformArchitectureProvider
+	 * #getArchitecture(java.lang.String)
+	 */
+	public String getArchitecture(String target) {
+		// convention says this is the part of the target after the underscore
+		int idx = target.lastIndexOf('_');
+		if (idx > 0)
+			return target.substring(idx + 1).toUpperCase();
+		else
+			return IScratchboxSDKTarget.ARCHITECTURE_UNKNOWN;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.maemosdk.core.sdk.
+	 * IScratchboxSDKPlatformArchitectureProvider#getPlatform(java.lang.String)
+	 */
+	public ISDKPlatform getPlatform(String target) {
+		// convention says this is the part of the target before the underscore,
+		// usually the name of the platform directly, except for aberrant 'SDK'
+		// cases
+		int idx = target.lastIndexOf('_');
+		String platformName = ISDKPlatform.NAME_UNKNOWN;
+		String version = ISDKPlatform.VERSION_UNKNOWN;
+		if (idx >= 1) {
+			String platform = target.substring(0, idx);
+			// the 'SDK' one is a hard nut to crack
+			if (!platform.equalsIgnoreCase("SDK")) {
+				platformName = platform.substring(0, 1).toUpperCase()
+						+ platform.substring(1).toLowerCase();
+
+				List<MaemoSDKInfo> maemoSDKS = MaemoSDKEngine.getInstance()
+						.getMaemoSDKS();
+				for (MaemoSDKInfo info : maemoSDKS) {
+					if (info.getName().equalsIgnoreCase(platformName)) {
+						version = info.getVersion();
+						break;
+					}
+				}
+			} else {
+				// TODO: look at key files or versions to determine the
+				// platform from the SDK target contents
+			}
+		}
+		return new BaseSDKPlatform(platformName, version);
+	}
+
+	/**
+	 * Get a command abstractor that updates the PATH if sb1 tools are not on
+	 * the path.
+	 * 
+	 * @param commandAbstractor
+	 * @param machine
+	 * @return
+	 */
+	private static ICommandAbstractor getSb1WrappedAbstractor(
+			ICommandAbstractor commandAbstractor, IMachine machine) {
+		// XXX: the default path should be provided some other way
+		return wrapCommandAbstractorForSDK(commandAbstractor, machine,
+				"sb-conf", "/scratchbox/tools/bin");
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDKTarget.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDKTarget.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/core/Scratchbox1SDKTarget.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.core.CorePreferenceConstants;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.IProcessLauncherFactory;
+import org.maemo.esbox.core.sdk.ISDKPlatform;
+import org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.sb1.command.GetGdbQemuCommandPatternCommand;
+import org.maemo.esbox.maemosdk.sb1.launcher.Scratchbox1ProcessLauncherFactory;
+
+/**
+ * SDK target for Scratchbox 1
+ * 
+ * @author baranov
+ * 
+ */
+public class Scratchbox1SDKTarget extends AbstractScratchboxSDKTarget {
+
+	private IPath targetRoot;
+
+	public Scratchbox1SDKTarget(Scratchbox1SDK sdk, ISDKPlatform platform,
+			String architecture, String target, IPath targetRoot) {
+		super(sdk, platform, architecture, target);
+		this.targetRoot = targetRoot;
+		init(new Scratchbox1FileSystemMapping(sdk.getSDKRoot(), target, sdk
+				.getPreferenceValue(CorePreferenceConstants.USER)));
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#
+	 * getProcessLauncherFactoryForInstall()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactoryForInstall() {
+		return new Scratchbox1ProcessLauncherFactory(this, true);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#getRootstrapPath()
+	 */
+	public IPath getRootstrapPath() {
+		return getSDKTargetRoot();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDKTarget#getProcessLauncherFactory()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactory() {
+		return new Scratchbox1ProcessLauncherFactory(this, false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDKTarget#getSDKTargetRoot()
+	 */
+	public IPath getSDKTargetRoot() {
+		return targetRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#
+	 * getGdbQemuCommandPattern(java.lang.String)
+	 */
+	public synchronized String getGdbQemuCommandPattern(String architecture)
+			throws ESboxException {
+		GetGdbQemuCommandPatternCommand command = new GetGdbQemuCommandPatternCommand(
+				this, this.getCommandAbstractor());
+		List<String> arguments = new ArrayList<String>(1);
+		arguments.add(architecture);
+		return command.performCommand(arguments);
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/internal/Activator.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/internal/Activator.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/internal/Activator.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,146 @@
+package org.maemo.esbox.maemosdk.sb1.internal;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.maemo.esbox.core.ErrorLogger;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.maemo.esbox.maemosdk.sdk1";
+
+	// The shared instance
+	private static Activator plugin;
+
+	private IPreferenceStore preferenceStore;
+
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 * 
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+	/**
+	 * Return the error logger instance of this plug-in.
+	 * 
+	 * @return the error logger instance of this plug-in.
+	 */
+	public static ErrorLogger getErrorLogger() {
+		class CoreErrorLogger extends ErrorLogger {
+
+			@Override
+			public String getPluginID() {
+				return PLUGIN_ID;
+			}
+
+			@Override
+			public Plugin getPlugin() {
+				return Activator.getDefault();
+			}
+
+		}
+
+		return new CoreErrorLogger();
+	}
+
+	/**
+	 * Returns an image descriptor for the image file at the given plug-in
+	 * relative path.
+	 * 
+	 * @param path
+	 *            the path
+	 * @return the image descriptor
+	 */
+	public static ImageDescriptor getImageDescriptor(String path) {
+		return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
+	}
+
+	/**
+	 * Find a file relative to the plugin, either in a running workspace or a
+	 * standalone unit test (assumed to run relative to a plugin)
+	 * 
+	 * @param path
+	 */
+	public static InputStream getPluginRelativeInputStream(String path)
+			throws IOException {
+		if (getDefault() != null) {
+			return FileLocator.openStream(getDefault().getBundle(), new Path(
+					path), false);
+		} else {
+			return new FileInputStream("../" + path);
+		}
+	}
+
+	/**
+	 * Returns the preference store for this UI plug-in. This preference store
+	 * is used to hold persistent settings for this plug-in in the context of a
+	 * workbench. Some of these settings will be user controlled, whereas others
+	 * may be internal setting that are never exposed to the user.
+	 * <p>
+	 * If an error occurs reading the preference store, an empty preference
+	 * store is quietly created, initialized with defaults, and returned.
+	 * </p>
+	 * <p>
+	 * <strong>NOTE:</strong> As of Eclipse 3.1 this method is no longer
+	 * referring to the core runtime compatibility layer and so plug-ins relying
+	 * on Plugin#initializeDefaultPreferences will have to access the
+	 * compatibility layer themselves.
+	 * </p>
+	 * 
+	 * @return the preference store
+	 */
+	public IPreferenceStore getPreferenceStore() {
+		// Create the preference store lazily.
+		if (preferenceStore == null) {
+			preferenceStore = new ScopedPreferenceStore(new InstanceScope(),
+					getBundle().getSymbolicName());
+
+		}
+		return preferenceStore;
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1EnvironmentProvider.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1EnvironmentProvider.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1EnvironmentProvider.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb1.launcher;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.EnvironmentProperties;
+import org.maemo.esbox.core.process.ProcessLauncherUtils;
+import org.maemo.esbox.core.process.ProcessLauncherUtils.Results;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.internal.api.core.IStandardEnvironmentProvider;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+
+/**
+ * The standard environment provider for scratchbox caches the environment once
+ * per SDK target.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1EnvironmentProvider implements
+		IStandardEnvironmentProvider {
+	public static Map<ISDKTarget, Properties> cachedStdEnvMap = new HashMap<ISDKTarget, Properties>();
+	private final ISDKTarget sdkTarget;
+
+	/**
+	 * @param sdkTarget
+	 */
+	public Scratchbox1EnvironmentProvider(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * getRawEnvironment()
+	 */
+	public Properties getRawEnvironment() {
+		Properties standardEnv = cachedStdEnvMap.get(sdkTarget);
+		if (standardEnv == null) {
+			// gather arguments by querying a typical shell launched in POSIX
+			// mode (sh instead of bash)
+			Scratchbox1ProcessLauncher launcher = new Scratchbox1ProcessLauncher(
+					sdkTarget, null, CommandLineArguments.createFromVarArgs(
+							"sh", "-c", "set"), null);
+
+			try {
+				Results results = ProcessLauncherUtils
+						.launchAndReadStandardStreams(launcher, null);
+				standardEnv = EnvironmentProperties
+						.createFromShellEnvDump(results.stdout);
+			} catch (ESboxException e) {
+				Activator
+						.getErrorLogger()
+						.logError(
+								"Failed to read scratchbox environment; using system environment",
+								e);
+				standardEnv = sdkTarget.getSDK().getMachine()
+						.getStandardEnvironment();
+			}
+
+			cachedStdEnvMap.put(sdkTarget, standardEnv);
+		}
+		return standardEnv;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * flushRawEnvironment()
+	 */
+	public void flushRawEnvironment() {
+		cachedStdEnvMap.remove(sdkTarget);
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncher.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncher.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncher.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.launcher;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.filesystem.provider.FileInfo;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.Policy;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.env.IEnvironmentOperation;
+import org.maemo.esbox.core.process.BaseProcessLauncher;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.process.ShellTemplateSubstitutor;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+
+/**
+ * For SB 1, we need to use a "run.sh" wrapper script. The login program does
+ * not conserve variables set outside unless "-k" is passed, but we don't want
+ * to use that anyway, in order to have a clean SB environment.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1ProcessLauncher extends BaseProcessLauncher implements
+		IProcessLauncher {
+
+	/**
+	 * The name of a file copied from the plugin to the sb environment and used
+	 * to ensure environment variables can be passed.
+	 */
+	private static final String RUN_SCRIPT_NAME = "run.sh";
+
+	private ISDKTarget sdkTarget;
+	private List<String> originalArguments;
+
+	public Scratchbox1ProcessLauncher(ISDKTarget sdkTarget,
+			IPath workingDirectory, List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock) {
+		// in SB 1, the working directory, executable, args, and environment
+		// are encoded in a single command to a wrapper script
+		super(encodeArgumentArray(sdkTarget, workingDirectory, cmdLine,
+				environmentModifierBlock), null, null);
+		if (sdkTarget == null)
+			throw new IllegalArgumentException();
+		this.sdkTarget = sdkTarget;
+		this.originalArguments = cmdLine;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.internal.core.BaseProcessLauncher#getLaunchInfoPrefix()
+	 */
+	@Override
+	protected String getLaunchInfoPrefix() {
+		return sdkTarget + " ";
+	}
+
+	@Override
+	public String getCommandLineString() {
+		return CommandLineArguments.toCommandLine(originalArguments);
+	}
+
+	private static List<String> encodeArgumentArray(ISDKTarget sdkTarget,
+			IPath workingDirectory, List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock) {
+
+		// get the location where the launcher script will be copied on the
+		// target
+		String runScriptLocation = sdkTarget
+				.getPreferenceValue(SB1PreferenceConstants.RUN_SCRIPT_LOC);
+
+		// encode working directory inside scratchbox
+		if (workingDirectory == null) {
+			workingDirectory = new Path("/");
+		}
+
+		List<String> envArgs = encodeEnvironmentModifier(environmentModifierBlock);
+
+		// Encode the launch command by replacing the arguments
+		// representing template arguments with the actual values.
+		//
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+
+		substitutor.define("RUN_SCRIPT_DIRECTORY", runScriptLocation);
+		substitutor.define("RUN_SCRIPT", RUN_SCRIPT_NAME);
+		substitutor.define("DIRECTORY", workingDirectory.toPortableString());
+
+		String exportsString = CommandLineArguments.toString(envArgs,
+				",", false); //$NON-NLS-1$
+
+		substitutor.define("EXPORTS", exportsString);
+		substitutor.define("COMMAND", cmdLine.get(0));
+		substitutor.define("ARGS", CommandLineArguments.toCommandLine(cmdLine
+				.subList(1, cmdLine.size())));
+
+		// get the Scratchbox invocation pattern
+		String commandPattern = sdkTarget
+				.getPreferenceValue(SB1PreferenceConstants.SB1_LOGIN_COMMAND);
+
+		// replace variables
+		commandPattern = substitutor.substitute(commandPattern);
+
+		List<String> commandArgs = CommandLineArguments
+				.createFromCommandLine(commandPattern);
+		return commandArgs;
+	}
+
+	/**
+	 * Encode the add/replace and delete operations to run.sh
+	 * 
+	 * @param environmentModifierBlock
+	 * @return list of modifier flags
+	 */
+	private static List<String> encodeEnvironmentModifier(
+			IEnvironmentModifierBlock environmentModifierBlock) {
+		List<String> mods = new ArrayList<String>();
+		if (environmentModifierBlock != null) {
+			for (IEnvironmentOperation operation : environmentModifierBlock
+					.getOperations()) {
+				if (operation.getValue() == null)
+					mods.add("-" + operation.getName());
+				else
+					mods.add(operation.getName() + "=" + operation.getValue());
+			}
+		}
+		if (mods.isEmpty()) {
+			mods.add("-"); // must have something for the argument to be
+			// detected by run.sh
+		}
+		return mods;
+	}
+
+	/* A flag is the best way to do this -- see below */
+	private static boolean copiedRunScript;
+
+	@Override
+	protected void setupForLaunch() throws ESboxException {
+		// First, be sure we're running under the current target
+		ScratchboxTargetSwitcher.ensureCurrentTarget(sdkTarget);
+
+		// Ensure the run script is available.
+		//
+		// It's a little fishy to check the timestamps, since the timestamp of
+		// the
+		// script from the plugin may be extracted from a JAR and always look
+		// newer!
+		// So, just be cautious and set it up once per Eclipse session.
+		// 
+		// We don't want to waste time checking contents or being "smart" since
+		// this
+		// will just slow things down.
+
+		if (!copiedRunScript) {
+			IFileStore runScriptLocation = sdkTarget
+					.getMachineFileSystemAccess()
+					.getFileStore(
+							new Path(
+									sdkTarget
+											.getPreferenceValue(SB1PreferenceConstants.RUN_SCRIPT_LOC)));
+			IFileStore runScript = runScriptLocation.getChild(RUN_SCRIPT_NAME);
+
+			try {
+				runScriptLocation.mkdir(EFS.NONE, null);
+
+				OutputStream os = null;
+				InputStream is = null;
+				try {
+					os = runScript.openOutputStream(EFS.OVERWRITE, null);
+					is = Activator.getPluginRelativeInputStream("./conf/"
+							+ RUN_SCRIPT_NAME);
+					byte[] content = new byte[8192];
+					int len;
+					while ((len = is.read(content)) > 0) {
+						os.write(content, 0, len);
+					}
+				} finally {
+					Policy.close(os);
+					Policy.close(is);
+				}
+
+				FileInfo info = new FileInfo();
+				info.setAttribute(EFS.ATTRIBUTE_EXECUTABLE, true);
+				runScript.putInfo(info, EFS.NONE, null);
+
+				copiedRunScript = true;
+
+			} catch (Exception e) {
+				throw (ScratchboxException) new ScratchboxException(
+						"Cannot copy run script to " + runScript).initCause(e);
+			}
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.internal.core.BaseProcessLauncher#doCreateProcess()
+	 */
+	@Override
+	protected Process doCreateProcess() throws Exception {
+		return sdkTarget.getSDK().getMachine().createProcess(
+				getLaunchCurrentWorkingDirectory(),
+				getLaunchCommandArguments(),
+				getLaunchEnvironmentModifierBlock(), isUsePTY());
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncherFactory.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncherFactory.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/Scratchbox1ProcessLauncherFactory.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.launcher;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.internal.api.core.BaseProcessLauncherFactory;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1ProcessLauncherFactory extends
+		BaseProcessLauncherFactory {
+
+	protected ISDKTarget sdkTarget;
+	private final boolean runAsRoot;
+
+	public Scratchbox1ProcessLauncherFactory(ISDKTarget sdkTarget,
+			boolean runAsRoot) {
+		super(new Scratchbox1EnvironmentProvider(sdkTarget), false);
+		this.sdkTarget = sdkTarget;
+		this.runAsRoot = runAsRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.core.IProcessLauncherFactory#createProcessLauncher(org
+	 * .eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath,
+	 * org.maemo.esbox.core.List<String>, java.util.Properties)
+	 */
+	protected IProcessLauncher doCreateProcessLauncher(IPath workingDirectory,
+			List<String> cmdLine, IEnvironmentModifierBlock envBlock) {
+
+		if (runAsRoot) {
+			cmdLine = new ArrayList<String>(cmdLine);
+			cmdLine.add(0, "fakeroot");
+		}
+		return new Scratchbox1ProcessLauncher(sdkTarget, workingDirectory,
+				cmdLine, envBlock);
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/ScratchboxTargetSwitcher.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/ScratchboxTargetSwitcher.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/launcher/ScratchboxTargetSwitcher.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.launcher;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.GeneralUtils;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.process.ProcessLauncherCreator;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.core.scratchbox.ESboxScriptLauncher;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDKTarget;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+
+/**
+ * Utility class to handle switching scratchbox targets and get user approval to
+ * kill existing sessions if needed.
+ * 
+ * @author eswartz
+ * 
+ */
+public abstract class ScratchboxTargetSwitcher {
+
+	/**
+	 * Ensure the current SDK target can host the given target, asking user for
+	 * approval to terminate existing sessions if they are running.
+	 * 
+	 * @param target
+	 *            an SDK target (SB1 or anything else)
+	 * @throws ESboxException
+	 *             if target could not be switched
+	 */
+	public static void ensureCurrentTarget(ISDKTarget target)
+			throws ESboxException {
+		// only scratchbox 1 cares about "current targets"
+		if (!(target instanceof Scratchbox1SDKTarget)) {
+			return;
+		}
+
+		Scratchbox1SDK sdk = ((Scratchbox1SDK) target.getSDK());
+		final String currentTarget = sdk.getCurrentTarget();
+		final String targetName = target.getName();
+		if (currentTarget.equals(targetName)) {
+			return;
+		}
+
+		// see if maemo is running, since it needs to be killed to switch
+		// targets
+		// but isn't considered a "session" every time
+		boolean isMaemoRunning = ESboxScriptLauncher.getInstance()
+				.isMaemoStarted(target);
+
+		// now try to switch and see if shells are open
+		boolean failedToSwitch = false;
+		try {
+			sdk.selectTarget(targetName);
+		} catch (final ScratchboxException e) {
+			// sb-conf: You must close your other Scratchbox sessions first
+			// or
+			// Note: Couldn't reselect the target. There are other Scratchbox
+			// sessions open.
+			if (e.getLocalizedMessage().contains("Scratchbox sessions")) {
+				failedToSwitch = true;
+			} else {
+				throw e;
+			}
+		}
+
+		if (isMaemoRunning || failedToSwitch) {
+			final boolean[] ret = { false };
+
+			if (!GeneralUtils.isJUnitRunning()) {
+				Display.getDefault().syncExec(new Runnable() {
+					public void run() {
+						ret[0] = MessageDialog
+								.openQuestion(
+										null,
+										"Scratchbox Target Conflict",
+										MessageFormat
+												.format(
+														"The scratchbox 1 target needs to be switched from ''{0}'' to ''{1}'', but existing sessions are active.\n\n"
+																+ "Kill existing Scratchbox sessions?  (You may manually close them first, if desired, then select 'No' to retry)",
+														currentTarget,
+														targetName));
+					};
+				});
+			} else {
+				ret[0] = true;
+			}
+
+			// if user accepts, kill existing ones
+			if (ret[0]) {
+				if (isMaemoRunning) {
+					// a target selection may succeed even if X and maemo are
+					// running... kill them first.
+					// We kill X too because some processes won't be killed by
+					// maemo-launcher.
+					try {
+						ESboxScriptLauncher.getInstance().killMaemo(target);
+					} catch (ESboxException e2) {
+						// ignore
+					}
+					try {
+						ESboxScriptLauncher.getInstance().stopX(target);
+					} catch (ESboxException e2) {
+						// ignore
+					}
+				}
+
+				// now kill the scratchbox sessions the "approved" way
+				try {
+					sdk.killProcess();
+
+					// wait politely
+					try {
+						Thread.sleep(1000);
+					} catch (InterruptedException e1) {
+
+					}
+
+				} catch (ScratchboxException e2) {
+					// sb-conf killall can fail in the event there is some
+					// process with a space in its
+					// name... just log it and keep going
+					Activator.getErrorLogger().logError(
+							"Problem killing scratchbox sessions", e2);
+				}
+
+				// double-check, since it doesn't really work!
+				List<String> sessions = sdk.getSessions();
+				if (sessions.size() > 0) {
+					// forcibly kill processes
+					List<String> cmdLine = CommandLineArguments
+							.createFromVarArgs("kill", "-9");
+					cmdLine.addAll(sessions);
+
+					IProcessLauncher processLauncher = ProcessLauncherCreator
+							.createProcessLauncher(sdk
+									.getMachineProcessLauncherFactory(), null,
+									cmdLine);
+					Process process;
+					try {
+						process = processLauncher.createProcess();
+						process.waitFor();
+					} catch (final Exception e1) {
+						Display.getDefault().syncExec(new Runnable() {
+							public void run() {
+								MessageDialog
+										.openError(
+												null,
+												"Scratchbox Target Conflict",
+												MessageFormat
+														.format(
+																"Couldn''t kill scratchbox processes:\n\n{0}\n\nRetrying the target selection anyway.",
+																e1
+																		.getLocalizedMessage()));
+							};
+						});
+					}
+				}
+
+			}
+
+			// always retry, and rethrow if fails
+			sdk.selectTarget(targetName);
+		}
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/provider/Scratchbox1SDKProvider.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/provider/Scratchbox1SDKProvider.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/provider/Scratchbox1SDKProvider.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.provider;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.maemo.esbox.core.CorePreferenceManager;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.ErrorLogger;
+import org.maemo.esbox.core.machine.IMachine;
+import org.maemo.esbox.core.machine.MachineRegistry;
+import org.maemo.esbox.core.sdk.IPreferenceProvider;
+import org.maemo.esbox.core.sdk.ISDK;
+import org.maemo.esbox.core.sdk.ISDKProvider;
+import org.maemo.esbox.internal.api.core.sdk.UserAwarePreferenceProviderWrapper;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.maemosdk.core.sdk.CacheUtils;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+
+/**
+ * This implementation of the SDK provider searches for SB1 targets using the
+ * 'sb-conf list --targets' command. If any aspect of SB1 communication fails,
+ * we assume SB1 is not installed.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox1SDKProvider implements ISDKProvider {
+
+	// only 1.0.x+ supported right now
+	private static final String SCRATCHBOX_VERSION_PATTERN = "1\\.\\d+\\..*"; //$NON-NLS-1$
+
+	/**
+	 * 
+	 */
+	public Scratchbox1SDKProvider() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDKProvider#createSDKs()
+	 */
+	public List<ISDK> createSDKs() throws ESboxException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		List<ISDK> sdks = new ArrayList<ISDK>();
+		for (IMachine machine : MachineRegistry.getInstance()
+				.getBuildMachines()) {
+			try {
+				IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
+						CorePreferenceManager.getInstance()
+								.getPreferenceProvider(), machine);
+				IScratchboxSDK sdk = getMachineSDKs(prefProvider, machine);
+				if (sdk != null) {
+					sdks.add(sdk);
+					sdk.refresh();
+				}
+			} catch (ScratchboxException e) {
+				logger.log(IStatus.INFO,
+						"Problem scanning Scratchbox 1 installation", e);
+			}
+		}
+		CacheUtils.getInstance().saveCachedData();
+		return sdks;
+	}
+
+	/**
+	 * @param prefProvider
+	 * @return
+	 * @throws ScratchboxException
+	 */
+	private IScratchboxSDK getMachineSDKs(IPreferenceProvider prefProvider,
+			IMachine machine) throws ESboxException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		// only support one Scratchbox 1.x installation
+		String version = Scratchbox1SDK.getCurrentSboxVersion(machine);
+		if (version == null) {
+			// no scratchbox?
+			return null;
+		}
+
+		if (!version.matches(SCRATCHBOX_VERSION_PATTERN)) {
+			logger
+					.logError(
+							MessageFormat
+									.format(
+											"Only Scratchbox 1.x is supported (detected {0}); disabling Scratchbox 1 support",
+											version), null);
+			return null;
+		}
+
+		IScratchboxSDK sdk = new Scratchbox1SDK(machine, version, prefProvider);
+
+		return sdk;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb1.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.esbox.core.adapters.ISDKManageTargetAdapter;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoSDKInstallTargetAdapterFactory implements IAdapterFactory {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+	 * java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(ISDKManageTargetAdapter.class)) {
+			if (adaptableObject instanceof Scratchbox1SDK) {
+				return new MaemoScratchbox1SDKManageTargetAdapter(
+						(Scratchbox1SDK) adaptableObject);
+			}
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/adapters/MaemoScratchbox1SDKManageTargetAdapter.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb1.ui.adapters;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.core.Policy;
+import org.maemo.esbox.core.adapters.ISDKManageTargetAdapter;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+import org.maemo.esbox.maemosdk.sb1.ui.wizard.NewScratchbox1TargetWizard;
+import org.maemo.esbox.maemosdk.ui.adapters.ESboxTargetRemover;
+import org.maemo.esbox.maemosdk.ui.adapters.MaemoScratchboxSDKManageTargetAdapterBase;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoScratchbox1SDKManageTargetAdapter extends
+		MaemoScratchboxSDKManageTargetAdapterBase implements
+		ISDKManageTargetAdapter {
+
+	private Scratchbox1SDK sdk;
+
+	/**
+	 * @param adaptableObject
+	 */
+	public MaemoScratchbox1SDKManageTargetAdapter(Scratchbox1SDK sdk) {
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.core.adapters.ISDKManageTargetAdapter#installSDKTargets
+	 * (org.eclipse.swt.widgets.Shell, java.util.List)
+	 */
+	public IStatus installSDKTargets(Shell shell, List<ISDKTarget> installed) {
+		NewScratchbox1TargetWizard targetWizard;
+
+		targetWizard = new NewScratchbox1TargetWizard(sdk);
+		WizardDialog dlg = new WizardDialog(shell, targetWizard);
+		if (dlg.open() == Dialog.OK) {
+			return Status.OK_STATUS;
+		}
+
+		return Policy.getCancelStatus(Activator.getDefault());
+	}
+
+	public IStatus removeSDKTarget(Shell shell, ISDKTarget selectedTarget) {
+
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.ui.adapters.
+	 * MaemoScratchboxSDKManageTargetAdapterBase
+	 * #createTargetRemover(org.eclipse.swt.widgets.Shell,
+	 * org.maemo.esbox.core.sdk.ISDKTarget, boolean)
+	 */
+	protected ESboxTargetRemover createTargetRemover(Shell shell,
+			ISDKTarget target, boolean deleteRootstrap) {
+		return new ESboxTargetRemover(shell, target, deleteRootstrap) {
+
+			@Override
+			protected void doRemoveTarget(IProgressMonitor monitor,
+					IScratchboxSDK sdk) {
+				monitor.worked(1);
+			}
+		};
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/preferences/Scratchbox1PreferencesPage.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/preferences/Scratchbox1PreferencesPage.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/preferences/Scratchbox1PreferencesPage.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,159 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT.
+ * 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:
+ *    Paulo Romulo (UFCG) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb1.ui.preferences;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.preference.*;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.maemo.esbox.core.machine.ILocalMachine;
+
+import org.maemo.esbox.core.sdk.SDKFactory;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.maemosdk.core.sdk.ScratchboxSDKFacade;
+import org.maemo.esbox.maemosdk.sb1.core.SB1PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+
+/**
+ * General preference page for scratchbox 1
+ * 
+ * @author romulo
+ */
+public class Scratchbox1PreferencesPage extends FieldEditorPreferencePage
+		implements IWorkbenchPreferencePage {
+
+	/**
+	 * Field for sandbox root
+	 */
+	private DirectoryFieldEditor feSandboxRoot = null;
+	private StringFieldEditor feSandboxRootStr = null;
+
+	/**
+	 * Field for run scratchbox commands
+	 */
+	private StringFieldEditor feSboxCommands = null;
+	protected boolean sdksChanged;
+	private String origSandboxRoot;
+
+	// private StringFieldEditor feGdbQemuCommand;
+
+	/**
+	 * The constructor
+	 */
+	public Scratchbox1PreferencesPage() {
+		super(GRID);
+		setPreferenceStore(SB1PreferenceConstants.getPreferenceStore());
+		setDescription("Options configuring scratchbox 1");
+		origSandboxRoot = getPreferenceStore().getString(
+				SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
+	 * ()
+	 */
+	public void createFieldEditors() {
+		IScratchboxSDK sdk = null;
+		try {
+			sdk = ScratchboxSDKFacade.getInstance().getScratchboxSDK(
+					Scratchbox1SDK.class).get(0);
+		} catch (ScratchboxException e) {
+		}
+		if (false && sdk != null && sdk.getMachine() instanceof ILocalMachine) {
+			feSandboxRoot = new DirectoryFieldEditor(
+					SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString(),
+					"Sandbox root directory:", getFieldEditorParent());
+			addField(feSandboxRoot);
+			feSandboxRoot.getTextControl(getFieldEditorParent())
+					.addModifyListener(new ModifyListener() {
+
+						public void modifyText(ModifyEvent e) {
+							sdksChanged = true;
+						}
+
+					});
+		} else {
+			feSandboxRootStr = new StringFieldEditor(
+					SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString(),
+					"Sandbox root directory:", getFieldEditorParent());
+			addField(feSandboxRootStr);
+			feSandboxRootStr.getTextControl(getFieldEditorParent())
+					.addModifyListener(new ModifyListener() {
+
+						public void modifyText(ModifyEvent e) {
+							sdksChanged = true;
+						}
+
+					});
+		}
+
+		feSboxCommands = new StringFieldEditor(
+				SB1PreferenceConstants.SB1_LOGIN_COMMAND.toString(),
+				"Command template:", getFieldEditorParent());
+
+		feSboxCommands
+				.getTextControl(getFieldEditorParent())
+				.setToolTipText(
+						"This setting should only be changed if you have very specific needs, like an alternate run script.");
+
+		// make this string manageable
+		int width;
+		GC gc = new GC(getFieldEditorParent().getShell());
+		width = gc.getAdvanceWidth('m') * 32;
+		gc.dispose();
+
+		GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		gridData.widthHint = width;
+		feSboxCommands.getTextControl(getFieldEditorParent()).setLayoutData(
+				gridData);
+
+		addField(feSboxCommands);
+
+		// addField(feGdbQemuCommand);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	public void init(IWorkbench workbench) {
+		// Nothing to do
+	}
+
+	@Override
+	public boolean performOk() {
+		boolean ret = super.performOk();
+		if (ret) {
+			if (sdksChanged) {
+				String curSandboxRoot = getPreferenceStore().getString(
+						SB1PreferenceConstants.SB1_SBOX_SANDBOX.toString());
+				if (!curSandboxRoot.equals(origSandboxRoot)) {
+					SDKFactory.getInstance().refresh(new NullProgressMonitor());
+					origSandboxRoot = curSandboxRoot;
+				}
+			}
+		}
+		return ret;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/NewScratchbox1TargetWizard.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/NewScratchbox1TargetWizard.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/NewScratchbox1TargetWizard.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Carolina Nogueira de Souza (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb1.ui.wizard;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.ErrorLogger;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+import org.maemo.esbox.maemosdk.sb1.ui.wizard.TargetWizardDevkitsPage;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardCPUMethod;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardCompilerPage;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardNamePage;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardPageFactory;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.sbrsh.SbrshConfigurationNFSServer;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.sbrsh.SbrshConfigurationTargetDevice;
+
+/**
+ * The target wizard provides a easy way to create a target for Scratchbox. As
+ * Scratchbox target configuration, the user can configure your target.
+ * 
+ */
+public class NewScratchbox1TargetWizard extends Wizard implements INewWizard {
+
+	protected WizardPage targetNamePage;
+	protected WizardPage compilerNamePage;
+	protected WizardPage devkitsName;
+	protected WizardPage cpuMethodName;
+	protected WizardPage sbrshConfigTargetDevice;
+	protected WizardPage sbrshConfigNFSServer;
+	protected IProject generatedProject;
+
+	private Scratchbox1SDK sdk;
+
+	protected ISDKTarget createdTarget;
+
+	private void initialize() {
+		setNeedsProgressMonitor(true);
+		setWindowTitle("New Scratchbox 1 Target");
+		ImageDescriptor image = Activator
+				.getImageDescriptor("./icons/full/wizban/newtarget_wiz.gif");
+		setDefaultPageImageDescriptor(image);
+		initPages();
+	}
+
+	/**
+	 * Constructs a new target wizard for the given SDK (from the target
+	 * configuration page)
+	 * 
+	 * @param sdk
+	 */
+	public NewScratchbox1TargetWizard(Scratchbox1SDK sdk) {
+		super();
+		this.sdk = sdk;
+		initialize();
+	}
+
+	/**
+	 * Inicializes the content of the pages.
+	 */
+	private void initPages() {
+		if (sdk != null) {
+			targetNamePage = TargetWizardPageFactory.getInstance()
+					.createNamePage(sdk);
+			addPage(targetNamePage);
+			compilerNamePage = TargetWizardPageFactory.getInstance()
+					.createCompilerPage(sdk);
+			addPage(compilerNamePage);
+			devkitsName = new TargetWizardDevkitsPage(sdk);
+			addPage(devkitsName);
+			cpuMethodName = TargetWizardPageFactory.getInstance()
+					.createCPUMethod(sdk);
+			addPage(cpuMethodName);
+			sbrshConfigTargetDevice = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigDeviceTargetPage();
+			addPage(sbrshConfigTargetDevice);
+			sbrshConfigNFSServer = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigNFSSServer();
+			addPage(sbrshConfigNFSServer);
+		} else {
+			addPage(TargetWizardPageFactory.getInstance()
+					.createBadInstallationPage());
+		}
+	}
+
+	public boolean canFinish() {
+		if (sdk == null)
+			return false;
+
+		boolean nonCustomRootstrap = true;
+		boolean cpuPage = ((TargetWizardCPUMethod) cpuMethodName).canFinish();
+		boolean configDevice = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.canFinish();
+		boolean NFSServer = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.canFinish();
+		boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+
+		if (!sbrshConfigAccepted && (nonCustomRootstrap || cpuPage))
+			return true;
+		if (sbrshConfigAccepted && NFSServer && configDevice)
+			return true;
+
+		return false;
+	}
+
+	@Override
+	public IWizardPage getNextPage(IWizardPage page) {
+		if (page == cpuMethodName) {
+			boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+					.getSbrshConfigure();
+			if (!sbrshConfigAccepted) // user does not want to configure sbrsh
+				return null;
+			else
+				// user wants to configure sbrsh
+				return super.getNextPage(page);
+		}
+		return super.getNextPage(page);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
+	 */
+	public boolean performFinish() {
+		if (!setupTargetFromScratch())
+			return false;
+
+		boolean sbrshConfigSelected = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+		if (sbrshConfigSelected) {
+			configureSbrshService();
+			showsDialog();
+		}
+
+		return true;
+	}
+
+	private boolean setupTargetFromScratch() {
+		String targetName;
+		// in this mode, construct a target from the user's settings
+		targetName = getTargetNameSelected();
+		String compilerName = getCompilerNameSelected();
+		String cpuMethod = getCputranspSelected();
+		try {
+
+			String devkits = getDevkitsSelected();
+			// ScratchboxFacade.getInstance().createTarget((IScratchbox1SDK)
+			// sdk, targetName, compilerName, devkits, cpuMethod);
+			sdk.createTarget(targetName, compilerName, devkits, cpuMethod);
+
+			createdTarget = sdk.findSDKTarget(targetName);
+			return true;
+		} catch (ESboxException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot get create target "
+					+ targetName, e);
+			return false;
+		}
+	}
+
+	/**
+	 * Return the name of the target to be created.
+	 * 
+	 * @return the name of the target to be created.
+	 */
+	private String getTargetNameSelected() {
+		return ((TargetWizardNamePage) targetNamePage).getTextControl()
+				.getText();
+	}
+
+	/**
+	 * Return the compiler name of the target to be created.
+	 * 
+	 * @return the compiler name of the target to be created.
+	 */
+	private String getCompilerNameSelected() {
+		TableItem item = ((TargetWizardCompilerPage) compilerNamePage)
+				.getTableControl().getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Return the devkits selected.
+	 * 
+	 * @return the devkits selected.
+	 */
+	private String getDevkitsSelected() {
+		String devkits = "";
+		TableItem devkitsSelected[] = ((TargetWizardDevkitsPage) devkitsName).table
+				.getSelection();
+		String separator = "";
+		for (int i = 0; i < devkitsSelected.length; i++) {
+			TableItem devkit = devkitsSelected[i];
+			devkits += separator + devkit.getText();
+			separator = ":";
+		}
+		return devkits;
+	}
+
+	/**
+	 * Return the cputransp name of the target to be created.
+	 * 
+	 * @return the cputransp name of the target to be created.
+	 */
+	private String getCputranspSelected() {
+		TableItem item = ((TargetWizardCPUMethod) cpuMethodName).getTable()
+				.getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Configure sbrsh service.
+	 */
+	private void configureSbrshService() {
+		String targetName = getTargetNameSelected();
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceAddr();
+		String nfsHostname = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.getNFSHostname();
+
+		try {
+			// ScratchboxFacade.getInstance().configureSbrsh(sdk, targetName,
+			// deviceTargetAddr, nfsHostname);
+			sdk.configureSbrsh(targetName, deviceTargetAddr, nfsHostname);
+		} catch (ESboxException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot configure sbrsh", e);
+		}
+	}
+
+	/**
+	 * Add user at access list of the sbrshd running at the target device.
+	 */
+	private void addUser() {
+		String deviceTargetIP = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String username = System.getProperty("user.name");
+		ErrorLogger errorLogger = Activator.getErrorLogger();
+
+		try {
+			String localAddr = getLocalIP();
+			// ScratchboxFacade.getInstance().addSbrshAccessList(sdk,
+			// deviceTargetIP, username, localAddr);
+			sdk.addSbrshAccessList(deviceTargetIP, username, localAddr);
+		} catch (ESboxException e) {
+			errorLogger
+					.logAndShowError(
+							"Cannot add user to the access list of sbrshd at the target device",
+							e);
+		} catch (UnknownHostException e) {
+			errorLogger.logAndShowError("Cannot get local IP address", e);
+		}
+	}
+
+	/**
+	 * Shows the dialog to ask the user if s/he wants to add his/herself to the
+	 * acess list of the sbrshd.
+	 */
+	private void showsDialog() {
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String text = "Do you want to add yourself to the access list of the sbrshd running on target device? \n";
+		text += "(This requires that "
+				+ deviceTargetAddr
+				+ " has ssh daemon running and sbrshd already installed, and that you have root access).";
+		boolean userAddedAtAccessList = MessageDialog.openQuestion(getShell(),
+				"Scratchbox Configuration", text);
+		if (userAddedAtAccessList) {
+			addUser();
+		}
+	}
+
+	/**
+	 * Get the local IP address.
+	 * 
+	 * @return the local IP address.
+	 * @throws UnknownHostException
+	 */
+	private String getLocalIP() throws UnknownHostException {
+		return InetAddress.getLocalHost().getHostAddress();
+	}
+
+	/**
+	 * We will accept the selection in the workbench to see if we can initialize
+	 * from it.
+	 * 
+	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+	}
+
+	/**
+	 * Get the target created. Only valid after wizard dialog completes.
+	 * 
+	 * @return newly created ISDKTarget or <code>null</code>
+	 */
+	public ISDKTarget getCreatedTarget() {
+		return createdTarget;
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/TargetWizardDevkitsPage.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/TargetWizardDevkitsPage.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk1/src/org/maemo/esbox/maemosdk/sb1/ui/wizard/TargetWizardDevkitsPage.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Carolina Nogueira de Souza (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb1.ui.wizard;
+
+import java.util.List;
+
+import org.eclipse.jface.wizard.WizardPage;
+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.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.ErrorLogger;
+import org.maemo.esbox.maemosdk.sb1.core.Scratchbox1SDK;
+import org.maemo.esbox.maemosdk.sb1.internal.Activator;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.IValidatePage;
+
+/**
+ * This pages shows the devkits that the user can choose for his/her target.
+ * 
+ */
+public class TargetWizardDevkitsPage extends WizardPage implements
+		IValidatePage {
+
+	protected Table table;
+	private Scratchbox1SDK sdk;
+
+	/**
+	 * Constructs a NewTargetWizardDevkitsPage.
+	 */
+	protected TargetWizardDevkitsPage(Scratchbox1SDK sdk) {
+		super("Devkit");
+		this.sdk = sdk;
+		setTitle("Devkit");
+		setDescription("Select devkits");
+		setPageComplete(false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+	 * .Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setLayout(new GridLayout(1, false));
+
+		Label label = new Label(composite, SWT.LEFT);
+		label.setText("Devkits");
+
+		table = new Table(composite, SWT.MULTI | SWT.CHECK | SWT.BORDER);
+		table.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+		table.setHeaderVisible(false);
+		table.setLinesVisible(true);
+		table.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				validatePage();
+			}
+		});
+
+		inicializeTable();
+
+		setControl(composite);
+	}
+
+	/**
+	 * Inicializes the contents of the table.
+	 */
+	private void inicializeTable() {
+		TableItem item = null;
+		List<String> devkits = null;
+		try {
+			// devkits = ScratchboxFacade.getInstance().getDevkits(sdk);
+			devkits = sdk.getDevkits();
+		} catch (ESboxException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot get list of devkits", e);
+			return;
+		}
+		for (String devkit : devkits) {
+			item = new TableItem(table, SWT.NONE);
+			item.setText(devkit);
+		}
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage
+	 * #perfomeAction()
+	 */
+	public boolean validatePage() {
+		TableItem[] items = table.getItems();
+		boolean noneSelected = false;
+		boolean pageOK = false;
+		// verifies if at least one option was checked.
+		for (int i = 0; i < items.length; i++) {
+			TableItem item = items[i];
+			if (item.getChecked()) {
+				pageOK = true;
+				break;
+			}
+		}
+		// verifies if the options were choosen properly.
+		for (int i = 0; i < items.length; i++) {
+			TableItem item = items[i];
+			// verifies if any item was selected.
+			if (item.getChecked()) {
+				// verifies if "none" was selected.
+				if (item.getText().equals("none")) {
+					noneSelected = true;
+					// the user cant select another devkit if "none" was
+					// selected.
+				} else {
+					pageOK = !noneSelected;
+				}
+			}
+		}
+		if (noneSelected && !pageOK) {
+			setErrorMessage("Selected corrects devkits.");
+		} else {
+			String msg = pageOK ? null : "Select at least one option";
+			setErrorMessage(msg);
+		}
+		setPageComplete(pageOK);
+		return pageOK;
+	}
+}
\ No newline at end of file

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/AbstractSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/AbstractSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/AbstractSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.security.InvalidParameterException;
+
+import org.maemo.esbox.maemosdk.core.command.AbstractSDKCommand;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+public abstract class AbstractSb2Command extends AbstractSDKCommand {
+
+	public AbstractSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.command.AbstractSDKCommand#
+	 * replaceScratchboxConfigCommand(java.lang.String, java.lang.String[])
+	 */
+	public String replaceScratchboxConfigCommand(String action, String[] options)
+			throws InvalidParameterException {
+		String sboxCommand;
+
+		sboxCommand = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_CONFIG_COMMAND);
+
+		return replaceScratchboxCommand(sboxCommand, action, options);
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateMaemoRootstrapSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateMaemoRootstrapSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateMaemoRootstrapSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.maemo.esbox.core.CorePlugin;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.ProcessLauncherUtils;
+import org.maemo.esbox.core.sdk.ISDK;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * Creates a new rootstrap for a target, if it does not exist. This command
+ * wraps the callback to service:
+ * <p>
+ * maemo-rootstrap [--force] install &lt;target&gt;
+ * 
+ */
+public class CreateMaemoRootstrapSb2Command extends MaemoRootstrapSb2Command {
+
+	private ISDK sdk;
+	private IProgressMonitor monitor;
+
+	public CreateMaemoRootstrapSb2Command(ISDK sdk,
+			ICommandAbstractor commandAbstractor, IProgressMonitor monitor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+		this.monitor = monitor;
+	}
+
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 3;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Boolean performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String useHostToolsFlag = param.get(1);
+		String forceFlag = param.get(2);
+
+		List<String> params = new ArrayList<String>();
+		if (useHostToolsFlag.equals(Boolean.TRUE.toString())) {
+			params
+					.add(commandAbstractor
+							.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT));
+		}
+		if (forceFlag.equals(Boolean.TRUE.toString())) {
+			params
+					.add(commandAbstractor
+							.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_FORCE_OPT));
+		}
+		params
+				.add(commandAbstractor
+						.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_INSTALL_ACT));
+		params.add(targetName);
+
+		IEnvironmentModifierBlock envBlock = commandAbstractor
+				.getProcessLauncherFactory().defaultEnvironmentModifierBlock();
+		ProcessLauncherUtils.defineProxyVariables(envBlock);
+
+		setMonitorAndConsole(monitor, CorePlugin.getDefault().getConsole(true,
+				null, "Installing rootstrap " + targetName));
+		doPerformCommand(params, envBlock, 0);
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateTargetSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateTargetSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/CreateTargetSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.process.ProcessLauncherCreator;
+import org.maemo.esbox.core.process.ShellTemplateSubstitutor;
+import org.maemo.esbox.core.sdk.ISDK;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+/**
+ * Creates a new target, if it does not exist. This command wraps the callback
+ * to service:
+ * <p>
+ * sb2-init {flags} [targetname] [compiler]
+ * 
+ */
+public class CreateTargetSb2Command extends AbstractSb2Command {
+
+	private ISDK sdk;
+
+	public CreateTargetSb2Command(ISDK sdk, ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = sdk;
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() >= 3;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param) throws ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String compilerName = param.get(1);
+		String cpuTransp = param.get(2);
+
+		// remaining arguments are flags
+		String pattern = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_INIT_COMMAND);
+
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+		substitutor.define("TARGET", targetName);
+		substitutor.define("COMPILER", compilerName);
+
+		String options = "";
+		if (cpuTransp != null && cpuTransp.length() > 0) {
+			options += "-c " + cpuTransp;
+		}
+		substitutor.define("OPTIONS", options);
+
+		pattern = substitutor.substitute(pattern);
+
+		List<String> cmdLine = CommandLineArguments
+				.createFromCommandLine(pattern);
+
+		IProcessLauncher processLauncher = ProcessLauncherCreator
+				.createProcessLauncher(commandAbstractor
+						.getProcessLauncherFactory(), null, cmdLine);
+
+		Process process = processLauncher.createProcess();
+
+		processLauncher.redirectToConsole(true, null,
+				"Installing scratchbox2 target " + targetName);
+
+		try {
+			process.waitFor();
+		} catch (InterruptedException e) {
+			Activator.getErrorLogger().logError("Target installation aborted",
+					e);
+		}
+
+		sdk.refresh();
+
+		return true;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 3;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetCurrentTargetSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetCurrentTargetSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetCurrentTargetSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.CorePreferenceConstants;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.Policy;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+
+/**
+ * Get the current Scratchgox 2 target. There is no command to do this, so read
+ * $HOME/.scratchbox2/config
+ */
+public class GetCurrentTargetSb2Command extends AbstractSb2Command {
+
+	public GetCurrentTargetSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		IFileStore config = commandAbstractor
+				.getFileSystemAccess()
+				.getFileStore(
+						new Path("home")
+								.append(
+										commandAbstractor
+												.getPreferenceValue(CorePreferenceConstants.USER))
+								.append(".scratchbox2").append("config"));
+
+		InputStream is = null;
+		try {
+			is = config.openInputStream(EFS.NONE, null);
+			BufferedReader reader = new BufferedReader(
+					new InputStreamReader(is));
+			Pattern varPattern = Pattern
+					.compile("\\s*DEFAULT_TARGET\\s*=\\s*(\\S+)\\s*");
+			String line;
+			while ((line = reader.readLine()) != null) {
+				Matcher matcher = varPattern.matcher(line.trim());
+				if (matcher.matches()) {
+					return matcher.group(1);
+				}
+			}
+
+			return null;
+		} catch (IOException e) {
+			throw new ScratchboxException("Cannot read target from " + config
+					+ ": " + e.getMessage());
+		} catch (CoreException e) {
+			throw new ScratchboxException("Cannot read target from " + config
+					+ ": " + e.getMessage());
+		} finally {
+			Policy.close(is);
+		}
+
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetGdbQemuCommandPatternCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetGdbQemuCommandPatternCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetGdbQemuCommandPatternCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb2.core.Scratchbox2SDKTarget;
+
+/**
+ * Get the command pattern for launching qemu with the debugger
+ * 
+ * @author eswartz
+ * 
+ */
+public class GetGdbQemuCommandPatternCommand extends AbstractSb2Command {
+	private Scratchbox2SDKTarget sdkTarget;
+
+	public GetGdbQemuCommandPatternCommand(Scratchbox2SDKTarget sdkTarget,
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public String performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String commandPattern = null;
+
+		String architecture = param.get(0);
+
+		if (architecture.equals(IScratchboxSDKTarget.ARCHITECTURE_ARMEL)) {
+			// we think this always uses a new enough version, so keep ${PORT}
+			commandPattern = sdkTarget
+					.getPreferenceValue(SB2PreferenceConstants.SB2_GDB_REMOTE_QEMU);
+		} else {
+			// The others, just standard "gdbserver" command.
+			commandPattern = sdkTarget
+					.getPreferenceValue(MaemoPreferenceConstants.SBOX_GDB_REMOTE);
+		}
+
+		return commandPattern;
+	}
+
+	/**
+	 * Find what qemu is configured for this target.
+	 * 
+	 * @return qemu name, or <code>null</code> if not using qemu
+	 */
+	protected String getConfiguredQemu() throws ESboxException {
+		return null;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetMaemoRootstrapLocationCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetMaemoRootstrapLocationCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetMaemoRootstrapLocationCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb2.core.Scratchbox2SDKTarget;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class GetMaemoRootstrapLocationCommand extends MaemoRootstrapSb2Command {
+
+	private Scratchbox2SDKTarget sdkTarget;
+
+	public GetMaemoRootstrapLocationCommand(
+			ICommandAbstractor commandAbstractor, Scratchbox2SDKTarget sdkTarget) {
+		super(commandAbstractor);
+		this.sdkTarget = sdkTarget;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.internal.core.command.ICommand#performCommand(java.util
+	 * .List)
+	 */
+	public Object performCommand(List<String> params)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		List<String> rsCommands = new ArrayList<String>(2);
+
+		String pathAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_PATH_ACT);
+
+		rsCommands.add(pathAction);
+		rsCommands.add(sdkTarget.getName());
+
+		List<String> results = doPerformCommand(rsCommands, null, 0);
+		if (results.size() == 0)
+			throw new ScratchboxException(
+					"Could not detect rootstrap location for " + sdkTarget
+							+ "\ngot:\n" + catenateLines(results));
+
+		// ignore bogus report of deleted rootstrap
+		IPath root = new Path(results.get(0).trim());
+		IFileStore store = sdkTarget.getMachineFileSystemAccess().getFileStore(
+				root);
+		if (store.fetchInfo().exists())
+			return root;
+		else
+			throw new ScratchboxException("Rootstrap location for " + sdkTarget
+					+ " does not exist: " + store);
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetVersionScratchboxCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetVersionScratchboxCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/GetVersionScratchboxCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * Get the version of Scratchbox installed. This command wraps the callback to
+ * service sb-conf version.
+ * 
+ */
+public class GetVersionScratchboxCommand extends AbstractSb2Command {
+
+	public GetVersionScratchboxCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.ScratchboxCommand#getParametersSize()
+	 */
+	public int getParametersSize() {
+		// TODO Auto-generated method stub
+		return 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .util.List)
+	 */
+	public String performCommand(List<String> params)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(params))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String sboxVersionAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_VERSION_ACT);
+
+		String currentSboxVersionCommand = this
+				.replaceScratchboxConfigCommand(sboxVersionAction);
+
+		Process process = createProcess(currentSboxVersionCommand, null);
+
+		String currentVersion = getInputFromProcessAndWait(process, false, 0);
+
+		return currentVersion;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListAvailableMaemoRootstrapsSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.ProcessLauncherUtils;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * List the maemo rootstraps available for installation.
+ */
+public class ListAvailableMaemoRootstrapsSb2Command extends
+		MaemoRootstrapSb2Command {
+
+	private static final int LIST_TIMEOUT = 10000;
+
+	public ListAvailableMaemoRootstrapsSb2Command(
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<MaemoRootstrap> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String availableAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT);
+
+		// ensure the proxy is established
+		IEnvironmentModifierBlock proxyEnvBlock = commandAbstractor
+				.getProcessLauncherFactory().defaultEnvironmentModifierBlock();
+		ProcessLauncherUtils.defineProxyVariables(proxyEnvBlock);
+
+		List<String> available = doPerformCommand(Collections
+				.singletonList(availableAction), proxyEnvBlock, LIST_TIMEOUT);
+
+		// this output has a few header lines
+		List<MaemoRootstrap> targetsAvailable = new ArrayList<MaemoRootstrap>();
+
+		boolean gotHeader = false;
+		for (String line : available) {
+			if (line.contains("Nickname,")) {
+				gotHeader = true;
+				continue;
+			}
+			if (line.trim().length() == 0) {
+				continue;
+			}
+			if (!gotHeader) {
+				continue;
+			}
+
+			String[] tokens = line.split(",\\s*");
+			if (tokens.length == 3) {
+				targetsAvailable.add(new MaemoRootstrap(tokens[0], tokens[1],
+						tokens[2]));
+			}
+
+		}
+		return targetsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCompilersSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCompilersSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCompilersSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+/**
+ * List the installed compilers. There's no known command for this, but we can
+ * look in specific places.
+ * 
+ */
+public class ListCompilersSb2Command extends AbstractSb2Command {
+
+	public ListCompilersSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		List<String> compilersAvailable = new ArrayList<String>();
+
+		try {
+			IFileStore baseToolDir = commandAbstractor.getFileSystemAccess()
+					.getFileStore(new Path("/opt/maemo/tools"));
+			IFileStore[] kids = baseToolDir.childStores(EFS.NONE, null);
+			for (IFileStore baseDir : kids) {
+				IFileStore dir = baseDir.getChild("bin");
+				if (dir.fetchInfo().isDirectory()) {
+					IFileStore[] files = dir.childStores(EFS.NONE, null);
+					for (IFileStore file : files) {
+						if (file.getName().endsWith("-gcc")) {
+							compilersAvailable.add(file.toURI().getPath());
+							break;
+						}
+					}
+				}
+			}
+		} catch (CoreException e) {
+			Activator.getErrorLogger().logError("Error scanning compilers", e);
+		}
+		return compilersAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCputranspSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCputranspSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListCputranspSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.ProcessLauncherUtils;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+
+/**
+ * List the installed compilers. There's no known command for this, but we can
+ * look in specific places.
+ * 
+ */
+public class ListCputranspSb2Command extends AbstractSb2Command {
+
+	public ListCputranspSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		List<String> cputranspAvailable = new ArrayList<String>();
+
+		Set<String> expected = new HashSet<String>();
+		expected.add("sb2-qemu-arm");
+		expected.add("sbrsh");
+
+		Properties env = ProcessLauncherUtils
+				.getSynthesizedEnvironment(commandAbstractor
+						.getProcessLauncherFactory());
+		String pathenv = env.getProperty("PATH");
+		if (pathenv == null) {
+			pathenv = "/usr/bin:/bin"; // XXX
+		}
+		if (pathenv != null) {
+			String[] paths = pathenv.split(":");
+			for (String exp : expected) {
+				for (String path : paths) {
+					IFileStore bin = commandAbstractor.getFileSystemAccess()
+							.getFileStore(new Path(path).append(exp));
+					if (bin.fetchInfo().exists()) {
+						cputranspAvailable.add(bin.toURI().getPath());
+						break;
+					}
+				}
+			}
+		}
+
+		return cputranspAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListInstalledMaemoRootstrapsSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * List the maemo rootstraps installed
+ */
+public class ListInstalledMaemoRootstrapsSb2Command extends
+		MaemoRootstrapSb2Command {
+
+	public ListInstalledMaemoRootstrapsSb2Command(
+			ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 0;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String availableAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_LIST_ACT);
+
+		List<String> installed = doPerformCommand(Collections
+				.singletonList(availableAction), null, 0);
+
+		return installed;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListTargetsCommand.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListTargetsCommand.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ListTargetsCommand.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * List the installed targets. This command wraps the callback to service (sb1)
+ * sb-conf list --targets or sb2-config -l (sb2)
+ * 
+ */
+public class ListTargetsCommand extends AbstractSb2Command {
+
+	public ListTargetsCommand(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public List<String> performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String listAction;
+		String targetsOption;
+		listAction = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_LIST_ACT);
+		targetsOption = "";
+
+		String listTargetsCommandString = this.replaceScratchboxConfigCommand(
+				listAction, new String[] { targetsOption });
+
+		Process process = createProcess(listTargetsCommandString, null);
+
+		List<String> targetsAvailable = getLineInputFromProcessAndWait(process,
+				true, 0);
+
+		return targetsAvailable;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/MaemoRootstrapSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/MaemoRootstrapSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/MaemoRootstrapSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,94 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.ShellTemplateSubstitutor;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * Base class for maemo rootstrap command.
+ */
+public abstract class MaemoRootstrapSb2Command extends AbstractSb2Command {
+
+	public MaemoRootstrapSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return true;
+	}
+
+	/**
+	 * Override if stderr output is allowed.
+	 * 
+	 * @return false
+	 */
+	protected boolean allowErrors() {
+		return false;
+
+	}
+
+	/**
+	 * Perform the command with the given params as command line arguments, with
+	 * an optional timeout (triggering ScratchboxException if reached)
+	 * 
+	 * @param params
+	 *            command line parameters to maemo-rootstrap
+	 * @param envBlock
+	 *            any environment needed or <code>null</code>
+	 * @param timeout
+	 *            if not 0, timeout in milliseconds
+	 * @return lines from stdout
+	 * @throws ScratchboxException
+	 *             if command execution fails or if timeout reached
+	 */
+	@SuppressWarnings("unchecked")
+	protected List<String> doPerformCommand(List<String> params,
+			IEnvironmentModifierBlock envBlock, long timeout)
+			throws ESboxException {
+		String rootstrapCommand = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_COMMAND);
+
+		String options = CommandLineArguments.toCommandLine(params);
+
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+		substitutor.define("OPTIONS", options);
+
+		rootstrapCommand = substitutor.substitute(rootstrapCommand);
+
+		if (console == null) {
+			Process process = createProcess(rootstrapCommand, envBlock);
+			List<String> results = getLineInputFromProcessAndWait(process,
+					allowErrors(), timeout);
+			return results;
+		} else {
+			runAndWaitForProcess("Running " + rootstrapCommand,
+					rootstrapCommand, envBlock, timeout);
+			return Collections.EMPTY_LIST;
+		}
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveMaemoRootstrapSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveMaemoRootstrapSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveMaemoRootstrapSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.maemo.esbox.core.CorePlugin;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.ProcessLauncherUtils;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * Remove a maemo rootstrap. Parameters are target name and force boolean flag.
+ */
+public class RemoveMaemoRootstrapSb2Command extends MaemoRootstrapSb2Command {
+
+	private final IProgressMonitor monitor;
+
+	public RemoveMaemoRootstrapSb2Command(ICommandAbstractor commandAbstractor,
+			IProgressMonitor monitor) {
+		super(commandAbstractor);
+		this.monitor = monitor;
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return param.size() == 2;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Boolean performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetName = param.get(0);
+		String forceFlag = param.get(1);
+
+		String action = commandAbstractor
+				.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_REMOVE_ACT);
+
+		List<String> commands = new ArrayList<String>();
+
+		if (forceFlag.equals(Boolean.TRUE.toString())) {
+			String force = commandAbstractor
+					.getPreferenceValue(SB2PreferenceConstants.SB2_MAEMO_ROOTSTRAP_FORCE_OPT);
+			commands.add(force);
+		}
+		commands.add(action);
+		commands.add(targetName);
+
+		IEnvironmentModifierBlock envBlock = commandAbstractor
+				.getProcessLauncherFactory().defaultEnvironmentModifierBlock();
+		ProcessLauncherUtils.defineProxyVariables(envBlock);
+
+		setMonitorAndConsole(monitor, CorePlugin.getDefault().getConsole(true,
+				null, "Removing rootstrap " + targetName));
+
+		doPerformCommand(commands, envBlock, 0);
+
+		return Boolean.TRUE;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveTargetSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveTargetSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/RemoveTargetSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.runtime.CoreException;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.sdk.ISDK;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.command.ScratchboxInvalidParameterException;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.Scratchbox2SDK;
+
+/**
+ * Remove a Scratchbox 2 target. There's no known command for this, but we can
+ * manually fix up the system.
+ * 
+ */
+public class RemoveTargetSb2Command extends AbstractSb2Command {
+
+	private Scratchbox2SDK sdk;
+
+	public RemoveTargetSb2Command(ISDK sdk, ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+		this.sdk = (Scratchbox2SDK) sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * embedded.core.scratchbox.command.IScratchboxCommand#performCommand(java
+	 * .lang.Object)
+	 */
+	public Object performCommand(List<String> param)
+			throws ScratchboxException, ESboxException {
+		if (!this.checkParameters(param))
+			throw new ScratchboxInvalidParameterException(
+					"Invalid number of parameters");
+
+		String targetToRemove = param.get(0);
+		if (!targetExist(targetToRemove))
+			throw new ScratchboxInvalidParameterException("Target "
+					+ targetToRemove + " does not exist.");
+
+		IFileStore sb2Dir = commandAbstractor.getFileSystemAccess()
+				.getFileStore(sdk.getScratchbox2ConfigDirectory());
+		IFileStore targetDir = sb2Dir.getChild(targetToRemove);
+
+		if (!targetDir.fetchInfo().exists()) {
+			throw new ScratchboxInvalidParameterException("Target "
+					+ targetToRemove
+					+ " does not exist at the expected location: " + targetDir);
+		}
+
+		try {
+			targetDir.delete(EFS.NONE, null);
+		} catch (CoreException e) {
+			throw new ScratchboxException("Failed to delete rootstrap", e);
+		} finally {
+			sdk.refresh();
+		}
+
+		return true;
+	}
+
+	/**
+	 * Verify if a target exists.
+	 * 
+	 * @param targetToRemove
+	 *            the target to verify.
+	 * 
+	 * @return true, if the target exists in Scratchbox; false, otherwise.
+	 * @throws ScratchboxException
+	 *             if some problem occurrs while requesting Scratchbox services.
+	 */
+	private boolean targetExist(String targetToRemove) throws ESboxException {
+		List<String> targetsAvailable = new ListTargetsCommand(
+				commandAbstractor).performCommand(new ArrayList<String>());
+		return targetsAvailable.contains(targetToRemove);
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 1;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ShowPathMappingSb2Command.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ShowPathMappingSb2Command.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/command/ShowPathMappingSb2Command.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.command;
+
+import java.io.ByteArrayOutputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.process.ProcessLauncherCreator;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * Invoke 'sb2-show path' on a list of paths and return the mappings, or
+ * <code>null</code> for unmapped entries
+ * 
+ * @author eswartz
+ * 
+ */
+public class ShowPathMappingSb2Command extends AbstractSb2Command {
+	public ShowPathMappingSb2Command(ICommandAbstractor commandAbstractor) {
+		super(commandAbstractor);
+	}
+
+	@Override
+	protected boolean checkParameters(List<String> param) {
+		return true;
+	}
+
+	public Map<IPath, IPath> performCommand(List<String> params)
+			throws ScratchboxException, ESboxException {
+		List<String> cmdLine = CommandLineArguments
+				.createFromVarArgs(
+						commandAbstractor
+								.getPreferenceValue(SB2PreferenceConstants.SB2_SB2_SHOW_COMMAND),
+						commandAbstractor
+								.getPreferenceValue(SB2PreferenceConstants.SB2_SB2_SHOW_PATH_ACTION));
+		cmdLine.addAll(params);
+
+		IProcessLauncher launcher = ProcessLauncherCreator
+				.createProcessLauncher(commandAbstractor
+						.getProcessLauncherFactory(), null, cmdLine);
+
+		launcher.createProcess();
+
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+		ByteArrayOutputStream err = new ByteArrayOutputStream();
+		launcher.waitAndRead(out, err);
+
+		if (err.size() != 0)
+			throw new ScratchboxException(
+					"Cannot resolve scratchbox2 path mappings:\n" + err);
+
+		String resolveInfo = out.toString().trim();
+		String[] lines = resolveInfo.split("\r\n|\r|\n");
+
+		Map<IPath, IPath> result = new HashMap<IPath, IPath>(lines.length);
+
+		Pattern sb2ShowPattern = Pattern
+				.compile(commandAbstractor
+						.getPreferenceValue(SB2PreferenceConstants.SB2_SB2_SHOW_PATH_OUTPUT_PATTERN));
+
+		for (String line : lines) {
+			Matcher matcher = sb2ShowPattern.matcher(line);
+			if (matcher.matches()) {
+				String toPath = matcher.group(2);
+				// workaround buggy output
+				if (toPath.startsWith("//"))
+					toPath = toPath.substring(1);
+				result.put(new Path(matcher.group(1)), new Path(toPath));
+			}
+		}
+
+		return result;
+	}
+
+	@Override
+	public int getParametersSize() {
+		return 0;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/IScratchbox2SDK.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/IScratchbox2SDK.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/IScratchbox2SDK.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.core;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.machine.IMachine;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+
+public interface IScratchbox2SDK extends IScratchboxSDK {
+
+	/**
+	 * Map<String,Map<String, String>> of sb2 target names to a map of the
+	 * target directory to host directory path mappings
+	 */
+	static final String SB2_TARGET_TO_PATH_MAPPINGS_MAP = "sb2_target_to_path_mappings_map";
+	/** Map<String,String> of sb2 target names to rootstrap paths */
+	static final String SB2_TARGET_TO_ROOTSTRAP_MAP = "sb2_target_to_rootstrap_map";
+
+	/**
+	 * @return
+	 */
+	public IPath getScratchbox2ConfigDirectory();
+
+	/**
+	 * Create a new rootstrap target for Scratchbox 2. The target is named after
+	 * a maemo-rootstrap available target.
+	 * 
+	 * @param targetName
+	 *            the name of the new target.
+	 * @param useHostTools
+	 *            if true, use the host toolchain rather than installing devkits
+	 *            in the rootstrap
+	 * @param force
+	 *            if true, then overwrite any existing rootstrap; if false, then
+	 *            let the user choose (in the console :/) whether to overwrite
+	 *            or keep an existing one
+	 * @return true if succeeded, false if failed
+	 * @throws ESboxException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean createRootstrapTarget(String targetName,
+			boolean useHostTools, boolean force, IProgressMonitor monitor)
+			throws ESboxException;
+
+	/**
+	 * Create a new rootstrap target for Scratchbox 2. The target is named after
+	 * a maemo-rootstrap available target.
+	 * 
+	 * @param targetName
+	 *            the name of the new target.
+	 * @param force
+	 *            if true, then overwrite any existing rootstrap; if false, then
+	 *            let the user choose (in the console :/) whether to overwrite
+	 *            or keep an existing one
+	 * @return true if succeeded, false if failed
+	 * @throws ESboxException
+	 *             if some problem related to Scratchbox communication occurs.
+	 */
+	public boolean removeRootstrap(String targetName, boolean force,
+			IProgressMonitor monitor) throws ESboxException;
+
+	/**
+	 * Get the names of rootstraps already installed. This may inclue those that
+	 * do not have targets associated.
+	 * 
+	 * @param sdk
+	 *            the SDK to check
+	 * @return List, never null
+	 * @throws ESboxException
+	 */
+	public List<String> getInstalledMaemoRootstraps() throws ESboxException;
+
+	/**
+	 * Get the MaemoRootstrap items available for installation. This includes
+	 * any that might already be defined.
+	 * 
+	 * @return List, never null
+	 * @throws ESboxException
+	 */
+	public List<MaemoRootstrap> getAvailableMaemoRootstraps(IMachine machine)
+			throws ESboxException;
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/SB2PreferenceConstants.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/SB2PreferenceConstants.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/SB2PreferenceConstants.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.core;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+/**
+ * This class encapsulates the keys for preference constants defined by
+ * Scratchbox 2.
+ * 
+ * @author eswartz
+ * 
+ */
+public class SB2PreferenceConstants {
+	public static final int VERSION_MAJOR = 17;
+	public static final int VERSION_MINOR = 0;
+
+	/** Get the preference store that contains these preferences */
+	public static IPreferenceStore getPreferenceStore() {
+		return Activator.getDefault().getPreferenceStore();
+	}
+
+	/* SB2 configuration options */
+	public static final String SB2_GDB_REMOTE_QEMU = "SB2_GDB_REMOTE_QEMU";
+	public static final String SB2_CONFIG_COMMAND = "SB2_CONFIG_COMMAND";
+	public static final String SB2_EXEC_COMMAND = "SB2_EXEC_COMMAND";
+	public static final String SB2_INIT_COMMAND = "SB2_INIT_COMMAND";
+	public static final String SB2_VERSION_ACT = "SB2_VERSION_ACT";
+	public static final String SB2_LIST_ACT = "SB2_LIST_ACT";
+	public static final String SB2_MAPPING_MODE = "SB2_MAPPING_MODE";
+	public static final String SB2_INSTALL_MAPPING_MODE = "SB2_INSTALL_MAPPING_MODE";
+	public static final String SB2_LOG_LEVEL = "SB2_LOG_LEVEL";
+	public static final String SB2_INIT_OPT_COMPILER = "SB2_INIT_OPT_COMPILER";
+	public static final String SB2_MAEMO_ROOTSTRAP_COMMAND = "SB2_MAEMO_ROOTSTRAP_COMMAND";
+	public static final String SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT = "SB2_MAEMO_ROOTSTRAP_AVAILABLE_ACT";
+	public static final String SB2_MAEMO_ROOTSTRAP_LIST_ACT = "SB2_MAEMO_ROOTSTRAP_LIST_ACT";
+	public static final String SB2_MAEMO_ROOTSTRAP_INSTALL_ACT = "SB2_MAEMO_ROOTSTRAP_INSTALL_ACT";
+	public static final String SB2_MAEMO_ROOTSTRAP_FORCE_OPT = "SB2_MAEMO_ROOTSTRAP_FORCE_OPT";
+	public static final String SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT = "SB2_MAEMO_ROOTSTRAP_HOST_TOOLS_OPT";
+	public static final String SB2_MAEMO_ROOTSTRAP_REMOVE_ACT = "SB2_MAEMO_ROOTSTRAP_REMOVE_ACT";
+	public static final String SB2_SB2_SHOW_COMMAND = "SB2_SB2_SHOW_COMMAND";
+	public static final String SB2_SB2_SHOW_PATH_ACTION = "SB2_SB2_SHOW_PATH_ACTION";
+	public static final String SB2_SB2_SHOW_PATH_OUTPUT_PATTERN = "SB2_SB2_SHOW_PATH_OUTPUT_PATTERN";
+	public static final String SB2_MAEMO_ROOTSTRAP_PATH_ACT = "SB2_MAEMO_ROOTSTRAP_PATH_ACT";
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2FileSystemMapping.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2FileSystemMapping.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2FileSystemMapping.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,85 @@
+/**
+ * (c) 2008 Nokia
+ */
+package org.maemo.esbox.maemosdk.sb2.core;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.internal.api.core.machine.FileSystemMapping;
+import org.maemo.esbox.internal.api.core.machine.IFileSystemMappingImpl;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+import com.nokia.cpp.internal.api.utils.core.Pair;
+
+/**
+ * Represent the mappings from the machine to a Scratchbox 2 target running on
+ * the machine. This represents the direct mappings with all softlinks resolved.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2FileSystemMapping extends FileSystemMapping implements
+		IFileSystemMappingImpl {
+	/**
+	 * Construct with default path canonicalizers and add mappings for paths
+	 * known to be mapped.
+	 * 
+	 * @param targetRoot
+	 * @param target
+	 */
+	public Scratchbox2FileSystemMapping(Scratchbox2SDKTarget sdkTarget,
+			IPath scratchboxBase, String target, String user) {
+
+		super(FileSystemMapping.getMachineCanonicalizer(true),
+				FileSystemMapping.getMachineCanonicalizer(true));
+
+		List<Pair<IPath, IPath>> mappings = getHostToTargetRootMappings();
+		mappings.clear();
+
+		// directories we're interested in
+		String[] topLevelDirs = { "/dev", "/home", "/proc", "/sys", "/targets",
+				"/bin", "/boot", "/cdrom", "/etc", "/floppy", "/initrd",
+				"/lib", "/media", "/mnt", "/opt", "/root", "/sbin", "/srv",
+				"/usr",
+				"/var",
+
+				// things get messier, so be more specific
+				"/var/cache/apt", "/usr/include", "/usr/lib",
+				"/usr/local/include", "/usr/local/lib", "/usr/X11R6",
+				"/usr/local", "/home/user", };
+
+		List<IPath> topLevelPaths = new ArrayList<IPath>();
+		topLevelPaths.add(new Path("/"));
+		for (String topLevelDir : topLevelDirs) {
+			topLevelPaths.add(new Path(topLevelDir));
+		}
+
+		Map<IPath, IPath> pathMapping = null;
+		try {
+			pathMapping = Scratchbox2SDK.getSb2PathMapping(sdkTarget,
+					topLevelPaths);
+			// pathMapping = ScratchboxFacade.getInstance().getSb2PathMapping(
+			// sdkTarget, topLevelPaths);
+		} catch (ESboxException e) {
+			Activator.getErrorLogger().logError(
+					"Unable to map Scratchbox 2 paths", e);
+			return;
+		}
+
+		for (Map.Entry<IPath, IPath> entry : pathMapping.entrySet()) {
+			map(mappings, entry.getValue(), entry.getKey());
+		}
+
+		setHostToTargetRootMappings(mappings);
+	}
+
+	private void map(List<Pair<IPath, IPath>> mappings, IPath from, IPath to) {
+		mappings.add(new Pair<IPath, IPath>(from, to));
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDK.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDK.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDK.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,544 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API. Implementation from ScratchboxFacade 
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.maemo.esbox.core.CorePreferenceConstants;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.machine.IMachine;
+import org.maemo.esbox.core.sdk.IPreferenceProvider;
+import org.maemo.esbox.core.sdk.ISDKPlatform;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.internal.api.core.sdk.BaseSDKPlatform;
+import org.maemo.esbox.maemosdk.core.command.ICommandAbstractor;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDK;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.core.sdk.MachineUtils;
+import org.maemo.esbox.maemosdk.core.sdk.MaemoUtils;
+import org.maemo.esbox.maemosdk.core.sdk.CacheUtils;
+import org.maemo.esbox.maemosdk.sb2.command.CreateMaemoRootstrapSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.CreateTargetSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.GetCurrentTargetSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.GetMaemoRootstrapLocationCommand;
+import org.maemo.esbox.maemosdk.sb2.command.GetVersionScratchboxCommand;
+import org.maemo.esbox.maemosdk.sb2.command.ListAvailableMaemoRootstrapsSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.ListCompilersSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.ListCputranspSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.ListInstalledMaemoRootstrapsSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.ListTargetsCommand;
+import org.maemo.esbox.maemosdk.sb2.command.RemoveMaemoRootstrapSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.RemoveTargetSb2Command;
+import org.maemo.esbox.maemosdk.sb2.command.ShowPathMappingSb2Command;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+/**
+ * @author baranov
+ * 
+ */
+public class Scratchbox2SDK extends AbstractScratchboxSDK implements
+		IScratchbox2SDK {
+
+	private static final IPath ROOT_PATH = new Path("/");
+	private static Pattern TARGET_PLATFORM_VERSION_ARCHITECTURE_PATTERN = Pattern
+			.compile("([a-zA-Z_]+)(\\d+)_([a-zA-Z]+)");
+
+	private static final String SB2_MACHINE = "sb2_machine";
+	private static final String SB2_VERSION = "sb2_version";
+
+	public Scratchbox2SDK(IMachine machine, String version,
+			IPreferenceProvider prefProvider) {
+		super(machine, version, "Scratchbox 2", SB2_MACHINE, SB2_VERSION,
+				"sb2_targets", 2);
+		this.prefProvider = prefProvider;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDK#refresh()
+	 */
+	public void refresh() {
+		super.refresh();
+		List<String> targetNames;
+		try {
+			targetNames = getTargets();
+		} catch (ESboxException e) {
+			Activator.getErrorLogger().logError("Could not refresh targets", e);
+			return;
+		}
+		List<ISDKTarget> newTargets = new ArrayList<ISDKTarget>();
+		for (String target : targetNames) {
+			// ignore this one, left behind by errant rootstrap installations
+			if (target.equals("libtool_build"))
+				continue;
+			IPath config = getScratchbox2ConfigDirectory();
+			IPath sb2BasePath = config.append(target);
+			Scratchbox2SDKTarget sdkTarget = new Scratchbox2SDKTarget(this,
+					getPlatform(target), getArchitecture(target), target,
+					sb2BasePath);
+			newTargets.add(sdkTarget);
+
+			try {
+				IPath sb2RootstrapPath = getMaemoRootstrapPath(sdkTarget);
+				sdkTarget.setRootstrapPath(sb2RootstrapPath);
+			} catch (ESboxException e) {
+				Activator.getErrorLogger().logError(null, e);
+			}
+
+		}
+		this.targets = newTargets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getTargets()
+	 */
+	public List<String> getTargets() throws ESboxException {
+		MachineUtils.ensureCurrentMachine(SB_MACHINE, this.getMachine());
+
+		String[] targetsArray = (String[]) CacheUtils.getInstance()
+				.getCachedValue(SB_TARGETS);
+		if (targetsArray != null)
+			return Arrays.asList(targetsArray);
+
+		ListTargetsCommand listTargetsCommand = new ListTargetsCommand(
+				getCommandAbstractor());
+		List<String> targets = listTargetsCommand
+				.performCommand(new ArrayList<String>());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS,
+				(String[]) targets.toArray(new String[targets.size()]));
+
+		return targets;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDK#getCommandAbstractor
+	 * ()
+	 */
+	public ICommandAbstractor getCommandAbstractor() throws ESboxException {
+		return getSb2WrappedAbstractor(super.getCommandAbstractor(), this
+				.getMachine());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK#
+	 * getScratchbox2ConfigDirectory()
+	 */
+	public IPath getScratchbox2ConfigDirectory() {
+		String userName = prefProvider
+				.getPreferenceValue(CorePreferenceConstants.USER);
+		if (userName.length() == 0)
+			userName = "ubuntu";
+		return new Path("home").append(userName).append(".scratchbox2")
+				.makeAbsolute();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#createTarget(java.lang
+	 * .String, java.lang.String, java.lang.String, java.lang.String)
+	 */
+	public boolean createTarget(String targetName, String compiler,
+			String devkits, String cputransp) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(compiler);
+		params.add(cputransp);
+
+		CreateTargetSb2Command createTargetCommand = new CreateTargetSb2Command(
+				this, getCommandAbstractor());
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+
+		return (Boolean) createTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getCompilers()
+	 */
+	public List<String> getCompilers() throws ESboxException {
+		ListCompilersSb2Command listCompilersCommand = new ListCompilersSb2Command(
+				getCommandAbstractor());
+		return listCompilersCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getCputransp()
+	 */
+	public List<String> getCputransp() throws ESboxException {
+		ListCputranspSb2Command listCputranspCommand = new ListCputranspSb2Command(
+				getCommandAbstractor());
+		return listCputranspCommand.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#getCurrentTarget()
+	 */
+	public String getCurrentTarget() throws ESboxException {
+		GetCurrentTargetSb2Command getCurrentTargetCommand = new GetCurrentTargetSb2Command(
+				getCommandAbstractor());
+		return (String) getCurrentTargetCommand
+				.performCommand(new ArrayList<String>());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK#removeTarget(java.lang
+	 * .String)
+	 */
+	public boolean removeTarget(String targetName) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+
+		RemoveTargetSb2Command removeTargetCommand;
+		removeTargetCommand = new RemoveTargetSb2Command(this,
+				getCommandAbstractor());
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+		CacheUtils.getInstance().setCachedValue(
+				SB2_TARGET_TO_PATH_MAPPINGS_MAP, null);
+		CacheUtils.getInstance().setCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP,
+				null);
+		return (Boolean) removeTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDK#getSDKRoot()
+	 */
+	public IPath getSDKRoot() {
+		return ROOT_PATH;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.maemosdk.core.sdk.
+	 * IScratchboxSDKPlatformArchitectureProvider
+	 * #getArchitecture(java.lang.String)
+	 */
+	public String getArchitecture(String target) {
+		// convention says this is the part of the target after the underscore
+		Matcher matcher = TARGET_PLATFORM_VERSION_ARCHITECTURE_PATTERN
+				.matcher(target);
+		if (matcher.matches()) {
+			return matcher.group(3).toUpperCase();
+		} else {
+			return IScratchboxSDKTarget.ARCHITECTURE_UNKNOWN;
+		}
+	}
+
+	public ISDKPlatform getPlatform(String target) {
+		// convention says this is the part of the target before the underscore,
+		// minus a version.
+		Matcher matcher = TARGET_PLATFORM_VERSION_ARCHITECTURE_PATTERN
+				.matcher(target);
+		if (matcher.matches()) {
+			String name = matcher.group(1);
+			String platformName = name.substring(0, 1).toUpperCase()
+					+ name.substring(1).toLowerCase();
+			String versionInfo = matcher.group(2);
+			String version = ISDKPlatform.VERSION_UNKNOWN;
+			if (versionInfo.length() == 2)
+				version = versionInfo.substring(0, 1) + "."
+						+ versionInfo.substring(1, 2);
+			return new BaseSDKPlatform(platformName, version);
+		} else {
+			return new BaseSDKPlatform(ISDKPlatform.NAME_UNKNOWN,
+					ISDKPlatform.VERSION_UNKNOWN);
+		}
+	}
+
+	/**
+	 * Get the names of rootstraps already installed. This may inclue those that
+	 * do not have targets associated.
+	 * 
+	 * @param sdk
+	 *            the SDK to check
+	 * @return List, never null
+	 * @throws ESboxException
+	 */
+	public synchronized List<String> getInstalledMaemoRootstraps()
+			throws ESboxException {
+		ListInstalledMaemoRootstrapsSb2Command command = new ListInstalledMaemoRootstrapsSb2Command(
+				MachineUtils.getHostCommandAbstractor(this.getMachine()));
+		return command.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK#getAvailableMaemoRootstraps
+	 * (org.maemo.esbox.core.machine.IMachine)
+	 */
+	public List<MaemoRootstrap> getAvailableMaemoRootstraps(IMachine machine)
+			throws ESboxException {
+		ListAvailableMaemoRootstrapsSb2Command command = new ListAvailableMaemoRootstrapsSb2Command(
+				MachineUtils.getHostCommandAbstractor(machine));
+		return command.performCommand(EMPTY_ARGS);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK#createRootstrapTarget
+	 * (java.lang.String, boolean, boolean,
+	 * org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public boolean createRootstrapTarget(String targetName,
+			boolean useHostTools, boolean force, IProgressMonitor monitor)
+			throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(Boolean.toString(useHostTools));
+		params.add(Boolean.toString(force));
+
+		CreateMaemoRootstrapSb2Command createTargetCommand = new CreateMaemoRootstrapSb2Command(
+				this, getCommandAbstractor(), monitor);
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+
+		return createTargetCommand.performCommand(params);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK#removeRootstrap(java
+	 * .lang.String, boolean, org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public boolean removeRootstrap(String targetName, boolean force,
+			IProgressMonitor monitor) throws ESboxException {
+		List<String> params = new ArrayList<String>();
+		params.add(targetName);
+		params.add(Boolean.toString(force));
+
+		RemoveMaemoRootstrapSb2Command removeTargetCommand = new RemoveMaemoRootstrapSb2Command(
+				getCommandAbstractor(), monitor);
+
+		CacheUtils.getInstance().setCachedValue(SB_TARGETS, null);
+		CacheUtils.getInstance().setCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP,
+				null);
+		CacheUtils.getInstance().setCachedValue(
+				SB2_TARGET_TO_PATH_MAPPINGS_MAP, null);
+
+		return removeTargetCommand.performCommand(params);
+	}
+
+	/**
+	 * Invoke sb2-show path on the given path(s) to return the mappings.
+	 * 
+	 * @param hostPaths
+	 *            array of paths to map
+	 * @return map of resolved host paths to target paths
+	 * @throws ESboxException
+	 */
+	public static synchronized Map<IPath, IPath> getSb2PathMapping(
+			IScratchboxSDKTarget sdkTarget, List<IPath> hostPaths)
+			throws ESboxException {
+		// find cached value
+		MachineUtils.ensureCurrentMachine(SB2_MACHINE, sdkTarget.getSDK()
+				.getMachine());
+		Map<String, Map<String, String>> targetToPathMappingsMap = null;
+		Map<String, String> storedPathMappings = null;
+		targetToPathMappingsMap = (Map<String, Map<String, String>>) CacheUtils
+				.getInstance().getCachedValue(SB2_TARGET_TO_PATH_MAPPINGS_MAP);
+		if (targetToPathMappingsMap != null) {
+			storedPathMappings = targetToPathMappingsMap.get(sdkTarget
+					.getName());
+		}
+
+		Map<IPath, IPath> returnedPathMappings = new HashMap<IPath, IPath>();
+
+		// locate entries known to the cache
+		List<IPath> needToLookupHostPaths;
+		if (storedPathMappings != null) {
+			needToLookupHostPaths = new ArrayList<IPath>();
+			for (IPath hostPath : hostPaths) {
+				String targetPath = storedPathMappings.get(hostPath
+						.toPortableString());
+				if (targetPath != null) {
+					returnedPathMappings.put(hostPath, new Path(targetPath));
+				} else {
+					needToLookupHostPaths.add(hostPath);
+				}
+			}
+		} else {
+			needToLookupHostPaths = hostPaths;
+		}
+
+		if (needToLookupHostPaths.size() == 0) {
+			return returnedPathMappings;
+		}
+
+		// do the hard work for the paths not covered by the cache
+		ShowPathMappingSb2Command command = new ShowPathMappingSb2Command(
+				MaemoUtils.getCommandAbstractor(sdkTarget));
+		List<String> paths = new ArrayList<String>(needToLookupHostPaths.size());
+		for (IPath path : needToLookupHostPaths) {
+			paths.add(path.toPortableString());
+		}
+
+		Map<IPath, IPath> newPathMappings = (Map<IPath, IPath>) command
+				.performCommand(paths);
+		returnedPathMappings.putAll(newPathMappings);
+
+		// update cache
+		if (storedPathMappings == null) {
+			storedPathMappings = new HashMap<String, String>();
+		}
+		for (Map.Entry<IPath, IPath> entry : newPathMappings.entrySet()) {
+			storedPathMappings.put(entry.getKey().toPortableString(), entry
+					.getValue().toPortableString());
+		}
+		if (targetToPathMappingsMap == null) {
+			targetToPathMappingsMap = new HashMap<String, Map<String, String>>();
+		}
+		targetToPathMappingsMap.put(sdkTarget.getName(), storedPathMappings);
+
+		CacheUtils.getInstance().setCachedValue(
+				SB2_TARGET_TO_PATH_MAPPINGS_MAP, targetToPathMappingsMap);
+
+		return returnedPathMappings;
+	}
+
+	/**
+	 * Return the current version of Scratchbox 2
+	 * 
+	 * @return the current version of Scratchbox 2.
+	 * @throws ESboxException
+	 *             if any problem related to Scratchbox communication occurs,
+	 *             including no scratchbox 2 detected
+	 */
+	public static synchronized String getCurrentSbox2Version(IMachine machine)
+			throws ESboxException {
+		// find cached value
+		MachineUtils.ensureCurrentMachine(SB2_MACHINE, machine);
+		String version = (String) CacheUtils.getInstance().getCachedValue(
+				SB2_VERSION);
+		if (version != null)
+			return version;
+
+		// do the hard work
+		MachineUtils.acquireMachine(machine);
+		ICommandAbstractor commandAbstractor = MachineUtils
+				.getHostCommandAbstractor(machine);
+		commandAbstractor = getSb2WrappedAbstractor(commandAbstractor, machine);
+		GetVersionScratchboxCommand getVersionCommand = new GetVersionScratchboxCommand(
+				commandAbstractor);
+
+		String currentVersion = getVersionCommand
+				.performCommand(new ArrayList<String>());
+		// remember cached value
+		CacheUtils.getInstance().setCachedValue(SB2_VERSION, currentVersion);
+
+		return currentVersion;
+	}
+
+	/**
+	 * Get the path where a maemo rootstrap is installed
+	 * 
+	 * @param scratchbox2SDKTarget
+	 * @return path of rootstrap
+	 * @throws ESboxException
+	 *             if not located
+	 */
+	private synchronized IPath getMaemoRootstrapPath(
+			Scratchbox2SDKTarget sdkTarget) throws ESboxException {
+		// find cached value
+		MachineUtils.ensureCurrentMachine(SB_MACHINE, sdkTarget.getSDK()
+				.getMachine());
+		Map<String, String> targetToRootstrapMap = null;
+		targetToRootstrapMap = (Map<String, String>) CacheUtils.getInstance()
+				.getCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP);
+		if (targetToRootstrapMap != null) {
+			String rootstrap = targetToRootstrapMap.get(sdkTarget.getName());
+			if (rootstrap != null) {
+				return new Path(rootstrap);
+			}
+		}
+
+		// do the hard work
+		GetMaemoRootstrapLocationCommand command = new GetMaemoRootstrapLocationCommand(
+				getCommandAbstractor(), sdkTarget);
+		IPath rootstrapPath;
+
+		// be sure to record something in the cache for broken targets so
+		// we don't keep asking all the time
+		ESboxException caughtException = null;
+		try {
+			rootstrapPath = (IPath) command.performCommand(EMPTY_ARGS);
+		} catch (ESboxException e) {
+			rootstrapPath = Path.EMPTY;
+			caughtException = e;
+		}
+
+		// store cached value
+		if (targetToRootstrapMap == null)
+			targetToRootstrapMap = new HashMap<String, String>();
+		targetToRootstrapMap.put(sdkTarget.getName(), rootstrapPath
+				.toPortableString());
+		CacheUtils.getInstance().setCachedValue(SB2_TARGET_TO_ROOTSTRAP_MAP,
+				targetToRootstrapMap);
+
+		if (caughtException != null)
+			throw caughtException;
+
+		return rootstrapPath;
+	}
+
+	/**
+	 * Get a command abstractor that updates the PATH if sb2 tools are not on
+	 * the path.
+	 * 
+	 * @param commandAbstractor
+	 * @param machine
+	 * @return
+	 */
+	private static ICommandAbstractor getSb2WrappedAbstractor(
+			ICommandAbstractor commandAbstractor, IMachine machine) {
+		// XXX: the default path should be provided some other way
+		return wrapCommandAbstractorForSDK(commandAbstractor, machine, "sb2",
+				"/usr/bin");
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDKTarget.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDKTarget.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/core/Scratchbox2SDKTarget.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Petr Baranov (Nokia) - initial API. Implementation from ScratchboxFacade 
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.core.CorePreferenceConstants;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.IProcessLauncherFactory;
+import org.maemo.esbox.core.sdk.ISDKPlatform;
+import org.maemo.esbox.maemosdk.core.sdk.AbstractScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget;
+import org.maemo.esbox.maemosdk.sb2.command.GetGdbQemuCommandPatternCommand;
+import org.maemo.esbox.maemosdk.sb2.launcher.Scratchbox2ProcessLauncherFactory;
+
+/**
+ * @author baranov
+ * 
+ */
+public class Scratchbox2SDKTarget extends AbstractScratchboxSDKTarget {
+	private IPath targetRoot;
+	private IPath rootstrapRoot;
+
+	public Scratchbox2SDKTarget(Scratchbox2SDK sdk, ISDKPlatform platform,
+			String architecture, String target, IPath targetRoot) {
+		super(sdk, platform, architecture, target);
+		if (targetRoot == null)
+			throw new IllegalArgumentException();
+		this.targetRoot = targetRoot;
+		init(new Scratchbox2FileSystemMapping(this, targetRoot, target, sdk
+				.getPreferenceValue(CorePreferenceConstants.USER))
+		// ,new AptPackageManager(this)
+		);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#
+	 * getProcessLauncherFactoryForInstall()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactoryForInstall() {
+		// install mode needs to be a different mapping and also run as root
+		return new Scratchbox2ProcessLauncherFactory(this,
+				SB2PreferenceConstants.SB2_INSTALL_MAPPING_MODE, true);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDKTarget#getRootstrapPath()
+	 */
+	public IPath getRootstrapPath() {
+		return rootstrapRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDKTarget#getProcessLauncherFactory()
+	 */
+	public IProcessLauncherFactory getProcessLauncherFactory() {
+		// default is build mode
+		return new Scratchbox2ProcessLauncherFactory(this,
+				SB2PreferenceConstants.SB2_MAPPING_MODE, false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDKTarget#getSDKTargetRoot()
+	 */
+	public IPath getSDKTargetRoot() {
+		return targetRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.internal.api.core.sdk.BaseSDKTarget#getArchitecture()
+	 */
+	public String getArchitecture() {
+		// sb2 doesn't YET ship an x86 emulator
+		return IScratchboxSDKTarget.ARCHITECTURE_ARMEL;
+	}
+
+	/**
+	 * Get the command template for launching qemu under gdb with this target
+	 * 
+	 * @param sdkTarget
+	 * @param architecture
+	 *            one of {@link IScratchboxSDKTarget#ARCHITECTURE_ARMEL} or
+	 *            {@link IScratchboxSDKTarget#ARCHITECTURE_X86}; usually from
+	 *            sdkTarget.getArchitecture()
+	 * @return String or null if no cputransp used or not using qemu
+	 */
+	public synchronized String getGdbQemuCommandPattern(String architecture)
+			throws ESboxException {
+		// ScratchboxSDK2 sdk = (ScratchboxSDK2)this.getSDK();
+		GetGdbQemuCommandPatternCommand command = new GetGdbQemuCommandPatternCommand(
+				this, this.getCommandAbstractor());
+		List<String> arguments = new ArrayList<String>(1);
+		arguments.add(architecture);
+		return command.performCommand(arguments);
+	}
+
+	/** Not API! The targets should be refreshed from ISDK#refresh() */
+	void setRootstrapPath(IPath rootstrapPath) {
+		this.rootstrapRoot = rootstrapPath;
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/internal/Activator.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/internal/Activator.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/internal/Activator.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,157 @@
+package org.maemo.esbox.maemosdk.sb2.internal;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Plugin;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.maemo.esbox.core.ErrorLogger;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends Plugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.maemo.esbox.maemosdk.sdk2";
+
+	// The shared instance
+	private static Activator plugin;
+
+	private IPreferenceStore preferenceStore;
+
+	/**
+	 * The constructor
+	 */
+	public Activator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 * 
+	 * @return the shared instance
+	 */
+	public static Activator getDefault() {
+		return plugin;
+	}
+
+	/**
+	 * Return the error logger instance of this plug-in.
+	 * 
+	 * @return the error logger instance of this plug-in.
+	 */
+	public static ErrorLogger getErrorLogger() {
+		class CoreErrorLogger extends ErrorLogger {
+
+			@Override
+			public String getPluginID() {
+				return PLUGIN_ID;
+			}
+
+			@Override
+			public Plugin getPlugin() {
+				return Activator.getDefault();
+			}
+
+		}
+
+		return new CoreErrorLogger();
+	}
+
+	/**
+	 * Returns an image descriptor for the image file at the given plug-in
+	 * relative path.
+	 * 
+	 * @param path
+	 *            the path
+	 * @return the image descriptor
+	 */
+	public static ImageDescriptor getImageDescriptor(String path) {
+		return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, path);
+	}
+
+	/**
+	 * Find a file relative to the plugin, either in a running workspace or a
+	 * standalone unit test (assumed to run relative to a plugin)
+	 * 
+	 * @param path
+	 */
+	public static InputStream getPluginRelativeInputStream(String path)
+			throws IOException {
+		if (getDefault() != null) {
+			return FileLocator.openStream(getDefault().getBundle(), new Path(
+					path), false);
+		} else {
+			return new FileInputStream("../" + path);
+		}
+	}
+
+	/**
+	 * Returns the preference store for this UI plug-in. This preference store
+	 * is used to hold persistent settings for this plug-in in the context of a
+	 * workbench. Some of these settings will be user controlled, whereas others
+	 * may be internal setting that are never exposed to the user.
+	 * <p>
+	 * If an error occurs reading the preference store, an empty preference
+	 * store is quietly created, initialized with defaults, and returned.
+	 * </p>
+	 * <p>
+	 * <strong>NOTE:</strong> As of Eclipse 3.1 this method is no longer
+	 * referring to the core runtime compatibility layer and so plug-ins relying
+	 * on Plugin#initializeDefaultPreferences will have to access the
+	 * compatibility layer themselves.
+	 * </p>
+	 * 
+	 * @return the preference store
+	 */
+	public IPreferenceStore getPreferenceStore() {
+		// Create the preference store lazily.
+		if (preferenceStore == null) {
+			preferenceStore = new ScopedPreferenceStore(new InstanceScope(),
+					getBundle().getSymbolicName());
+
+		}
+		return preferenceStore;
+	}
+
+	/**
+	 * @param object
+	 * @param e
+	 * @return
+	 */
+	public static IStatus createErrorStatus(String msg, Throwable t) {
+		return new Status(IStatus.ERROR, PLUGIN_ID, msg, t);
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2EnvironmentProvider.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2EnvironmentProvider.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2EnvironmentProvider.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.launcher;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.EnvironmentProperties;
+import org.maemo.esbox.core.process.ProcessLauncherUtils;
+import org.maemo.esbox.core.process.ProcessLauncherUtils.Results;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.internal.api.core.IStandardEnvironmentProvider;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2EnvironmentProvider implements
+		IStandardEnvironmentProvider {
+	public static Map<ISDKTarget, Properties> cachedStdEnvMap = new HashMap<ISDKTarget, Properties>();
+	private final ISDKTarget sdkTarget;
+
+	/**
+	 * @param sdkTarget
+	 */
+	public Scratchbox2EnvironmentProvider(ISDKTarget sdkTarget) {
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * flushRawEnvironment()
+	 */
+	public void flushRawEnvironment() {
+		cachedStdEnvMap.remove(sdkTarget);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @seeorg.maemo.esbox.internal.api.core.IStandardEnvironmentProvider#
+	 * getRawEnvironment()
+	 */
+	public Properties getRawEnvironment() {
+		Properties standardEnv = cachedStdEnvMap.get(sdkTarget);
+		if (standardEnv == null) {
+			// gather arguments by querying a typical shell launched in POSIX
+			// mode (sh instead of bash)
+			Scratchbox2ProcessLauncher launcher = new Scratchbox2ProcessLauncher(
+					sdkTarget, null, CommandLineArguments.createFromVarArgs(
+							"sh", "-c", "set"), null,
+					SB2PreferenceConstants.SB2_MAPPING_MODE, false);
+
+			try {
+				Results results = ProcessLauncherUtils
+						.launchAndReadStandardStreams(launcher, null);
+				standardEnv = EnvironmentProperties
+						.createFromShellEnvDump(results.stdout);
+			} catch (ESboxException e) {
+				Activator
+						.getErrorLogger()
+						.logError(
+								"Failed to read scratchbox environment; using system environment",
+								e);
+				standardEnv = sdkTarget.getSDK().getMachine()
+						.getStandardEnvironment();
+			}
+
+			cachedStdEnvMap.put(sdkTarget, standardEnv);
+		}
+		return standardEnv;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncher.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncher.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncher.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.launcher;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.BaseProcessLauncher;
+import org.maemo.esbox.core.process.CommandLineArguments;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.process.ShellTemplateSubstitutor;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * For SB 2, launching is easy and follows the same pattern as a normal program
+ * invocation.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2ProcessLauncher extends BaseProcessLauncher implements
+		IProcessLauncher {
+
+	private ISDKTarget sdkTarget;
+
+	public Scratchbox2ProcessLauncher(ISDKTarget sdkTarget,
+			IPath workingDirectory, List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock, String modeKey,
+			boolean runAsRoot) {
+		super(encodeArgumentArray(sdkTarget, cmdLine, modeKey),
+				environmentModifierBlock, workingDirectory);
+		if (runAsRoot) {
+			getLaunchCommandArguments().add(0, "sudo");
+		}
+		if (sdkTarget == null)
+			throw new IllegalArgumentException();
+		this.sdkTarget = sdkTarget;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.internal.core.BaseProcessLauncher#getLaunchInfoPrefix()
+	 */
+	@Override
+	protected String getLaunchInfoPrefix() {
+		return sdkTarget + " ";
+	}
+
+	private static List<String> encodeArgumentArray(ISDKTarget sdkTarget,
+			List<String> cmdLine, String modeKey) {
+
+		// Encode the launch command by replacing the arguments
+		// representing template arguments with the actual values.
+		//
+		ShellTemplateSubstitutor substitutor = new ShellTemplateSubstitutor();
+
+		substitutor.define("TARGET", sdkTarget.getName());
+		substitutor.define("COMMAND", cmdLine.get(0));
+		substitutor.define("ARGS", CommandLineArguments.toCommandLine(cmdLine
+				.subList(1, cmdLine.size())));
+
+		String level = sdkTarget
+				.getPreferenceValue(SB2PreferenceConstants.SB2_LOG_LEVEL);
+		if (level.length() > 0) {
+			substitutor.define("LOG_OPTION", "-L " + level);
+		} else {
+			substitutor.define("LOG_OPTION", "");
+		}
+
+		String mapMode = sdkTarget.getPreferenceValue(modeKey);
+		substitutor.define("MAPPING_MODE", mapMode);
+
+		// get the Scratchbox invocation pattern
+		String commandPattern = sdkTarget
+				.getPreferenceValue(SB2PreferenceConstants.SB2_EXEC_COMMAND);
+
+		// replace variables
+		commandPattern = substitutor.substitute(commandPattern);
+
+		List<String> commandArgs = CommandLineArguments
+				.createFromCommandLine(commandPattern);
+		return commandArgs;
+	}
+
+	@Override
+	protected void setupForLaunch() throws ScratchboxException {
+		// nothing
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.internal.core.BaseProcessLauncher#doCreateProcess()
+	 */
+	@Override
+	protected Process doCreateProcess() throws Exception {
+		return sdkTarget.getSDK().getMachine().createProcess(
+				getLaunchCurrentWorkingDirectory(),
+				getLaunchCommandArguments(),
+				getLaunchEnvironmentModifierBlock(), isUsePTY());
+	}
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncherFactory.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncherFactory.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/launcher/Scratchbox2ProcessLauncherFactory.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.launcher;
+
+import java.util.List;
+
+import org.eclipse.core.runtime.IPath;
+import org.maemo.esbox.core.env.IEnvironmentModifierBlock;
+import org.maemo.esbox.core.process.IProcessLauncher;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.internal.api.core.BaseProcessLauncherFactory;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2ProcessLauncherFactory extends
+		BaseProcessLauncherFactory {
+
+	protected ISDKTarget sdkTarget;
+	private String mappingModeKey;
+	private final boolean runAsRoot;
+
+	/**
+	 * Create a factory and specify whether it is creating commands in build
+	 * mode (sb2 -m maemo) or installation mode (sb2 -e)
+	 * 
+	 * @param sdkTarget
+	 * @param mappingModeKey
+	 *            one of SB2PreferenceConstants.MAPPING_MODE or
+	 *            SB2PreferenceConstants.INSTALL_MAPPING_MODE
+	 * @param isBuildMode
+	 *            true: build mode, false: installation mode
+	 */
+	public Scratchbox2ProcessLauncherFactory(ISDKTarget sdkTarget,
+			String mappingModeKey, boolean runAsRoot) {
+		super(new Scratchbox2EnvironmentProvider(sdkTarget), false);
+		if (sdkTarget == null)
+			throw new IllegalArgumentException();
+		this.sdkTarget = sdkTarget;
+		this.mappingModeKey = mappingModeKey;
+		this.runAsRoot = runAsRoot;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.core.IProcessLauncherFactory#createProcessLauncher(org
+	 * .eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath,
+	 * org.maemo.esbox.core.List<String>, java.util.Properties)
+	 */
+	protected IProcessLauncher doCreateProcessLauncher(IPath workingDirectory,
+			List<String> cmdLine,
+			IEnvironmentModifierBlock environmentModifierBlock) {
+
+		return new Scratchbox2ProcessLauncher(sdkTarget, workingDirectory,
+				cmdLine, environmentModifierBlock, mappingModeKey, runAsRoot);
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/provider/Scratchbox2SDKProvider.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/provider/Scratchbox2SDKProvider.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/provider/Scratchbox2SDKProvider.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.provider;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.maemo.esbox.core.CorePreferenceManager;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.ErrorLogger;
+import org.maemo.esbox.core.machine.IMachine;
+import org.maemo.esbox.core.machine.MachineRegistry;
+import org.maemo.esbox.core.sdk.IPreferenceProvider;
+import org.maemo.esbox.core.sdk.ISDK;
+import org.maemo.esbox.core.sdk.ISDKProvider;
+import org.maemo.esbox.internal.api.core.sdk.UserAwarePreferenceProviderWrapper;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.core.sdk.CacheUtils;
+import org.maemo.esbox.maemosdk.sb2.core.Scratchbox2SDK;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+
+/**
+ * This implementation of the SDK provider searches for SB2 targets using the
+ * 'sb2-config -l' command. If any aspect of SB2 communication fails, we assume
+ * SB2 is not installed.
+ * 
+ * @author eswartz
+ * 
+ */
+public class Scratchbox2SDKProvider implements ISDKProvider {
+
+	// this may need to be bumped once an official release is made
+	private static final String SCRATCHBOX_VERSION_PATTERN = "1\\.99\\..*"; //$NON-NLS-1$
+
+	/**
+	 * 
+	 */
+	public Scratchbox2SDKProvider() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.maemo.esbox.core.sdk.ISDKProvider#createSDKs()
+	 */
+	public List<ISDK> createSDKs() throws ESboxException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		List<ISDK> sdks = new ArrayList<ISDK>();
+		for (IMachine machine : MachineRegistry.getInstance()
+				.getBuildMachines()) {
+			// will never find sbox on host (right?!)
+			if (machine.getOS().equals(Platform.OS_WIN32))
+				continue;
+
+			try {
+				IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
+						CorePreferenceManager.getInstance()
+								.getPreferenceProvider(), machine);
+				Scratchbox2SDK sdk = getMachineSDK(prefProvider, machine);
+				if (sdk != null) {
+					sdks.add(sdk);
+					sdk.refresh();
+				}
+			} catch (ScratchboxException e) {
+				logger.log(IStatus.INFO,
+						"Problem scanning Scratchbox 2 installation", e);
+			}
+		}
+
+		CacheUtils.getInstance().saveCachedData();
+
+		return sdks;
+	}
+
+	/**
+	 * @param logger
+	 * @param prefProvider
+	 * @param sdks
+	 * @return
+	 * @throws ScratchboxException
+	 */
+	private Scratchbox2SDK getMachineSDK(IPreferenceProvider prefProvider,
+			IMachine machine) throws ESboxException {
+		ErrorLogger logger = Activator.getErrorLogger();
+
+		// only support one Scratchbox 2 installation
+		String version = Scratchbox2SDK.getCurrentSbox2Version(machine);
+		if (version == null) {
+			// no scratchbox?
+			return null;
+		}
+
+		if (!version.matches(SCRATCHBOX_VERSION_PATTERN)) {
+			logger
+					.logError(
+							MessageFormat
+									.format(
+											"Only Scratchbox 2 version 1.99.x is supported (detected {0}); disabling Scratchbox 2 support",
+											version), null);
+			return null;
+		}
+
+		Scratchbox2SDK sdk = new Scratchbox2SDK(machine, version, prefProvider);
+
+		return sdk;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoSDKInstallTargetAdapterFactory.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.ui.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.maemo.esbox.core.adapters.ISDKManageTargetAdapter;
+import org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoSDKInstallTargetAdapterFactory implements IAdapterFactory {
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
+	 * java.lang.Class)
+	 */
+	public Object getAdapter(Object adaptableObject, Class adapterType) {
+		if (adapterType.equals(ISDKManageTargetAdapter.class)) {
+			if (adaptableObject instanceof IScratchbox2SDK) {
+				return new MaemoScratchbox2SDKManageTargetAdapter(
+						(IScratchbox2SDK) adaptableObject);
+			}
+		}
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+	 */
+	public Class[] getAdapterList() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/adapters/MaemoScratchbox2SDKManageTargetAdapter.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,185 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.ui.adapters;
+
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.wizard.WizardDialog;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.Policy;
+import org.maemo.esbox.core.adapters.ISDKManageTargetAdapter;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.core.sdk.IScratchboxSDK;
+import org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+import org.maemo.esbox.maemosdk.sb2.ui.wizard.NewScratchbox2TargetWizard;
+import org.maemo.esbox.maemosdk.ui.adapters.ESboxTargetRemover;
+import org.maemo.esbox.maemosdk.ui.adapters.MaemoScratchboxSDKManageTargetAdapterBase;
+
+/**
+ * @author eswartz
+ * 
+ */
+public class MaemoScratchbox2SDKManageTargetAdapter extends
+		MaemoScratchboxSDKManageTargetAdapterBase implements
+		ISDKManageTargetAdapter {
+
+	private final IScratchbox2SDK sdk;
+
+	/**
+	 * @param sdk
+	 */
+	public MaemoScratchbox2SDKManageTargetAdapter(IScratchbox2SDK sdk) {
+		this.sdk = sdk;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.core.adapters.ISDKManageTargetAdapter#installSDKTargets
+	 * (org.eclipse.swt.widgets.Shell, java.util.List)
+	 */
+	public IStatus installSDKTargets(Shell shell, List<ISDKTarget> installed) {
+		NewScratchbox2TargetWizard targetWizard;
+
+		targetWizard = new NewScratchbox2TargetWizard(sdk);
+		WizardDialog dlg = new WizardDialog(shell, targetWizard);
+		if (dlg.open() == Dialog.OK) {
+			return Status.OK_STATUS;
+		}
+
+		return Policy.getCancelStatus(Activator.getDefault());
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.maemo.esbox.core.adapters.ISDKTargetInstallerAdapter#removeSDKTarget
+	 * (org.eclipse.swt.widgets.Shell, org.maemo.esbox.core.sdk.ISDKTarget)
+	 */
+	public IStatus removeSDKTarget(Shell shell, ISDKTarget selectedTarget) {
+		final boolean[] deleteRootstrap = { false };
+		boolean rootstrapUsed_ = false;
+		try {
+			// see if a rootstrap -- possibly disconnected from the target --
+			// exists
+			List<MaemoRootstrap> rootstraps = sdk
+					.getAvailableMaemoRootstraps(selectedTarget.getSDK()
+							.getMachine());
+			for (MaemoRootstrap rootstrap : rootstraps) {
+				if (rootstrap.getName().equals(selectedTarget.getName())) {
+					rootstrapUsed_ = true;
+					break;
+				}
+			}
+		} catch (ESboxException e1) {
+			Activator.getErrorLogger().logError(
+					"Failure scanning maemo rootstraps", e1);
+		}
+
+		final boolean rootstrapUsed = rootstrapUsed_;
+		String message;
+		if (rootstrapUsed) {
+			message = "Really delete SDK target ''{0}''?\n\n"
+					+ "This will remove the entry from {1}.\n\n"
+					+ "If existing projects use this target, you will be asked to select an alternate target.";
+		} else {
+			message = "Really delete SDK target ''{0}''?\n\n"
+					+ "This will remove the entry from {1} and delete the rootstrap.\n\n"
+					+ "If existing projects use this target, you will be asked to select an alternate target.";
+		}
+		String title = MessageFormat.format("Delete target from {0}?",
+				selectedTarget.getSDK().getDisplayName());
+
+		MessageDialog dialog = new MessageDialog(shell, title, null,
+				MessageFormat.format(message, selectedTarget.getName(),
+						selectedTarget.getSDK().getName()),
+				MessageDialog.WARNING,
+				new String[] { IDialogConstants.YES_LABEL,
+						IDialogConstants.NO_LABEL }, 1) {
+			@Override
+			protected Control createDialogArea(Composite parent) {
+				Composite composite = (Composite) super
+						.createDialogArea(parent);
+				if (rootstrapUsed) {
+					Label spacer = new Label(composite, SWT.NONE);
+					spacer.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true,
+							false));
+
+					final Button removeRootstrap = new Button(composite,
+							SWT.CHECK);
+					removeRootstrap
+							.setText("Also delete rootstrap (target filesystem)");
+					removeRootstrap.setLayoutData(new GridData(SWT.FILL,
+							SWT.TOP, true, false));
+					removeRootstrap
+							.addSelectionListener(new SelectionAdapter() {
+								@Override
+								public void widgetSelected(SelectionEvent e) {
+									deleteRootstrap[0] = removeRootstrap
+											.getSelection();
+								}
+							});
+				}
+				return composite;
+			}
+		};
+
+		if (dialog.open() == 0) {
+			return removeTarget(shell, selectedTarget, deleteRootstrap[0]);
+		} else {
+			return Policy.getCancelStatus(Activator.getDefault());
+		}
+	}
+
+	protected ESboxTargetRemover createTargetRemover(Shell shell,
+			ISDKTarget target, boolean deleteRootstrap) {
+		return new ESboxTargetRemover(shell, target, deleteRootstrap) {
+
+			protected void doRemoveTarget(IProgressMonitor monitor,
+					IScratchboxSDK sdk) {
+				try {
+					((IScratchbox2SDK) sdk).removeRootstrap(
+							sdkTarget.getName(), true, new SubProgressMonitor(
+									monitor, 1));
+				} catch (ESboxException e) {
+					// don't worry -- it may be a bogus target or one without a
+					// rootstrap
+					Activator.getErrorLogger().logError(
+							"Problem removing rootstrap", e);
+				}
+			};
+		};
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/preferences/Scratchbox2PreferencesPage.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/preferences/Scratchbox2PreferencesPage.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/preferences/Scratchbox2PreferencesPage.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.ui.preferences;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.maemo.esbox.maemosdk.sb2.core.SB2PreferenceConstants;
+
+/**
+ * General preference page for scratchbox 2
+ * 
+ * @author eswartz
+ */
+public class Scratchbox2PreferencesPage extends FieldEditorPreferencePage
+		implements IWorkbenchPreferencePage {
+
+	/**
+	 * Field for build mapping mode
+	 */
+	private StringFieldEditor feSbox2BuildMappingMode = null;
+	/**
+	 * Field for install mapping mode
+	 */
+	private StringFieldEditor feSbox2InstallMappingMode = null;
+
+	/**
+	 * Field for log level
+	 */
+	private RadioGroupFieldEditor feSbox2LogLevel = null;
+
+	private StringFieldEditor feSbox2CommandLine;
+
+	/**
+	 * The constructor
+	 */
+	public Scratchbox2PreferencesPage() {
+		super(GRID);
+		setPreferenceStore(SB2PreferenceConstants.getPreferenceStore());
+		setDescription("Options configuring scratchbox 2");
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors
+	 * ()
+	 */
+	public void createFieldEditors() {
+
+		feSbox2BuildMappingMode = new StringFieldEditor(
+				SB2PreferenceConstants.SB2_MAPPING_MODE.toString(),
+				"Build mapping mode:", getFieldEditorParent());
+
+		feSbox2InstallMappingMode = new StringFieldEditor(
+				SB2PreferenceConstants.SB2_INSTALL_MAPPING_MODE.toString(),
+				"Install mapping mode:", getFieldEditorParent());
+
+		feSbox2LogLevel = new RadioGroupFieldEditor(
+				SB2PreferenceConstants.SB2_LOG_LEVEL.toString(),
+				"Logging level:", 1, new String[][] { { "none", "" }, //$NON-NLS-1$
+						{ "error", "error" }, //$NON-NLS-1$
+						{ "warning", "warning" }, //$NON-NLS-1$
+						{ "notice", "notice" }, //$NON-NLS-1$
+						{ "info", "info" }, //$NON-NLS-1$
+						{ "debug", "debug" }, //$NON-NLS-1$
+						{ "noise", "noise" }, //$NON-NLS-1$
+				}, getFieldEditorParent());
+
+		feSbox2CommandLine = new StringFieldEditor(
+				SB2PreferenceConstants.SB2_EXEC_COMMAND.toString(),
+				"Command template:", getFieldEditorParent());
+
+		// make this string manageable
+		GC gc = new GC(getFieldEditorParent().getShell());
+		GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+		gridData.widthHint = gc.getAdvanceWidth('m') * 32;
+		gc.dispose();
+		feSbox2CommandLine.getTextControl(getFieldEditorParent())
+				.setLayoutData(gridData);
+
+		addField(feSbox2BuildMappingMode);
+		addField(feSbox2InstallMappingMode);
+		addField(feSbox2LogLevel);
+		addField(feSbox2CommandLine);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	public void init(IWorkbench workbench) {
+		// Nothing to do
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/MaemoRootstrapContentLabelProvider.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation.
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.ui.wizard;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK;
+
+/**
+ * This class provides installable rootstraps, descriptions, etc. from the
+ * result of 'maemo-rootstrap'.
+ * 
+ * @author eswartz
+ * 
+ */
+public class MaemoRootstrapContentLabelProvider extends LabelProvider implements
+		ITreeContentProvider, ITableLabelProvider, IColorProvider,
+		IFontProvider {
+	static final int COLUMN_NAME = 0;
+	static final int COLUMN_ARCHITECTURE = 1;
+	static final int COLUMN_DESCRIPTION = 2;
+
+	public static Object NO_ROOTSTRAP = new Object();
+	public static Object LOADING_LABEL = new Object();
+
+	private boolean rootstrapsFetched;
+	// either MaemoRootstrap or NO_ROOTSTRAP
+	private List<Object> rootstraps;
+	private Thread rootstrapThread;
+	private final IScratchbox2SDK sdk;
+
+	public MaemoRootstrapContentLabelProvider(IScratchbox2SDK sdk) {
+		this.sdk = sdk;
+	}
+
+	public Object[] getElements(Object inputElement) {
+		if (!rootstrapsFetched) {
+			rootstraps = new ArrayList<Object>();
+			rootstraps.add(NO_ROOTSTRAP);
+			rootstraps.add(LOADING_LABEL);
+
+			if (rootstrapThread == null) {
+				rootstrapThread = new Thread(new Runnable() {
+
+					public void run() {
+						try {
+							List<MaemoRootstrap> realRootstraps = sdk
+									.getAvailableMaemoRootstraps(sdk
+											.getMachine());
+							synchronized (rootstraps) {
+								rootstraps.remove(1);
+								rootstraps.addAll(realRootstraps);
+							}
+						} catch (final ESboxException e) {
+							Display.getDefault().syncExec(new Runnable() {
+
+								public void run() {
+									MessageDialog.openError(null,
+											"Rootstrap lookup failed",
+											"Error fetching rootstraps: check proxy settings?\n\n"
+													+ e.getMessage());
+								}
+
+							});
+						}
+						rootstrapsFetched = true;
+						rootstrapThread = null;
+						Display.getDefault().asyncExec(new Runnable() {
+
+							public void run() {
+								fireLabelProviderChanged(new LabelProviderChangedEvent(
+										MaemoRootstrapContentLabelProvider.this));
+							}
+
+						});
+					}
+
+				});
+				rootstrapThread.start();
+			}
+		}
+		synchronized (rootstraps) {
+			return rootstraps.toArray();
+		}
+	}
+
+	public Object[] getChildren(Object parentElement) {
+		return new Object[0];
+	}
+
+	public Object getParent(Object element) {
+		return null;
+	}
+
+	public boolean hasChildren(Object element) {
+		return false;
+	}
+
+	public void dispose() {
+
+	}
+
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		viewer.refresh();
+	}
+
+	public Image getColumnImage(Object element, int columnIndex) {
+		return null;
+	}
+
+	public String getColumnText(Object element, int columnIndex) {
+		switch (columnIndex) {
+		case COLUMN_NAME:
+			if (element == NO_ROOTSTRAP) {
+				return "Custom target";
+			} else if (element == LOADING_LABEL) {
+				return "Loading...";
+			} else {
+				return ((MaemoRootstrap) element).getName();
+			}
+
+		case COLUMN_ARCHITECTURE:
+			if (element == NO_ROOTSTRAP || element == LOADING_LABEL) {
+				return null;
+			}
+			return ((MaemoRootstrap) element).getArchitecture();
+
+		case COLUMN_DESCRIPTION:
+			if (element == NO_ROOTSTRAP) {
+				return "User-defined name and compiler, manually installed rootstrap";
+			} else if (element == LOADING_LABEL) {
+				return null;
+			} else {
+				return ((MaemoRootstrap) element).getDescription();
+			}
+		}
+		return null;
+	}
+
+	public Color getBackground(Object element) {
+		return null;
+	}
+
+	public Color getForeground(Object element) {
+		if (element == LOADING_LABEL)
+			return Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+		else
+			return null;
+	}
+
+	public Font getFont(Object element) {
+		if (element == LOADING_LABEL)
+			return JFaceResources.getFontRegistry().getItalic(
+					JFaceResources.DIALOG_FONT);
+		else
+			return null;
+	}
+
+}

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/NewScratchbox2TargetWizard.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/NewScratchbox2TargetWizard.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/NewScratchbox2TargetWizard.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,409 @@
+/*******************************************************************************
+ * Copyright (c) 2007-2008 INdT, (c) 2008 Nokia Corporation
+ * 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:
+ *    Raul Herbster (UFCG) - initial API and implementation
+ *    Carolina Nogueira de Souza (UFCG) - initial API and implementation
+ *    Ed Swartz (Nokia)
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+package org.maemo.esbox.maemosdk.sb2.ui.wizard;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.MessageFormat;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.maemo.esbox.core.ESboxException;
+import org.maemo.esbox.core.ErrorLogger;
+import org.maemo.esbox.core.sdk.ISDKTarget;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.core.scratchbox.ScratchboxException;
+import org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK;
+import org.maemo.esbox.maemosdk.sb2.internal.Activator;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardCPUMethod;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardCompilerPage;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardNamePage;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.TargetWizardPageFactory;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.sbrsh.SbrshConfigurationNFSServer;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.sbrsh.SbrshConfigurationTargetDevice;
+
+/**
+ * The target wizard provides a easy way to create a target for Scratchbox. As
+ * Scratchbox target configuration, the user can configure your target.
+ * 
+ */
+public class NewScratchbox2TargetWizard extends Wizard implements INewWizard {
+
+	protected WizardPage targetNamePage;
+	protected WizardPage compilerNamePage;
+	protected WizardPage cpuMethodName;
+	protected WizardPage sbrshConfigTargetDevice;
+	protected WizardPage sbrshConfigNFSServer;
+	protected IProject generatedProject;
+
+	private IScratchbox2SDK sdk;
+
+	private WizardPage maemoRootstrapPage;
+
+	protected ISDKTarget createdTarget;
+
+	private void initialize() {
+		setNeedsProgressMonitor(true);
+		setWindowTitle("New Scratchbox 2 Target");
+		ImageDescriptor image = Activator
+				.getImageDescriptor("./icons/full/wizban/newtarget_wiz.gif");
+		setDefaultPageImageDescriptor(image);
+		initPages();
+	}
+
+	/**
+	 * Constructs a new target wizard for the given SDK (from the target
+	 * configuration page)
+	 * 
+	 * @param sdk
+	 */
+	public NewScratchbox2TargetWizard(IScratchbox2SDK sdk) {
+		super();
+		this.sdk = sdk;
+		initialize();
+	}
+
+	/**
+	 * Inicializes the content of the pages.
+	 */
+	private void initPages() {
+		if (sdk != null) {
+			maemoRootstrapPage = new TargetWizardRootstrapSb2Page(sdk);
+			addPage(maemoRootstrapPage);
+			targetNamePage = TargetWizardPageFactory.getInstance()
+					.createNamePage(sdk);
+			addPage(targetNamePage);
+			compilerNamePage = TargetWizardPageFactory.getInstance()
+					.createCompilerPage(sdk);
+			addPage(compilerNamePage);
+			cpuMethodName = TargetWizardPageFactory.getInstance()
+					.createCPUMethod(sdk);
+			addPage(cpuMethodName);
+			sbrshConfigTargetDevice = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigDeviceTargetPage();
+			addPage(sbrshConfigTargetDevice);
+			sbrshConfigNFSServer = TargetWizardPageFactory.getInstance()
+					.createSbrshConfigNFSSServer();
+			addPage(sbrshConfigNFSServer);
+		} else {
+			addPage(TargetWizardPageFactory.getInstance()
+					.createBadInstallationPage());
+		}
+	}
+
+	public boolean canFinish() {
+		if (sdk == null)
+			return false;
+
+		boolean nonCustomRootstrap = true;
+		if (maemoRootstrapPage != null)
+			nonCustomRootstrap = ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+					.canFinish();
+		boolean cpuPage = ((TargetWizardCPUMethod) cpuMethodName).canFinish();
+		boolean configDevice = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.canFinish();
+		boolean NFSServer = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.canFinish();
+		boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+
+		if (!sbrshConfigAccepted && (nonCustomRootstrap || cpuPage))
+			return true;
+		if (sbrshConfigAccepted && NFSServer && configDevice)
+			return true;
+
+		return false;
+	}
+
+	@Override
+	public IWizardPage getNextPage(IWizardPage page) {
+		if (page == maemoRootstrapPage) {
+			boolean nonCustomRootstrap = ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+					.canFinish();
+			if (nonCustomRootstrap)
+				return null;
+			else
+				return super.getNextPage(page);
+		}
+		if (page == cpuMethodName) {
+			boolean sbrshConfigAccepted = ((TargetWizardCPUMethod) cpuMethodName)
+					.getSbrshConfigure();
+			if (!sbrshConfigAccepted) // user does not want to configure sbrsh
+				return null;
+			else
+				// user wants to configure sbrsh
+				return super.getNextPage(page);
+		}
+		return super.getNextPage(page);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
+	 */
+	public boolean performFinish() {
+		if (getRootstrap() != null) {
+			if (!setupTargetFromRootstrap())
+				return false;
+		} else {
+			if (!setupTargetFromScratch())
+				return false;
+		}
+
+		boolean sbrshConfigSelected = ((TargetWizardCPUMethod) cpuMethodName)
+				.getSbrshConfigure();
+		if (sbrshConfigSelected) {
+			configureSbrshService();
+			showsDialog();
+		}
+
+		return true;
+	}
+
+	private boolean setupTargetFromScratch() {
+		String targetName;
+		// in this mode, construct a target from the user's settings
+		targetName = getTargetNameSelected();
+		String compilerName = getCompilerNameSelected();
+		String cpuMethod = getCputranspSelected();
+		try {
+			sdk.createTarget(targetName, compilerName, null, cpuMethod);
+			createdTarget = sdk.findSDKTarget(targetName);
+			return true;
+		} catch (ESboxException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot get create target "
+					+ targetName, e);
+			return false;
+		}
+	}
+
+	private boolean setupTargetFromRootstrap() {
+		String targetName;
+		// in this mode, make a predefined target from a maemo rootstrap
+		targetName = getRootstrap().getName();
+		boolean create = true;
+
+		if (true) {
+			// see if the rootstrap (not necessarily the target) already exists,
+			// and ask user, in case this will overwrite their customizations
+			try {
+				List<String> installedRootstraps = sdk
+						.getInstalledMaemoRootstraps();
+				if (installedRootstraps.contains(targetName)) {
+					create = MessageDialog
+							.openConfirm(
+									getShell(),
+									"Reinstall rootstrap?",
+									MessageFormat
+											.format(
+													"The rootstrap ''{0}'' appears to be already installed, though it may be disconnected from scratchbox.\n\n"
+															+ "At this time, we can't recreate a target for this rootstrap, but "
+															+ "you could do it manually with 'sb2-init'.\n\n"
+															+ "Do you want to overwrite the rootstrap?",
+													targetName));
+				}
+			} catch (ESboxException e) {
+				ErrorLogger errorLogger = Activator.getErrorLogger();
+				errorLogger.logError("Cannot detect installed rootstraps", e);
+			}
+		}
+
+		if (create) {
+			try {
+				createRootstrap(targetName, useHostTools());
+			} catch (ESboxException e) {
+				ErrorLogger errorLogger = Activator.getErrorLogger();
+				errorLogger.logAndShowError(
+						"Cannot get create rootstrap target " + targetName, e);
+				return false;
+			}
+		}
+		return true;
+	}
+
+	private void createRootstrap(final String targetName,
+			final boolean useHostTools) throws ScratchboxException {
+		try {
+			getContainer().run(true, true, new IRunnableWithProgress() {
+
+				public void run(IProgressMonitor monitor)
+						throws InvocationTargetException, InterruptedException {
+					monitor.beginTask("Creating rootstrap",
+							IProgressMonitor.UNKNOWN);
+					try {
+						sdk.createRootstrapTarget(targetName, useHostTools,
+								true, new SubProgressMonitor(monitor, 1));
+						createdTarget = sdk.findSDKTarget(targetName);
+					} catch (ESboxException e) {
+						throw new InvocationTargetException(e);
+					}
+					monitor.done();
+				}
+
+			});
+		} catch (InvocationTargetException e) {
+			if (e.getCause() instanceof ScratchboxException)
+				throw (ScratchboxException) e.getCause();
+			else
+				throw new ScratchboxException(e);
+		} catch (InterruptedException e) {
+			throw new ScratchboxException(e);
+		}
+	}
+
+	private MaemoRootstrap getRootstrap() {
+		return ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+				.getRootstrap();
+	}
+
+	private boolean useHostTools() {
+		return ((TargetWizardRootstrapSb2Page) maemoRootstrapPage)
+				.useHostTools();
+	}
+
+	/**
+	 * Return the name of the target to be created.
+	 * 
+	 * @return the name of the target to be created.
+	 */
+	private String getTargetNameSelected() {
+		return ((TargetWizardNamePage) targetNamePage).getTextControl()
+				.getText();
+	}
+
+	/**
+	 * Return the compiler name of the target to be created.
+	 * 
+	 * @return the compiler name of the target to be created.
+	 */
+	private String getCompilerNameSelected() {
+		TableItem item = ((TargetWizardCompilerPage) compilerNamePage)
+				.getTableControl().getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Return the cputransp name of the target to be created.
+	 * 
+	 * @return the cputransp name of the target to be created.
+	 */
+	private String getCputranspSelected() {
+		TableItem item = ((TargetWizardCPUMethod) cpuMethodName).getTable()
+				.getSelection()[0];
+		return item.getText();
+	}
+
+	/**
+	 * Configure sbrsh service.
+	 */
+	private void configureSbrshService() {
+		String targetName = getTargetNameSelected();
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceAddr();
+		String nfsHostname = ((SbrshConfigurationNFSServer) sbrshConfigNFSServer)
+				.getNFSHostname();
+
+		try {
+			sdk.configureSbrsh(targetName, deviceTargetAddr, nfsHostname);
+		} catch (ESboxException e) {
+			ErrorLogger errorLogger = Activator.getErrorLogger();
+			errorLogger.logAndShowError("Cannot configure sbrsh", e);
+		}
+	}
+
+	/**
+	 * Add user at access list of the sbrshd running at the target device.
+	 */
+	private void addUser() {
+		String deviceTargetIP = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String username = System.getProperty("user.name");
+		ErrorLogger errorLogger = Activator.getErrorLogger();
+
+		try {
+			String localAddr = getLocalIP();
+			sdk.addSbrshAccessList(deviceTargetIP, username, localAddr);
+		} catch (ESboxException e) {
+			errorLogger
+					.logAndShowError(
+							"Cannot add user to the access list of sbrshd at the target device",
+							e);
+		} catch (UnknownHostException e) {
+			errorLogger.logAndShowError("Cannot get local IP address", e);
+		}
+	}
+
+	/**
+	 * Shows the dialog to ask the user if s/he wants to add his/herself to the
+	 * acess list of the sbrshd.
+	 */
+	private void showsDialog() {
+		String deviceTargetAddr = ((SbrshConfigurationTargetDevice) sbrshConfigTargetDevice)
+				.getTargetDeviceIP();
+		String text = "Do you want to add yourself to the access list of the sbrshd running on target device? \n";
+		text += "(This requires that "
+				+ deviceTargetAddr
+				+ " has ssh daemon running and sbrshd already installed, and that you have root access).";
+		boolean userAddedAtAccessList = MessageDialog.openQuestion(getShell(),
+				"Scratchbox Configuration", text);
+		if (userAddedAtAccessList) {
+			addUser();
+		}
+	}
+
+	/**
+	 * Get the local IP address.
+	 * 
+	 * @return the local IP address.
+	 * @throws UnknownHostException
+	 */
+	private String getLocalIP() throws UnknownHostException {
+		return InetAddress.getLocalHost().getHostAddress();
+	}
+
+	/**
+	 * We will accept the selection in the workbench to see if we can initialize
+	 * from it.
+	 * 
+	 * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
+	 */
+	public void init(IWorkbench workbench, IStructuredSelection selection) {
+	}
+
+	/**
+	 * Get the target created. Only valid after wizard dialog completes.
+	 * 
+	 * @return newly created ISDKTarget or <code>null</code>
+	 */
+	public ISDKTarget getCreatedTarget() {
+		return createdTarget;
+	}
+
+}
\ No newline at end of file

Added: branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java
===================================================================
--- branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java	                        (rev 0)
+++ branches/sdkPlugins/maemosdk/org.maemo.esbox.maemosdk.sdk2/src/org/maemo/esbox/maemosdk/sb2/ui/wizard/TargetWizardRootstrapSb2Page.java	2008-10-14 07:11:52 UTC (rev 868)
@@ -0,0 +1,222 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Nokia Corporation
+ * 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:
+ *    Ed Swartz (Nokia) - initial API and implementation
+ *    Petr Baranov (Nokia)
+ *******************************************************************************/
+
+package org.maemo.esbox.maemosdk.sb2.ui.wizard;
+
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardPage;
+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.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.maemo.esbox.maemosdk.core.scratchbox.MaemoRootstrap;
+import org.maemo.esbox.maemosdk.sb2.core.IScratchbox2SDK;
+import org.maemo.esbox.maemosdk.sb2.core.Scratchbox2SDK;
+import org.maemo.esbox.maemosdk.ui.targets.wizards.IValidatePage;
+
+/**
+ * This page allows the user to select a rootstrap (which defines the target
+ * name, compiler, devkits, and cpu method all at once) for use with sb2, or to
+ * explicitly select to configure all the aspects himself.
+ * 
+ * @author eswartz
+ * 
+ */
+public class TargetWizardRootstrapSb2Page extends WizardPage implements
+		IValidatePage {
+
+	protected TreeViewer rootstrapTargetViewer;
+	protected Text text;
+	/* private */IScratchbox2SDK sdk; // in case we use it later
+	protected Object selection;
+	private MaemoRootstrapContentLabelProvider provider;
+	private Button showExistingTargets;
+	private Button useHostTools;
+
+	/**
+	 * Constructs a NewTargetWizardNamePage.
+	 */
+	protected TargetWizardRootstrapSb2Page(IScratchbox2SDK sdk) {
+		super("Target Name");
+		this.sdk = sdk;
+		if (!(sdk instanceof Scratchbox2SDK)) {
+			throw new IllegalArgumentException(
+					"This page only expects a scratchbox 2 SDK");
+		}
+		setTitle("Select maemo SDK+ Rootstrap");
+		setDescription("Select the maemo rootstrap to install, or manually configure a target.");
+		setPageComplete(false);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+	 * .Composite)
+	 */
+	public void createControl(Composite parent) {
+		Composite composite = new Composite(parent, SWT.NONE);
+		composite.setLayout(new GridLayout(1, false));
+
+		Label label = new Label(composite, SWT.LEFT);
+		label.setText("Select a rootstrap:");
+
+		rootstrapTargetViewer = new TreeViewer(composite, SWT.SINGLE
+				| SWT.BORDER);
+		rootstrapTargetViewer.getTree().setLayoutData(
+				new GridData(SWT.FILL, SWT.FILL, true, true));
+
+		showExistingTargets = new Button(composite, SWT.CHECK);
+		showExistingTargets.setText("Show existing targets");
+		showExistingTargets.setSelection(false);
+		showExistingTargets
+				.setToolTipText("If checked, rootstraps with names matching existing targets will be shown.  This is the only way to reinstall a target.");
+
+		useHostTools = new Button(composite, SWT.CHECK);
+		useHostTools.setText("Use host's build tools");
+		useHostTools.setSelection(false);
+		useHostTools
+				.setToolTipText("If checked, configure the rootstrap to use the host versions of autotools, bison, flex, docbook, etc. instead of standard versions (c.f. devkits in scratchbox 1).  We recommend leaving this unchecked and invoking maemo-tools to install official build tools.");
+
+		// / setup rootstrap target tree
+
+		provider = new MaemoRootstrapContentLabelProvider(sdk);
+		rootstrapTargetViewer.setContentProvider(provider);
+		rootstrapTargetViewer.setLabelProvider(provider);
+
+		rootstrapTargetViewer
+				.addSelectionChangedListener(new ISelectionChangedListener() {
+
+					public void selectionChanged(SelectionChangedEvent event) {
+						selection = ((IStructuredSelection) event
+								.getSelection()).getFirstElement();
+						validatePage();
+					}
+
+				});
+
+		provider.addListener(new ILabelProviderListener() {
+
+			public void labelProviderChanged(LabelProviderChangedEvent event) {
+				rootstrapTargetViewer.refresh();
+			}
+
+		});
+
+		rootstrapTargetViewer.getTree().setLinesVisible(true);
+		rootstrapTargetViewer.getTree().setHeaderVisible(true);
+
+		TreeColumn nameColumn = new TreeColumn(rootstrapTargetViewer.getTree(),
+				SWT.LEFT);
+		nameColumn.setText("Target Name");
+		nameColumn.setWidth(200);
+		nameColumn.setResizable(true);
+
+		TreeColumn archColumn = new TreeColumn(rootstrapTargetViewer.getTree(),
+				SWT.LEFT);
+		archColumn.setText("Architecture");
+		archColumn.setWidth(100);
+		archColumn.setResizable(true);
+
+		TreeColumn descColumn = new TreeColumn(rootstrapTargetViewer.getTree(),
+				SWT.LEFT);
+		descColumn.setText("Description");
+		descColumn.setWidth(200);
+		descColumn.setResizable(true);
+
+		rootstrapTargetViewer.setInput(new Object());
+
+		rootstrapTargetViewer.setSelection(StructuredSelection.EMPTY);
+
+		showExistingTargets.addSelectionListener(new SelectionAdapter() {
+			@Override
+			public void widgetSelected(SelectionEvent e) {
+				updateViewerFilters();
+			}
+		});
+
+		updateViewerFilters();
+		setControl(composite);
+	}
+
+	protected void updateViewerFilters() {
+		if (!showExistingTargets.getSelection()) {
+			rootstrapTargetViewer
+					.setFilters(new ViewerFilter[] { new ViewerFilter() {
+
+						@Override
+						public boolean select(Viewer viewer,
+								Object parentElement, Object element) {
+							if (element instanceof MaemoRootstrap) {
+								MaemoRootstrap rootstrap = (MaemoRootstrap) element;
+								if (sdk.findSDKTarget(rootstrap.getName()) != null)
+									return false;
+							}
+							return true;
+						}
+
+					} });
+		} else {
+			rootstrapTargetViewer.setFilters(new ViewerFilter[0]);
+		}
+
+		rootstrapTargetViewer.refresh();
+
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * br.edu.ufcg.dee.omapsdk.properties.target.wizard.pages.ValidateWizardPage
+	 * #perfomeAction()
+	 */
+	public boolean validatePage() {
+		setPageComplete(selection instanceof MaemoRootstrap
+				|| selection == MaemoRootstrapContentLabelProvider.NO_ROOTSTRAP);
+		return true;
+	}
+
+	public boolean canFinish() {
+		return selection instanceof MaemoRootstrap;
+	}
+
+	public MaemoRootstrap getRootstrap() {
+		if (!(selection instanceof MaemoRootstrap))
+			return null;
+		return (MaemoRootstrap) selection;
+	}
+
+	public boolean isShowingExisting() {
+		return showExistingTargets.getSelection();
+	}
+
+	public boolean useHostTools() {
+		return useHostTools.getSelection();
+	}
+
+}
\ No newline at end of file



More information about the Esbox-commits mailing list