[Esbox-commits] r2043 - in branches/work_Fabricio: org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests org.maemo.esbox.tests/src/org/maemo/esbox/internal/tests org.maemo.esbox.tests/src/org/maemo/esbox/tests org.maemo.esbox.tests/src/org/maemo/esbox/tests/protocol org.maemo.esbox.vm/src/org/maemo/esbox/vm/ui org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards
fabricioepa at garage.maemo.org
fabricioepa at garage.maemo.org
Fri Aug 28 18:16:07 EEST 2009
Author: fabricioepa
Date: 2009-08-28 18:16:06 +0300 (Fri, 28 Aug 2009)
New Revision: 2043
Modified:
branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java
branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java
branches/work_Fabricio/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/MaemoSDKPreferenceIds.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerEngine.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerSelectionWizardPage.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java
branches/work_Fabricio/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/ESboxScratchboxTestSuite.java
branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/internal/tests/ESboxMicaTestSuite.java
branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/ESboxProductTestSuite.java
branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/protocol/ManualTestSBRSHMachine.java
branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadExecution.java
branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
branches/work_Fabricio/org.maemo.esbox.vm/src/org/maemo/esbox/vm/ui/SelectVirtualMachineDialog.java
Log:
Merging with /trunk 2040
Modified: branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/AfSbInitMaemoLauncherAdapter.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -25,13 +25,17 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.MessageDialogWithToggle;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.console.MessageConsole;
import org.maemo.esbox.internal.maemosdk.core.Activator;
import org.maemo.esbox.maemosdk.core.MaemoEnvironmentUtils;
import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.HostUtils;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.console.ConsoleStreamMonitor;
import org.maemo.mica.common.core.console.CoreConsoleManager;
@@ -39,6 +43,8 @@
import org.maemo.mica.common.core.machine.IMachine;
import org.maemo.mica.common.core.machine.IProcess;
import org.maemo.mica.common.core.machine.ProcessFilterCmdLineRegexp;
+import org.maemo.mica.common.core.preferences.CorePreferenceConstants;
+import org.maemo.mica.common.core.preferences.CorePreferenceManager;
import org.maemo.mica.common.core.process.CommandLineArguments;
import org.maemo.mica.common.core.process.IProcessLauncher;
import org.maemo.mica.common.core.process.IProcessLauncherFactory;
@@ -47,29 +53,35 @@
import org.maemo.mica.common.core.process.ProcessLauncherUtils;
import org.maemo.mica.common.core.process.StreamLineMonitorAdapter;
import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.maemosdk.core.IMaemoSDKPlatform;
import org.maemo.mica.maemosdk.core.IMaemoSDKTarget;
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
/**
* Launch the Maemo AF using the "af-sb-init.sh" script.
+ *
* @author baranov
- *
+ *
*/
-public class AfSbInitMaemoLauncherAdapter implements IMaemoLauncherAdapter{
+public class AfSbInitMaemoLauncherAdapter implements IMaemoLauncherAdapter {
+ private static final String ADD_EXTENSION_MIT_SHM = " -extension MIT-SHM";
+ private static final String ADD_LESSPOINTER_OPTION = "-lesspointer";
+ private static final String ADD_SWCURSOR_OPTION = "-swcursor";
+
private static final QualifiedName WARN_ARMEL_TARGET_EXECUTION = new QualifiedName(
Activator.PLUGIN_ID, "WARN_ARMEL_TARGET_EXECUTION");
private static final String MAEMO_LAUNCHER_APP = "maemo-launcher";
private static final String HILDON_DESKTOP_APP = "hildon-desktop";
-
+ private static final int DEFAULT_COLOR_DEPTH = 16;
private final ISDKTarget target;
private final MaemoCommand command;
-
+
/**
* @param target
*/
- public AfSbInitMaemoLauncherAdapter(ISDKTarget target){
+ public AfSbInitMaemoLauncherAdapter(ISDKTarget target) {
this.target = target;
this.command = new MaemoCommand(target);
}
@@ -81,8 +93,7 @@
+ "which may trigger unexpected bugs in otherwise correct programs.\n\n"
+ "We recommend using an X86 target for normal development activities.";
- if (target.getArchitecture().equals(
- IMaemoSDKTarget.ARCHITECTURE_ARMEL)) {
+ if (target.getArchitecture().equals(IMaemoSDKTarget.ARCHITECTURE_ARMEL)) {
Boolean oneTimeWarn = null;
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
@@ -92,8 +103,8 @@
} catch (CoreException e1) {
Activator.getErrorLogger().logError(null, e1);
}
-
- if(oneTimeWarn != null && !oneTimeWarn.booleanValue())
+
+ if (oneTimeWarn != null && !oneTimeWarn.booleanValue())
return;
try {
@@ -101,7 +112,7 @@
} catch (CoreException e1) {
Activator.getErrorLogger().logError(null, e1);
}
-
+
Display.getDefault().asyncExec(new Runnable() {
public void run() {
MessageDialog.openWarning(shell, "Warning", msg);
@@ -140,7 +151,7 @@
} catch (IOException e) {
throw new MicaException("Could not kill " + MAEMO_LAUNCHER_APP, e);
}
-
+
}
/* (non-Javadoc)
@@ -150,11 +161,11 @@
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask("", 10);
-
+
ensureCorrectXRunning(new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled())
return;
- command.performCommand(MaemoPreferenceConstants.MAEMO_RESTART_ACTION,
+ command.performCommand(MaemoPreferenceConstants.MAEMO_RESTART_ACTION,
new SubProgressMonitor(monitor, 9));
monitor.done();
}
@@ -166,32 +177,204 @@
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask("", 10);
-
+
ensureCorrectXRunning(new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled())
return;
-
+
Shell shell = WorkbenchUtils.getSafeShell();
warnIfArmelTarget(shell);
-
- command.performCommand(MaemoPreferenceConstants.MAEMO_START_ACTION,
+
+ command.performCommand(MaemoPreferenceConstants.MAEMO_START_ACTION,
new SubProgressMonitor(monitor, 9));
monitor.done();
}
/**
- * @param subProgressMonitor
- * @throws MicaException
+ * Ensure that correct X is running and restart if required.
+ *
+ * @param monitor the progress monitor
+ * @throws MicaException
*/
- private void ensureCorrectXRunning(IProgressMonitor monitor) throws MicaException {
+ private void ensureCorrectXRunning(IProgressMonitor monitor)
+ throws MicaException {
+ final boolean[] restart = { false };
+
+ if (HostUtils.isOSX()
+ && target.getPlatform().getVersion().compareTo(
+ IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0
+ && !XLauncher.getInstance().hasDisabledExtension(target,
+ "MIT-SHM")) {
+ final String warningKey = CorePreferenceConstants.SUPPRESS_MIT_SHM_WARNING;
+ final IPreferenceStore store = CorePreferenceManager.getInstance()
+ .getPreferenceStore(warningKey);
+
+ String value = store.getString(warningKey);
+
+ if (value == null || value.equals("")
+ || value.equals(MessageDialogWithToggle.PROMPT)) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ final String message =
+ "Due to some design limitations, Fremantle applications will not render " +
+ "correctly when X is running with the MIT-SHM extension enabled. " +
+ "Do you want to disable the extension and restart X?";
+ MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
+ null, "Warning", message,
+ "Do not show this warning in the future",
+ false, store, warningKey);
+ restart[0] = dialog.getReturnCode() == IDialogConstants.YES_ID;
+ }
+ });
+ } else if (value.equals(MessageDialogWithToggle.ALWAYS)) {
+ restart[0] = true;
+ }
+ }
+
+ if (restart[0]) {
+ IPreferenceStore store = CorePreferenceManager.getInstance()
+ .getPreferenceStore(
+ MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+ String command = store
+ .getString(MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+
+ if (!command.contains(ADD_EXTENSION_MIT_SHM)) {
+ store.setValue(MaemoPreferenceConstants.DISPLAY_X_COMMAND,
+ command + ADD_EXTENSION_MIT_SHM);
+ }
+
+ XLauncher x = XLauncher.getInstance();
+
+ if (x.isXServerStarted(target)) {
+ x.stopX(target, monitor);
+ }
+ x.startX(target, monitor);
+ }
+
if (!XLauncher.getInstance().isCorrectXServerRunning(target)) {
- // usability: if X is not running, be sure any Maemo environment in that
+ // usability: if X is not running, be sure any Maemo environment in
+ // that
// server is also killed, or else if the user tries to restart
// the Maemo AF, it will still appear to be running for a while
// until all the processes die from the X server socket timeout.
killMaemo();
XLauncher.getInstance().startXIfNeeded(target, monitor);
}
+
+ if (HostUtils.isWindows()
+ && target.getPlatform().getVersion().compareTo(
+ IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0) {
+
+ final int depth = XLauncher.getInstance().getDisplayDepth(target);
+ final boolean[] depthSupported = { true };
+ if (depth != -1 && depth != DEFAULT_COLOR_DEPTH) {
+ depthSupported[0] = false;
+ }
+ final boolean[] optionsSupported = { true };
+
+ if (XLauncher.getInstance().hasOption(target,
+ ADD_LESSPOINTER_OPTION)
+ || XLauncher.getInstance().hasOption(target,
+ ADD_SWCURSOR_OPTION)) {
+ optionsSupported[0] = false;
+ }
+ if (!depthSupported[0] || !optionsSupported[0]) {
+
+ if (!depthSupported[0] && optionsSupported[0]) {
+ final String warningKey = CorePreferenceConstants.SUPPRESS_COLOR_DEPTH_WARNING;
+ final IPreferenceStore store = CorePreferenceManager
+ .getInstance().getPreferenceStore(warningKey);
+ String value = store.getString(warningKey);
+ if (value == null || value.equals("")
+ || value.equals(MessageDialogWithToggle.PROMPT)) {
+
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ String messageDepth;
+ if (depth == 24 || depth == 32) {
+ messageDepth = "32/24";
+ } else {
+ messageDepth = Integer.toString(depth);
+ }
+ final String message = MessageFormat
+ .format(
+ "Your display uses {0} bit color depth. Due to some design limitations, "
+ + "Fremantle applications will not render correctly unless the display "
+ + "uses {1} bit color depth.",
+ messageDepth,
+ DEFAULT_COLOR_DEPTH);
+
+ MessageDialogWithToggle.openWarning(
+ null, "Warning", message,
+ "Do not show this warning in the future",
+ false, store, warningKey);
+ }
+ });
+ }
+ } else {
+ final String warningKey = CorePreferenceConstants.SUPPRESS_MOUSE_CURSOR_WARNING;
+ final IPreferenceStore store = CorePreferenceManager
+ .getInstance().getPreferenceStore(warningKey);
+
+ String value = store.getString(warningKey);
+
+ if (value == null || value.equals("")
+ || value.equals(MessageDialogWithToggle.PROMPT)) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ String question = "";
+ if (depthSupported[0]) {
+ question = "Due to some design limitations, Fremantle applications will not "
+ + "show mouse cursor correctly when X is started with the lesspointer "
+ + "or the swcursor options. Do you want to disable the options and "
+ + "restart X?";
+
+ } else if (!depthSupported[0]) {
+ question = "Due to some design limitations, Fremantle applications will not "
+ + "render correctly when X is running in 24/32 bit mode and the mouse "
+ + "cursor will not show correctly when the X is started up with the"
+ + "lesspointer or the swcursor options. Do you want to "
+ + "disable the options and restart X? Note: The display depth needs to be "
+ + "change manually to 16 bit mode from the display options.";
+ }
+ MessageDialogWithToggle dialog = MessageDialogWithToggle
+ .openYesNoQuestion(
+ null,
+ "Warning",
+ question,
+ "Do not show this warning in the future",
+ false, store, warningKey);
+ restart[0] = dialog.getReturnCode() == IDialogConstants.YES_ID;
+ }
+ });
+ } else if (value.equals(MessageDialogWithToggle.ALWAYS)) {
+ restart[0] = true;
+ }
+ if (restart[0]) {
+ IPreferenceStore storeXCommand = CorePreferenceManager
+ .getInstance()
+ .getPreferenceStore(
+ MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+ String command = storeXCommand
+ .getString(MaemoPreferenceConstants.DISPLAY_X_COMMAND);
+ command = command.replace(" " + ADD_LESSPOINTER_OPTION,
+ "");
+ command = command
+ .replace(" " + ADD_SWCURSOR_OPTION, "");
+ storeXCommand.setValue(
+ MaemoPreferenceConstants.DISPLAY_X_COMMAND,
+ command.trim());
+
+ XLauncher x = XLauncher.getInstance();
+
+ if (x.isXServerStarted(target)) {
+ x.stopX(target, monitor);
+ }
+ x.startX(target, monitor);
+ }
+ }
+ }
+ }
}
/* (non-Javadoc)
@@ -201,8 +384,8 @@
if (monitor == null)
monitor = new NullProgressMonitor();
monitor.beginTask("", 10);
-
- command.performCommand(MaemoPreferenceConstants.MAEMO_STOP_ACTION,
+
+ command.performCommand(MaemoPreferenceConstants.MAEMO_STOP_ACTION,
new SubProgressMonitor(monitor, 9));
try {
XLauncher.getInstance().stopX(target, new SubProgressMonitor(monitor, 1));
@@ -234,7 +417,7 @@
"|" + HILDON_DESKTOP_APP + ")\\b"));
return runningProcesses;
}
-
+
static public class MaemoCommand {
private ISDKTarget sdkTarget;
@@ -247,19 +430,19 @@
List<String> params = getParamList(command);
performCommand(params, monitor);
}
-
+
private void performCommand(List<String> params, final IProgressMonitor monitor) throws MicaException {
String maemoCommand = sdkTarget.getPreferenceValue(
MaemoPreferenceConstants.MAEMO_COMMAND);
- maemoCommand = this.replaceActions(maemoCommand,params.get(0));
-
+ maemoCommand = this.replaceActions(maemoCommand, params.get(0));
+
IProcessLauncherFactory processLauncherFactory = sdkTarget
.getProcessLauncherFactory();
IEnvironmentModifierBlock envBlock = processLauncherFactory
.getDefaultEnvironmentModifierBlock();
MaemoEnvironmentUtils.defineEmulatorXDisplayVariable(
- sdkTarget.getMachine(), envBlock);
+ sdkTarget.getMachine(), envBlock);
IProcessLauncher processLauncher = processLauncherFactory.createProcessLauncher(
ProcessLauncherParameters.create(
@@ -286,7 +469,7 @@
});
}
};
-
+
processLauncher.queueStreamMonitor(consoleMonitor);
// And watch for errors and termination
@@ -298,9 +481,9 @@
throws InterruptedException {
// REMOVED: error checking -- there are so many spurious
// errors that it's useless to report them
-
+
if (text.contains("Starting") &&
- (text.contains("Hildon Desktop") || text.contains("hildon-desktop"))) {
+ (text.contains("Hildon Desktop") || text.contains("hildon-desktop"))) {
// we need to stop after this or else the launch
// just hangs forever (waiting for input?)... dunno why.
// This happened at least as far back as 2.0.0M1 but
@@ -316,7 +499,7 @@
procMonitor.terminate();
return Status.OK_STATUS;
}
-
+
};
job.setSystem(true);
job.setUser(false);
Modified: branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.maemosdk.core/src/org/maemo/esbox/internal/api/maemosdk/core/tools/XLauncher.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -12,20 +12,24 @@
package org.maemo.esbox.internal.api.maemosdk.core.tools;
+import java.io.File;
import java.io.IOException;
import java.net.Socket;
import java.text.MessageFormat;
import java.util.List;
+import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.maemo.esbox.internal.maemosdk.core.Activator;
import org.maemo.esbox.maemosdk.core.MaemoPreferenceConstants;
+import org.maemo.mica.common.core.HostUtils;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.Policy;
import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
@@ -40,8 +44,10 @@
import org.maemo.mica.common.core.process.IProcessLauncher;
import org.maemo.mica.common.core.process.IProcessLauncherFactory;
import org.maemo.mica.common.core.process.IProcessMonitor;
+import org.maemo.mica.common.core.process.IStreamMonitor;
import org.maemo.mica.common.core.process.ProcessLauncherParameters;
import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.process.StreamLineMonitorAdapter;
import org.maemo.mica.common.core.sdk.ISDKTarget;
import org.maemo.mica.maemosdk.core.IMaemoSDKPlatform;
@@ -70,6 +76,9 @@
*/
private static final String FREMANTLE_X_SERVER_RESOLUTION = "800x480x16";
+ private static final Pattern DEPTHS_PATTERN = Pattern
+ .compile("^\\s*depths\\s+\\(.*\\):\\s*(\\d+),.*$");
+
/**
* @author eswartz
*
@@ -506,7 +515,12 @@
if (sdkTarget != null
&& sdkTarget.getPlatform().getVersion().compareTo(
IMaemoSDKPlatform.FREMANTLE.getVersion()) >= 0) {
- return FREMANTLE_X_SERVER_PLATFORM_PARAMETERS;
+ if(HostUtils.isWindows()){
+ return "";
+ }else{
+ return FREMANTLE_X_SERVER_PLATFORM_PARAMETERS;
+ }
+
}
return DEFAULT_X_SERVER_PLATFORM_PARAMETERS;
}
@@ -568,4 +582,118 @@
return (IProcess[]) processes.toArray(new IProcess[processes.size()]);
}
+ /**
+ * Check if given extension is disabled at command line.
+ *
+ * @param prefProvider the preference provider
+ * @param extension the extension to check
+ * @return true if extension is disable at command line
+ */
+ public boolean hasDisabledExtension(IPreferenceProvider prefProvider, String extension) {
+ List<String> commandLine = null;
+ if (previousCommandLine == null) {
+ commandLine = getDisplayXServerCommand(prefProvider);
+ } else {
+ commandLine = previousCommandLine;
+ }
+
+ int index = commandLine.indexOf(extension);
+ if (index < 1) {
+ return false;
+ } else {
+ return commandLine.get(index - 1).equals("-extension");
+ }
+ }
+
+ /**
+ * Check if given option exists at command line.
+ *
+ * @param prefProvider the preference provider
+ * @param option the option to check
+ * @return true if option exists at command line
+ */
+ public boolean hasOption(IPreferenceProvider prefProvider, String option) {
+ List<String> commandLine = null;
+ if (previousCommandLine == null) {
+ commandLine = getDisplayXServerCommand(prefProvider);
+ } else {
+ commandLine = previousCommandLine;
+ }
+
+ int index = commandLine.indexOf(option);
+ if (index < 1) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Get System color depth
+ *
+ * @param prefProvider
+ * instance of the IPreferenceProvider
+ * @return System color depth if an error occurred <code>-1</code> is
+ * returned
+ */
+ public int getDisplayDepth(IPreferenceProvider prefProvider) {
+ if (prefProvider == null) {
+ return -1;
+ }
+ IMachine machine = MachineRegistry.getInstance().getLocalMachine();
+ List<String> list = CommandLineArguments
+ .createFromCommandLine(prefProvider
+ .getPreferenceValue(MaemoPreferenceConstants.DISPLAY_X_COMMAND));
+ if (list.size() < 0 || list.get(0) == null) {
+ return -1;
+ }
+ String commandBase = new File(list.get(0)).getParent();
+ if (commandBase == null) {
+ commandBase = "";
+ }else{
+ commandBase += File.separator;
+ commandBase = new Path(commandBase).toString();
+ }
+ String commandSkeleton = commandBase + "xdpyinfo -display ${DISPLAY}";
+
+ String display = prefProvider
+ .getPreferenceValue(MaemoPreferenceConstants.X_DISPLAY);
+
+ // add display variable into commandSkeleton and add path for process
+ // launcher
+ IProcessLauncherFactory factory = machine.getProcessLauncherFactory();
+ IEnvironmentModifierBlock envBlock = factory
+ .getDefaultEnvironmentModifierBlock();
+
+ ProcessLauncherParameters params = ProcessLauncherParameters.create(
+ CommandLineArguments.createFromCommandLine(commandSkeleton
+ .replaceAll("\\$\\{DISPLAY\\}", display)), envBlock);
+ String path = prefProvider
+ .getPreferenceValue(MaemoPreferenceConstants.X_PATH);
+ if (path != null && path.length() > 0) {
+ MachineUtils.adjustLaunchParametersForPath(machine, factory,
+ params, path);
+ }
+
+ final int[] depth = new int[1];
+ depth[0] = -1;
+ try {
+ ProcessLauncherUtils.launchAndMonitorStandardStreams(machine
+ .getProcessLauncherFactory().createProcessLauncher(params),
+ new IStreamMonitor[] { new StreamLineMonitorAdapter() {
+ public void handleLine(String line, boolean errorStream)
+ throws InterruptedException {
+ Matcher matcher = DEPTHS_PATTERN.matcher(line);
+ if (matcher.matches()) {
+ depth[0] = Integer.parseInt(matcher.group(1));
+ }
+ }
+ } }, null);
+ } catch (MicaException e) {
+ Activator.getErrorLogger().logError(e.getMessage(), e);
+ return -1;
+ }
+ return depth[0];
+ }
+
}
\ No newline at end of file
Modified: branches/work_Fabricio/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/MaemoSDKPreferenceIds.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/MaemoSDKPreferenceIds.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/MaemoSDKPreferenceIds.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -20,5 +20,6 @@
public interface MaemoSDKPreferenceIds {
public final String BUILD_MACHINE_PREFS_ID = UIActivator.PLUGIN_ID + ".preferencePage.buildMachines";
+ public static final String ESBOX_PREFERENCE_CATEGORY_ID = "org.maemo.esbox.ui.preferenceCategory.esbox";
}
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -13,8 +13,10 @@
import java.lang.reflect.InvocationTargetException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.GridDataFactory;
@@ -24,6 +26,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.wizard.IWizardContainer;
+import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
@@ -34,8 +37,11 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWizard;
+import org.maemo.esbox.internal.api.scratchbox.ui.wizards.ApplyAutoconfPatchWizard;
import org.maemo.esbox.internal.scratchbox.sb1.Activator;
import org.maemo.esbox.internal.scratchbox.sb1.IHelpID;
+import org.maemo.esbox.scratchbox.sb1.sdk.IScratchbox1SDK;
+import org.maemo.mica.common.core.HostUtils;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.Policy;
import org.maemo.mica.common.core.machine.IBuildMachine;
@@ -45,8 +51,11 @@
import org.maemo.mica.common.core.process.IStreamMonitor;
import org.maemo.mica.common.core.process.ProcessLauncherParameters;
import org.maemo.mica.common.core.process.ProcessLauncherUtils;
+import org.maemo.mica.common.core.sdk.ISDK;
import org.maemo.mica.common.core.sdk.ISDKTarget;
+import org.maemo.mica.common.core.sdk.SDKManager;
import org.maemo.mica.internal.api.common.core.SudoWrappedProcessLauncherFactory;
+import org.maemo.mica.internal.api.common.ui.wizards.WizardWorkProgressPageBase;
import org.maemo.mica.internal.api.maemosdk.ui.wizards.BadInstallationPage;
import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
@@ -132,8 +141,22 @@
}
public boolean canFinish() {
- return canFinish;
+ if (!canFinish)
+ return false;
+
+ // we dynamically add all the pages, so validate them each
+ IWizardPage page = targetPage;
+ while (page != null) {
+ // this one will never be complete until we see it
+ if (page instanceof WizardWorkProgressPageBase)
+ break;
+ if (!page.isPageComplete())
+ return false;
+ page = page.getNextPage();
+ }
+ return true;
}
+
/**
* @param canFinish
* the canFinish to set
@@ -146,10 +169,12 @@
public boolean performFinish() {
final IStatus status = doWork();
- final boolean success = status.isMultiStatus()
+ // if we did a lot of work, we have a multistatus.
+ // otherwise, it's an error or nothing really changed.
+ final boolean installedNew = status.isMultiStatus()
&& (status.isOK() || status.matches(IStatus.INFO));
- String message = status.isMultiStatus() ? success ? "Installation succeeded"
+ String message = status.isMultiStatus() ? installedNew ? "Installation succeeded"
: "Installation encountered some errors"
: null;
@@ -157,13 +182,39 @@
"SDK Installation Results", message, status, true)
&& !status.matches(IStatus.CANCEL);
- // Need to reboot
- if (success)
+ if (installedNew) {
+ patchAutotools();
doReboot();
+ }
return goOn;
}
+ /**
+ * Start wizard to patch autotools, since it will break over Samba
+ */
+ private void patchAutotools() {
+ if (HostUtils.isWindows()) {
+ ApplyAutoconfPatchWizard wizard = new ApplyAutoconfPatchWizard();
+
+ // we should find the wizard here, but don't fail if we don't
+ IScratchbox1SDK theSDK = null;
+ IPath installPath =
+ new Path(targetPage.getSDKInstallerData().getScratchboxLocation());
+ for (ISDK sdk : SDKManager.getInstance().getSDKsOfType(IScratchbox1SDK.class)) {
+ if (((IScratchbox1SDK)sdk).getInstallRoot().equals(installPath)) {
+ theSDK = (IScratchbox1SDK) sdk;
+ }
+ }
+ if (theSDK != null) {
+ wizard.setInitialTargets(new Object[] { theSDK });
+ }
+
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.open();
+ }
+ }
+
private void doReboot() {
MessageDialog rebootDlg= new MessageDialog(
super.getShell(),
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerEngine.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerEngine.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerEngine.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -247,6 +247,7 @@
IAptInstallerWorkList workList = AptInstallerEngine.newWorkList();
+ workList.queueAddRepository(manager, repository);
workList.queueInstallUnknownPackages(manager, installerData.getRequiredPackages());
return workList;
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerSelectionWizardPage.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerSelectionWizardPage.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1SDKInstallerSelectionWizardPage.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -16,9 +16,11 @@
import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.wizard.IWizardPage;
@@ -169,6 +171,19 @@
}
});
+ sdkTable.addOpenListener(new IOpenListener() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IOpenListener#open(org.eclipse.jface.viewers.OpenEvent)
+ */
+ public void open(OpenEvent event) {
+ validatePage();
+ if (isPageComplete()) {
+ getWizard().getContainer().showPage(getNextPage());
+ }
+ }
+
+ });
}
/**
@@ -354,6 +369,8 @@
*/
protected void doChangeSDKChoice(Scratchbox1SDKInstallerData data) {
sdkInstallerData = data;
+ detectionPage = null;
+
if (data != null) {
userList.setText(data.getUserList());
userGroup.setText(data.getUserGroup());
@@ -377,7 +394,9 @@
public IWizardPage getNextPage() {
if (PreviousInstallationDetectionPage.detect(buildMachine,
sdkInstallerData)) {
- detectionPage = new PreviousInstallationDetectionPage(getWizard(), sdkInstallerData);
+ if (detectionPage == null) {
+ detectionPage = new PreviousInstallationDetectionPage(getWizard(), sdkInstallerData);
+ }
return detectionPage;
}
return getWizard().getWorkPage();
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/Scratchbox1TargetInstallerSelectionWizardPage.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -24,10 +24,12 @@
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
+import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
@@ -253,6 +255,19 @@
}
});
+ platformTable.addOpenListener(new IOpenListener() {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IOpenListener#open(org.eclipse.jface.viewers.OpenEvent)
+ */
+ public void open(OpenEvent event) {
+ validatePage();
+ if (isPageComplete()) {
+ getWizard().getContainer().showPage(getNextPage());
+ }
+ }
+
+ });
}
/**
Modified: branches/work_Fabricio/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/ESboxScratchboxTestSuite.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/ESboxScratchboxTestSuite.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/ESboxScratchboxTestSuite.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -40,7 +40,9 @@
}
}
} catch (MicaException e) {
+ return TestSuite.warning("Could not connect to build machine");
}
+
SDKManager.getInstance().waitForRefreshComplete(null);
TestSuite suite = new TestSuite(
Modified: branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/internal/tests/ESboxMicaTestSuite.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/internal/tests/ESboxMicaTestSuite.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/internal/tests/ESboxMicaTestSuite.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -43,6 +43,7 @@
}
}
} catch (MicaException e) {
+ return TestSuite.warning("Could not connect to build machine");
}
suite.addTest(new JUnit4TestAdapter(TestOProfileValgrindSupport.class));
Modified: branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/ESboxProductTestSuite.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/ESboxProductTestSuite.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/ESboxProductTestSuite.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IStatus;
import org.maemo.mica.common.core.ErrorLogger;
import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.TimeoutProgressMonitor;
import org.maemo.mica.common.core.ErrorLogger.Listener;
import org.maemo.mica.common.core.machine.*;
import org.maemo.mica.common.core.tests.TestMachineUtils;
@@ -29,19 +30,18 @@
public class ESboxProductTestSuite {
public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for ESbox Product");
-
try {
IMachine testMachine = TestMachineUtils.getSSHBuildMachine();
if (testMachine != null) {
- MachineUtils.acquireMachine(testMachine);
+ MachineUtils.acquireMachine(testMachine,
+ new TimeoutProgressMonitor(5 * 60 * 1000));
} else {
for (IBuildMachine machine : MachineRegistry.getInstance().getBuildMachines()) {
MachineUtils.acquireMachine(machine);
}
}
} catch (MicaException e) {
+ return TestSuite.warning("Could not connect to build machine");
}
ErrorLogger.Listener listener = new Listener() {
@@ -57,7 +57,10 @@
};
ErrorLogger.addListener(listener);
-
+
+ TestSuite suite = new TestSuite(
+ "Test for ESbox Product");
+
suite.addTest(org.maemo.mica.common.core.tests.MicaCoreTestSuite.suite());
suite.addTest(org.maemo.esbox.internal.tests.ESboxMicaTestSuite.suite());
suite.addTest(org.maemo.esbox.vm.tests.ESboxVMTestSuite.suite());
Modified: branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/protocol/ManualTestSBRSHMachine.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/protocol/ManualTestSBRSHMachine.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.tests/src/org/maemo/esbox/tests/protocol/ManualTestSBRSHMachine.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -18,6 +18,7 @@
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.maemo.esbox.tests.common.SboxTestUtils;
import org.maemo.mica.common.core.HostUtils;
@@ -69,7 +70,7 @@
// new QemuMachine(new StockQemuConfiguration());
else
sbrshHostMachine = MachineRegistry.getInstance().getLocalMachine();
- MachineUtils.acquireMachine(sbrshHostMachine);
+ MachineUtils.acquireMachine(sbrshHostMachine, new NullProgressMonitor());
SboxTestUtils.reset();
theSB1SDKTarget = SboxTestUtils.theSB1SDKTarget;
Modified: branches/work_Fabricio/org.maemo.esbox.vm/src/org/maemo/esbox/vm/ui/SelectVirtualMachineDialog.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.vm/src/org/maemo/esbox/vm/ui/SelectVirtualMachineDialog.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.vm/src/org/maemo/esbox/vm/ui/SelectVirtualMachineDialog.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -19,6 +19,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.maemo.esbox.internal.api.maemosdk.ui.preferences.MaemoSDKPreferenceIds;
import org.maemo.esbox.internal.vm.Activator;
import org.maemo.mica.common.core.ProductUtils;
@@ -29,9 +30,6 @@
*/
public class SelectVirtualMachineDialog extends MessageDialogWithToggle {
- public static final String BUILD_MACHINE_PREFS_ID = "org.maemo.esbox.maemosdk.ui.preferencePage.buildMachines";
- protected static final String ESBOX_PREFERENCE_CATEGORY_ID = "org.maemo.esbox.ui.preferenceCategory.esbox";
-
private static final String BUG_ME_NOT = "SelectBuildMachineDialog.BugMeNot";
/**
@@ -73,10 +71,10 @@
SelectVirtualMachineDialog.this.close();
PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
getShell(),
- BUILD_MACHINE_PREFS_ID,
+ MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
new String[] {
- ESBOX_PREFERENCE_CATEGORY_ID,
- BUILD_MACHINE_PREFS_ID,
+ MaemoSDKPreferenceIds.ESBOX_PREFERENCE_CATEGORY_ID,
+ MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
},
null);
dialog.open();
Modified: branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadExecution.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadExecution.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DownloadExecution.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -92,8 +92,12 @@
}
// If user cancels donwload, it does not tries anymore.
- if (status != null && (status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR)))
- break;
+ if (status != null && (status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR))){
+ if (status.matches(IStatus.CANCEL))
+ throw new MicaException("Maemo SDK virtual image download was cancelled by user.");
+ else
+ break;
+ }
else if ((status != null && status.isOK()))
return;
}
Modified: branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -80,10 +80,14 @@
fileSize = getSizeFor(downloadPage, downloadFile.getDescriptor().getName());
remoteURL = getLinkFor(downloadPage, downloadFile.getDescriptor().getName());
} catch (MalformedURLException e) {
- Activator.getErrorLogger().logAndShowError("Invalid file URL", e);
- return null;
+ throw new MicaException("Invalid file URL on " + MaemoSDKVMInfo.DOWNLOAD_PAGE, e);
}
+ if (remoteURL == null) {
+ throw new MicaException("Cannot locate ''" + downloadFile.getDescriptor().getName()
+ + "'' on " + MaemoSDKVMInfo.DOWNLOAD_PAGE);
+ }
+
return new Tuple(remoteURL, fileSize);
}
@@ -293,7 +297,8 @@
URL remoteURL = (URL) remoteFileInfo.get(0);
// Get link of remote file
- String fileName = getFileName(remoteURL, downloadFile.getLocalURL());
+ String fileName = getFileName(remoteURL, downloadFile.getLocalURL());
+ downloadFile.setLocalURL(new File(fileName).toURL());
downloadFile.setDownloadedSize(getPreviousDownloadSize(fileName));
Integer remoteFileSize = (Integer) remoteFileInfo.get(1);
@@ -335,8 +340,9 @@
downloadFile.setSize(contentLength);
}
- CopyProgressMonitor progressMonitor = new CopyProgressMonitor("Downloading Maemo SDK virtual image",remoteFileSize, monitor);
- progressMonitor.addProgress(downloadFile.getDownloadedSize());
+ CopyProgressMonitor progressMonitor = new CopyProgressMonitor(
+ "Downloading Maemo SDK virtual image", remoteFileSize, monitor);
+ progressMonitor.setExistingSize(downloadFile.getDownloadedSize());
progressMonitor.start();
out = new RandomFileOutputStream(fileName,true);
@@ -347,7 +353,7 @@
monitor.beginTask(remoteURL.getFile(), remoteFileSize != 0 ? remoteFileSize : IProgressMonitor.UNKNOWN);
monitor.worked((int)downloadFile.getDownloadedSize());
- int bufferSize = 64*1054;//64KB
+ int bufferSize = 64*1024;//64KB
DownloadingThread thread = new DownloadingThread(in, out,bufferSize , progressMonitor, monitor);
thread.start();
@@ -360,8 +366,8 @@
if (monitor.isCanceled()) {
thread.stopDownloading();
- downloadFile.cancel();
- throw new MicaException("Maemo SDK virtual image download was cancelled by user.");
+ downloadFile.cancel();
+ return Status.CANCEL_STATUS;
}
if(downloadFile.getStatus() == MaemoSDKVMInfo.Status.PAUSED){
@@ -373,8 +379,7 @@
}
}
- if (thread.isCompleted() &&
- downloadFile.getDownloadedSize() == remoteFileSize.intValue()) {
+ if (thread.isCompleted()) {
downloadFile.complete();
}
Modified: branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -27,8 +27,10 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.window.Window;
+import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.PreferencesUtil;
+import org.maemo.esbox.internal.api.maemosdk.ui.preferences.MaemoSDKPreferenceIds;
import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo.Status;
import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1SDKWizard;
import org.maemo.esbox.internal.scratchbox.sb1.ui.wizard.NewScratchbox1TargetWizard;
@@ -36,7 +38,6 @@
import org.maemo.esbox.internal.vm.vmware.ui.wizards.MaemoSDKVMInstallData;
import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.esbox.vm.ui.SelectVirtualMachineDialog;
import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
import org.maemo.mica.common.core.Policy;
import org.maemo.mica.common.core.machine.IBuildMachine;
@@ -48,8 +49,6 @@
import org.maemo.mica.internal.api.common.core.filesystem.FilesystemUtils;
import org.maemo.mica.internal.api.linux.packages.core.aptinstall.AptInstallerHelper;
-import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
-
/**
* This class wraps the main methods used during installation of Maemo SDK
* virtual image.
@@ -86,25 +85,23 @@
public IStatus installVirtualImage(int timeout, Shell shell, IProgressMonitor monitor) {
IStatus status = Activator.createStatus(IStatus.OK, "Maemo SDK Virtual Image was properly installed.");
- if (!installData.canUsePreviousInstallation()) {
+ if (!installData.canUsePreviousInstallation())
status = this.downloadVM(shell, monitor);
- }
if (canProceed(status))
status = this.uncompressVM(shell, monitor);
- if (canProceed(status) && installData.canInstallSbox()) {
- promptPreferencesDialog(shell);
+ if (canProceed(status))
+ status = promptPreferencesDialog(shell);
+
+ if (canProceed(status) && installData.canInstallSbox())
status = this.installScratchbox(shell,monitor);
- }
- if (canProceed(status) && installData.canInstallTargets()) {
+ if (canProceed(status) && installData.canInstallTargets())
status = this.installScratchboxTargets(shell,monitor);
- }
- if (canProceed(status) && ((installData.canInstallCppEnv() || installData.canInstallPythonEnv()))) {
+ if (canProceed(status) && ((installData.canInstallCppEnv() || installData.canInstallPythonEnv())))
status = this.installPackages(shell, monitor);
- }
return status;
}
@@ -166,7 +163,8 @@
monitor.subTask("Uncompressing image...");
reporter.logInfo("Uncompressing Maemo SDK virtual image...");
- final String fileName = installData.getPathOfExistentVM();
+ final String fileName = installData.getPathOfExistentVM() == null ? installData.getFileToDownload().getLocalURL().getFile() :
+ installData.getPathOfExistentVM();
final String destinationPath = installData.getInstallationPath();
final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "File " + fileName
@@ -227,10 +225,13 @@
if (previousProgressValue < progressValue) {
previousProgressValue = progressValue;
monitor.worked(1);
+ if (monitor.isCanceled())
+ return;
}
monitor.subTask("Uncompressing " + zipEntry
+ "\t\t"
+ String.format(Locale.US, "%.2f", getProgress(lenght,totalRead)) + "%");
+
}
fileOutputStream.close();
zipInputStream.closeEntry();
@@ -323,44 +324,42 @@
* @param shell
* @return
*/
- private IStatus promptPreferencesDialog(final Shell shell) {
- configureInitialVMSettings();
-
+ private IStatus promptPreferencesDialog(final Shell shell) {
final IStatus statuses[] = new IStatus[] {Policy.getCancelStatus(Activator.getDefault())};
- shell.getDisplay().syncExec(new Runnable() {
+ String vmLocation = configureInitialVMSettings();
+
+ if (!vmLocation.trim().equals("")) {
- public void run() {
- SelectVirtualMachineDialog dialog = new SelectVirtualMachineDialog(
- WorkbenchUtils.getActiveShell());
- int result = dialog.open();
- if (result != Window.OK)
- statuses[0] = Activator.createErrorStatus("Virtual image was not properly configured.", null);
- else
- statuses[0] = Activator.createStatus(IStatus.OK, "Virtual image configured.");
- }
-
- });
-
+ shell.getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ null, /* do not tie to a shell to avoid #4438 */
+ MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
+ new String[] {
+ MaemoSDKPreferenceIds.ESBOX_PREFERENCE_CATEGORY_ID,
+ MaemoSDKPreferenceIds.BUILD_MACHINE_PREFS_ID,
+ },
+ null);
+ dialog.open();
+
+ // check for valid build machine
+ if (MachineRegistry.getInstance().getCurrentBuildMachines().length == 0)
+ statuses[0] = Activator.createErrorStatus("Virtual image was not properly configured.", null);
+ else
+ statuses[0] = Activator.createStatus(IStatus.OK, "Virtual image configured.");
+ }
+ });
+ }
return statuses[0];
}
/**
* Configure initial VM settings, such as vmx file path.
*/
- public void configureInitialVMSettings() {
- List<IBuildMachine> availableMachines = new ArrayList<IBuildMachine>(
- Arrays.asList(MachineRegistry.getInstance().getAvailableBuildMachines()));
-
- IBuildMachine vmwareMachine = null;
-
- for (IBuildMachine buildMachine : availableMachines) {
- String machineName = buildMachine.getName();
- if(machineName.contains("VMware")) {
- vmwareMachine = buildMachine;
- break;
- }
- }
+ public String configureInitialVMSettings() {
+ IBuildMachine vmwareMachine = getVMWareMachine();
IVirtualMachineConfiguration machineConfig = ((IVirtualMachine)vmwareMachine).getConfiguration();
@@ -372,12 +371,34 @@
} else {
vmxFileLocation = "";
}
-
((IVMwareConfiguration)machineConfig).setVmxPath(vmxFileLocation);
+
+ return vmxFileLocation;
}
/**
+ * Get current VMWare build machine.
+ * @return VMWare build machine.
+ */
+ private IBuildMachine getVMWareMachine() {
+ List<IBuildMachine> availableMachines = new ArrayList<IBuildMachine>(
+ Arrays.asList(MachineRegistry.getInstance().getAvailableBuildMachines()));
+
+ IBuildMachine vmwareMachine = null;
+
+ for (IBuildMachine buildMachine : availableMachines) {
+ String machineName = buildMachine.getName();
+ if(machineName.contains("VMware")) {
+ vmwareMachine = buildMachine;
+ break;
+ }
+ }
+
+ return vmwareMachine;
+ }
+
+ /**
* Get the location of vmx file.
* @return
*/
Modified: branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -34,6 +34,8 @@
private Button installEverything;
+ private Label mainMessage;
+
// installation details area
private Group installationDetailsGroup;
private Button installScratchbox;
@@ -71,12 +73,11 @@
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
setControl(composite);
- Label message = new Label(composite, SWT.WRAP);
- String imageName = ((NewMaemoSDKVMWizard)getWizard()).getInstallData().getFileToDownload().getDescriptor().getName();
- message.setText("You just selected virtual image ''" + imageName + "'' to be installed on your machine.\n" +
- " Please, select the following options in order to properly configure your Maemo SDK virtual machine");
+ mainMessage = new Label(composite, SWT.WRAP);
+ updateMainMessage();
+
GridDataFactory.swtDefaults().span(1, 1).align(SWT.LEFT, SWT.CENTER)
- .applyTo(message);
+ .applyTo(mainMessage);
Label separator = new Label(composite, SWT.NONE);
GridDataFactory.swtDefaults().span(1, 1).align(SWT.LEFT, SWT.CENTER)
@@ -88,7 +89,6 @@
.applyTo(installEverything);
installEverything
.setToolTipText("If checked, install the complete Maemo SDK programming environment on virtual image");
- installEverything.setSelection(true);
installEverything.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
@@ -106,13 +106,9 @@
createInstallationDetailsArea(composite);
createProgrammingEnvironmentArea(composite);
-
- setInstallationDetailsButtonsSelection(true);
- setInstallationDetailsGroupEnabled(false);
- setProgrammingEnvButtonsSelection(true);
- setProgrammignEnvGroupEnabled(false);
- updateInstallData();
+ setValues();
+
}
/**
@@ -289,5 +285,30 @@
installPythonEnv.getSelection());
installData.setInstallSbox(installScratchbox.getSelection() || installScratchboxTargets.getSelection());
}
+
+ private void updateMainMessage() {
+ String imageName = ((NewMaemoSDKVMWizard)getWizard()).getInstallData().getFileToDownload().getDescriptor().getName();
+ mainMessage.setText("You just selected virtual image ''" + imageName + "'' to be installed on your machine.\n" +
+ " Please, select the following options in order to properly configure your Maemo SDK virtual machine");
+ }
+
+ private void setValues() {
+ boolean isServer = ((NewMaemoSDKVMWizard)getWizard()).getInstallData().getFileToDownload().getDescriptor().isServerImage();
+ installEverything.setSelection(isServer);
+ setInstallationDetailsButtonsSelection(isServer);
+ setInstallationDetailsGroupEnabled(false);
+ setProgrammingEnvButtonsSelection(true);
+ setProgrammignEnvGroupEnabled(false);
+
+ updateInstallData();
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ updateMainMessage();
+ setValues();
+ }
+
}
Modified: branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
===================================================================
--- branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java 2009-08-28 14:46:09 UTC (rev 2042)
+++ branches/work_Fabricio/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java 2009-08-28 15:16:06 UTC (rev 2043)
@@ -247,7 +247,6 @@
String pathDirectory = dialog.open();
if (pathDirectory != null) {
destinationTextField.setText(pathDirectory);
- setDownloadFileLocalURL(pathDirectory);
validatePage();
}
}
@@ -330,8 +329,6 @@
String pathDirectory = dialog.open();
if (pathDirectory != null) {
existingVirtualImageTextField.setText(pathDirectory);
- ((NewMaemoSDKVMWizard) getWizard()).getInstallData()
- .setPathOfExistentVM(pathDirectory);
validatePage();
}
}
@@ -356,7 +353,7 @@
GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).span(4, 1)
.applyTo(label);
- imageDescription = new Text(composite,SWT.BORDER | SWT.MULTI | SWT.WRAP);
+ imageDescription = new Text(composite, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
imageDescription.setEditable(false);
GridDataFactory.fillDefaults().grab(true, true).span(4, 1).applyTo(
imageDescription);
@@ -408,9 +405,11 @@
File file = new File(destination);
if (!file.exists() || !file.isDirectory()){
errorMessage = "Invalid location for Maemo SDK virtual image. Please, select a valid directory.";
+ } else {
+ setDownloadFileLocalURL(destination);
}
}
-
+
String existingVirtualImageLocation = "";
if (errorMessage == null && usePreviousDownloadButton.getSelection()) {
existingVirtualImageLocation = existingVirtualImageTextField.getText().trim();
@@ -420,6 +419,8 @@
File file = new File(existingVirtualImageLocation);
if (!file.exists() || file.isDirectory()){
errorMessage = "Invalid Maemo SDK virtual image. You must select a zipped file that contains Maemo SDK virtual image.";
+ } else {
+ ((NewMaemoSDKVMWizard) getWizard()).getInstallData().setPathOfExistentVM(existingVirtualImageLocation);
}
}
}
More information about the Esbox-commits
mailing list