[Esbox-commits] r2122 - in branches/work_Ed: org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard 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

eswartz at garage.maemo.org eswartz at garage.maemo.org
Tue Sep 8 23:34:12 EEST 2009


Author: eswartz
Date: 2009-09-08 23:34:08 +0300 (Tue, 08 Sep 2009)
New Revision: 2122

Modified:
   branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java
   branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
   branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
   branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
   branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
   branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java
Log:
Rearange the VM installer wizard to fix bugs and avoid MacOS X display deadlock issue (bugs 4500, 4517).

-- divide the VM installer steps into separate invocations of wizards.  Do not launch a wizard from another wizard, since this is correlated with the hanging issue.

Plus:

-- add next/previous buttons to SB1 wizard
-- fix bug with VM installer dev environment choices being ignored
-- initialize file selection dialog with current path

Modified: branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java	2009-09-08 19:45:43 UTC (rev 2121)
+++ branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java	2009-09-08 20:34:08 UTC (rev 2122)
@@ -139,6 +139,7 @@
 		
 		targetPage = new Scratchbox1SDKInstallerSelectionWizardPage(buildMachine);
 		addPage(targetPage);
+		setForcePreviousAndNextButtons(true);
 	}
 
 	/**
@@ -190,11 +191,13 @@
 				"SDK Installation Results", message, status, true)
 				&& !status.matches(IStatus.CANCEL);
 
+		this.success = status.isOK() || status.matches(IStatus.INFO);
+		if (success) {
+			patchAutotools();
+		}
 		if (installedNew) {
-			patchAutotools();
 			doReboot();
 		}
-		this.success = installedNew;
 		return goOn;
 	}
 
@@ -328,7 +331,6 @@
 				StructuredSelection.EMPTY);
 		Shell parent = activeWorkbenchWindow.getShell();
 		WizardDialog dialog = new WizardDialog(parent, wizard);
-		dialog.create();
 		dialog.open();
 		if (!wizard.isSuccess())
 			return Activator.createStatus(IStatus.CANCEL, "Scratchbox 1 SDK installation was canceled");

Modified: branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java	2009-09-08 19:45:43 UTC (rev 2121)
+++ branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java	2009-09-08 20:34:08 UTC (rev 2122)
@@ -190,7 +190,7 @@
 	 * @param synchronous controls whether the wizard is launched synchronously or not.
 	 * This is used in automatic invocations of the target wizard.
 	 */
-	private void promptInstallNokiaBinaries(boolean synchronous) {
+	public void promptInstallNokiaBinaries(boolean synchronous) {
 		//calls Nokia-closed binaries wizard
 		if (DialogUtils.showQuestionDialog(DialogUtils.getShell(),
 						"Nokia-closed binaries installation",
@@ -267,7 +267,7 @@
 	 * @param defaultTargets If not null the default selected targets will be these
 	 * 
 	 */
-	public static IStatus startWizard() {
+	public static IStatus startWizard(NewScratchbox1TargetWizard wizard) {
 		IWorkbenchWindow activeWorkbenchWindow = Activator.getDefault()
 				.getWorkbench().getActiveWorkbenchWindow();
 		if (activeWorkbenchWindow == null) {
@@ -275,19 +275,13 @@
 			return Activator.createStatus(IStatus.ERROR, "Cannot open Scratchbox 1 SDK wizard");
 		}
 		
-		NewScratchbox1TargetWizard wizard = new NewScratchbox1TargetWizard();
 		wizard.init(activeWorkbenchWindow.getWorkbench(),
 				StructuredSelection.EMPTY);
-		wizard.setSuppressNokiaBinariesWizard(true);
 		Shell parent = activeWorkbenchWindow.getShell();
 		WizardDialog dialog = new WizardDialog(parent, wizard);
-		dialog.create();
 		dialog.open();
 		if (!wizard.isSuccess())
 			return Activator.createStatus(IStatus.CANCEL, "Scratchbox 1 target installation was canceled");
-		
-		// now install Nokia binaries synchronously
-		wizard.promptInstallNokiaBinaries(true);
 		return Activator.createStatus(IStatus.OK, "Scratchbox 1 target installation has finished");
 	}
 

Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java	2009-09-08 19:45:43 UTC (rev 2121)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java	2009-09-08 20:34:08 UTC (rev 2122)
@@ -29,6 +29,7 @@
 import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.eclipse.jface.preference.PreferenceDialog;
 import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.ui.dialogs.PreferencesUtil;
 import org.maemo.esbox.internal.api.maemosdk.ui.preferences.MaemoSDKPreferenceIds;
@@ -46,7 +47,6 @@
 import org.maemo.mica.common.core.machine.MachineRegistry;
 import org.maemo.mica.common.core.sdk.ISDKTarget;
 import org.maemo.mica.common.core.sdk.SDKManager;
-import org.maemo.mica.common.core.ui.IProgressReporter;
 import org.maemo.mica.internal.api.common.core.filesystem.FilesystemUtils;
 import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
 import org.maemo.mica.internal.api.linux.packages.core.aptinstall.AptInstallerHelper;
@@ -61,7 +61,6 @@
 public class MaemoSDKVMInstaller {
 
 	private MaemoSDKVMInstallData installData;
-	private IProgressReporter reporter;
 
 	/**
 	 * Constructor.
@@ -71,10 +70,8 @@
 	 * @param reporter
 	 *            the progress reporter
 	 */
-	public MaemoSDKVMInstaller(MaemoSDKVMInstallData installData,
-			IProgressReporter reporter) {
+	public MaemoSDKVMInstaller(MaemoSDKVMInstallData installData) {
 		this.installData = installData;
-		this.reporter = reporter;
 	}
 	
 	/**
@@ -94,7 +91,7 @@
 			status = this.uncompressVM(shell, monitor);
 		
 		if (canProceed(status))
-			status = promptPreferencesDialog(shell, monitor);			
+			status = promptPreferencesDialog(shell, monitor);		
 		
 		if (canProceed(status) && installData.canInstallSbox())
 			status = this.installScratchbox(shell,monitor);
@@ -125,9 +122,9 @@
 	 */
 	public IStatus downloadVM(final Shell shell, IProgressMonitor monitor) {
 		monitor.subTask("Downloading image...");
-		reporter.logInfo("Downloading Maemo SDK virtual image...");
+		//reporter.reportStep("Downloading Maemo SDK virtual image...");
 		
-		shell.getDisplay().syncExec(new Runnable() {
+		Display.getDefault().syncExec(new Runnable() {
 
 			public void run() {
 				MaemoSDKVMInfo fileDownload = installData.getFileToDownload();
@@ -163,7 +160,7 @@
 	 */
 	public IStatus uncompressVM(final Shell shell, IProgressMonitor monitor) {
 		monitor.subTask("Uncompressing image...");
-		reporter.logInfo("Uncompressing Maemo SDK virtual image...");
+		//reporter.reportStep("Uncompressing Maemo SDK virtual image...");
 		
 		final String fileName = installData.getPathOfExistentVM() == null ? installData.getFileToDownload().getLocalURL().getFile() :
 			installData.getPathOfExistentVM();
@@ -176,7 +173,7 @@
 			return Activator.createStatus(IStatus.ERROR,"Cannot retrieve information about zipped Maemo SDK virtual image.");
 		} 
 		
-		shell.getDisplay().syncExec(new Runnable() {
+		Display.getDefault().syncExec(new Runnable() {
 
 			public void run() {
 				try {					
@@ -248,7 +245,7 @@
 
 							} catch (IOException ioe) {
 								statuses[0] = Activator.createErrorStatus("Cannot uncompress Maemo SDK virtual image: I/O error", ioe);
-								reporter.appendStreamText("Cannot uncompress Maemo SDK virtual image.", true);
+								//reporter.appendStreamText("Cannot uncompress Maemo SDK virtual image.", true);
 							} finally {
 
 								Policy.close(zipInputStream);
@@ -262,7 +259,7 @@
 					});
 				} catch (Exception e) {
 					statuses[0] = Activator.createErrorStatus("Cannot uncompress Maemo SDK virtual image.", e);
-					reporter.appendStreamText("Cannot procced with Maemo SDK virtual image uncompressing.",true);
+					//reporter.appendStreamText("Cannot procced with Maemo SDK virtual image uncompressing.",true);
 				}			
 			}
 		});				
@@ -278,11 +275,11 @@
 	 */
 	private IStatus installScratchbox(final Shell shell, IProgressMonitor monitor) {
 		monitor.subTask("Installing Scratchbox 1...");
-		reporter.logInfo("Installing Scratchbox 1 on Maemo SDK virtual image. This operation will take several minutes.");
+		//reporter.queryToContinue("Installing Scratchbox 1 on Maemo SDK virtual image. This operation will take several minutes.");
 		
 		final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "Scratchbox was properly installed on Maemo SDK virtual image.") } ;
 		
-		shell.getDisplay().syncExec(new Runnable() {
+		Display.getDefault().syncExec(new Runnable() {
 			
 			public void run() {
 				statuses[0] = NewScratchbox1SDKWizard.startWizard();					
@@ -301,18 +298,33 @@
 	 */
 	private IStatus installScratchboxTargets(final Shell shell, IProgressMonitor monitor) {
 		monitor.subTask("Installing Scratchbox 1 targets...");
-		reporter.logInfo("Installing Scratchbox 1 Targets on Maemo SDK virtual image.  This operation will take several minutes.");
+		//reporter.logInfo("Installing Scratchbox 1 Targets on Maemo SDK virtual image.  This operation will take several minutes.");
 		
 		final IStatus[] statuses = { Activator.createStatus(IStatus.OK, "Scratchbox targets were properly installed on Maemo SDK virtual image.") } ;
 		
-		shell.getDisplay().syncExec(new Runnable() {
+		final NewScratchbox1TargetWizard wizard = new NewScratchbox1TargetWizard();
+		wizard.setSuppressNokiaBinariesWizard(true);
+		
+		Display.getDefault().syncExec(new Runnable() {
 			
 			public void run() {
-				statuses[0] = NewScratchbox1TargetWizard.startWizard();
+				statuses[0] = NewScratchbox1TargetWizard.startWizard(wizard);
 			}
 			
 		});	
 		
+		// need to break out of syncexec to launch a new wizard on OS X
+		if (statuses[0].getSeverity() == IStatus.OK
+				|| statuses[0].getSeverity() == IStatus.INFO) {
+			Display.getDefault().syncExec(new Runnable() {
+				
+				public void run() {
+					// now install Nokia binaries synchronously
+					wizard.promptInstallNokiaBinaries(true);
+				}
+			});
+		}
+		
 		return statuses[0];
 	}
 	
@@ -334,7 +346,7 @@
 	 */
 	private IStatus promptPreferencesDialog(final Shell shell, IProgressMonitor monitor) {		
 		monitor.subTask("Configuring Maemo SDK virtual image...");
-		reporter.logInfo("Configuring Maemo SDK virtual image...");
+		//reporter.logInfo("Configuring Maemo SDK virtual image...");
 		
 		final IStatus statuses[] = new IStatus[] {Policy.getCancelStatus(Activator.getDefault())};
 		
@@ -342,7 +354,7 @@
 		
 		if (!vmLocation.trim().equals("")) {
 
-			shell.getDisplay().syncExec(new Runnable() {
+			Display.getDefault().syncExec(new Runnable() {
 
 				public void run() {
 					try {
@@ -452,7 +464,7 @@
 	 */
 	private IStatus installPackages(Shell shell, IProgressMonitor monitor) {
 		monitor.subTask("Installing programming environment...");
-		reporter.logInfo("Installing Python/C++ programming environment on Maemo SDK virtual image. This operation may take several minutes.");
+		//reporter.logInfo("Installing Python/C++ programming environment on Maemo SDK virtual image. This operation may take several minutes.");
 		
 		IStatus status = Policy.getCancelStatus(Activator.getDefault());
 		
@@ -460,7 +472,10 @@
 		
 		String[] packages = checkPackagesToInstall();
 		
-		status = AptInstallerHelper.installPackages(sdkTargets, packages, true, shell, reporter, monitor);
+		status = AptInstallerHelper.installPackages(sdkTargets, packages, true, shell,
+				"Install C++ and Python Programming Environment",
+				"Install the C++ and Python development metapackages now?",
+				null /*reporter*/, null /*monitor*/);
 				
 		return status;
 	}

Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java	2009-09-08 19:45:43 UTC (rev 2121)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java	2009-09-08 20:34:08 UTC (rev 2122)
@@ -47,6 +47,8 @@
 	private Button installCPPEnv;
 	private Button installPythonEnv;
 
+	private boolean hasBeenSeen;
+
 	/**
 	 * Constructor.
 	 * 
@@ -291,7 +293,10 @@
 	@Override
 	public void setVisible(boolean visible) {
 		super.setVisible(visible);
-		setValues();
+		if (!hasBeenSeen && visible) {
+			setInitialValues();
+			hasBeenSeen = true;
+		}
 	}
 
 	/**
@@ -314,7 +319,7 @@
 	/**
 	 * Set default values based on virtual image.
 	 */
-	private void setValues() {
+	private void setInitialValues() {
 		MaemoSDKVMInstallData installData = ((NewMaemoSDKVMWizard)getWizard()).getInstallData();
 		
 		// if use previous installation, it takes Server default values

Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java	2009-09-08 19:45:43 UTC (rev 2121)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java	2009-09-08 20:34:08 UTC (rev 2122)
@@ -46,6 +46,7 @@
 import org.maemo.mica.common.core.machine.MachineRegistry;
 import org.maemo.mica.common.ui.NetworkSettingsUI;
 import org.maemo.mica.common.ui.dialogs.DialogUtils;
+import org.maemo.mica.common.ui.dialogs.DirectoryDialogHelper;
 import org.maemo.mica.internal.api.common.ui.LazyLoadingThreadTableContentProvider;
 
 /**
@@ -258,6 +259,8 @@
 
 			public void widgetSelected(SelectionEvent evt) {
 				DirectoryDialog dialog = new DirectoryDialog(DialogUtils.getShell(), SWT.OPEN);
+				DirectoryDialogHelper.setFilterPathToExistingDirectory(dialog, 
+						destinationTextField.getText());
 				dialog.setText("Select the directory to save the Maemo SDK virtual image");
 				String pathDirectory = dialog.open();
 				if (pathDirectory != null) {

Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java	2009-09-08 19:45:43 UTC (rev 2121)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java	2009-09-08 20:34:08 UTC (rev 2122)
@@ -12,19 +12,25 @@
 
 import java.lang.reflect.InvocationTargetException;
 
+import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
 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.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Display;
 import org.eclipse.ui.INewWizard;
 import org.eclipse.ui.IWorkbench;
 import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInstaller;
 import org.maemo.esbox.internal.vm.vmware.Activator;
 import org.maemo.mica.common.core.Policy;
 import org.maemo.mica.common.core.ui.IProgressReporter;
+import org.maemo.mica.common.ui.dialogs.DialogUtils;
 import org.maemo.mica.internal.api.common.ui.wizards.WizardWorkProgressPageBase;
 
 /**
@@ -42,6 +48,7 @@
 	private MaemoSDKVMConfigurationWizardPage configurationPage;
 	private MaemoSDKVMLicenseWizardPage licensePage;
 	private MaemoSDKVMInstallData installData;
+	private int httpTimeout;
 
 	/**
 	 * Constructor
@@ -98,28 +105,57 @@
 		return downloadUncompressWorkPage;
 	}
 	
+	
+	protected IStatus doWork() {
+
+		final IStatus statuses[] = { Status.CANCEL_STATUS };
+		
+		final MaemoSDKVMInstaller installer = new MaemoSDKVMInstaller(
+				installData);
+		
+		try {
+			statuses[0] = installer.installVirtualImage(
+							httpTimeout, 
+							null,
+							new NullProgressMonitor());
+			
+			return statuses[0];
+		} catch (Exception e) {
+			return Activator.createErrorStatus("Unexpected exception running installer", e);
+		}
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
 	 */
 	public boolean performFinish() {
-		final IStatus status = doWork();
+		httpTimeout = ((MaemoSDKVMInstallationWorkPage)getWorkPage()).getTimeout();
+		
+		// invoke the work after the wizard has gone away
+		getContainer().getShell().addDisposeListener(new DisposeListener() {
+			public void widgetDisposed(DisposeEvent e) {
+				Display.getDefault().asyncExec(new Runnable() {
+					public void run() {
+						final IStatus status = doWork();
 
-		final boolean success = (status.isOK() || status.matches(IStatus.INFO));
+						final boolean success = (status.isOK() || status.matches(IStatus.INFO));
+						
+						if (success)
+							DialogUtils.showMessageDialog(null, "Installation Complete", "All the steps of the VM installation are complete.");
+						else
+							Activator.getErrorLogger().logAndShowError("Installation did not complete successfully.\n \nIf the virtual machine was downloaded and configured, you can finish the installation manually with wizards under 'File > New > Other > Maemo Installers'.", 
+									new CoreException(status));
+					}
+				});
+			}
+		});
 
-		String message = success ? "Installation succeeded"
-				: "Installation encountered some errors";
-
-		boolean goOn = getWorkPage().reportOperationStatus(
-				"Maemo SDK Virtual Image installation results", message,
-				status, true)
-				&& !status.matches(IStatus.CANCEL);
-
-		return goOn;
+		return true;
 	}
 	
-	protected IStatus doWork() {
+	protected IStatus __doWork() {
 
 		getWorkPage().showAndClearLog();
 
@@ -135,7 +171,7 @@
 					
 					IProgressReporter reporter = getWorkPage().getProgressReporter();
 					
-					MaemoSDKVMInstaller vmInstaller = new MaemoSDKVMInstaller(installData, reporter);
+					MaemoSDKVMInstaller vmInstaller = new MaemoSDKVMInstaller(installData);
 					
 					status = vmInstaller.installVirtualImage(((MaemoSDKVMInstallationWorkPage)getWorkPage()).getTimeout(), getShell(), monitor);
 					



More information about the Esbox-commits mailing list