[Esbox-commits] r2034 - in trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal: api/vm/vmware vm/vmware/ui/wizards

raul at garage.maemo.org raul at garage.maemo.org
Thu Aug 27 22:50:10 EEST 2009


Author: raul
Date: 2009-08-27 22:50:09 +0300 (Thu, 27 Aug 2009)
New Revision: 2034

Modified:
   trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
   trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
   trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
Log:
Merged revs 2023:2033 from work_Raul to trunk

Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java	2009-08-27 19:32:52 UTC (rev 2033)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java	2009-08-27 19:50:09 UTC (rev 2034)
@@ -297,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);
@@ -378,8 +379,7 @@
 				}
 			}
 			
-			if (thread.isCompleted() &&
-					downloadFile.getDownloadedSize() == remoteFileSize.intValue()) {
+			if (thread.isCompleted()) {
 				downloadFile.complete();
 			}
 			

Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java	2009-08-27 19:32:52 UTC (rev 2033)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java	2009-08-27 19:50:09 UTC (rev 2034)
@@ -86,25 +86,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 +164,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
@@ -323,44 +322,36 @@
 	 * @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() {
-
-			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.");
-			}			
+		String vmLocation = configureInitialVMSettings();
+		
+		if (!vmLocation.trim().equals("")) {
 			
-		});
-		
+			shell.getDisplay().syncExec(new Runnable() {
+	
+				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.");
+				}			
+				
+			});
+		}
+			
 		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 +363,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: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java	2009-08-27 19:32:52 UTC (rev 2033)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java	2009-08-27 19:50:09 UTC (rev 2034)
@@ -267,7 +267,6 @@
 				String pathDirectory = dialog.open();
 				if (pathDirectory != null) {
 					destinationTextField.setText(pathDirectory);
-					setDownloadFileLocalURL(pathDirectory);
 					validatePage();
 				}
 			}
@@ -326,8 +325,6 @@
 				String pathDirectory = dialog.open();
 				if (pathDirectory != null) {
 					existingVirtualImageTextField.setText(pathDirectory);
-					((NewMaemoSDKVMWizard) getWizard()).getInstallData()
-							.setPathOfExistentVM(pathDirectory);
 					validatePage();
 				}
 			}
@@ -404,9 +401,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();
@@ -416,6 +415,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