[Esbox-commits] r2064 - in branches/work_Raul/org.maemo.esbox.vm.vmware: . src/org/maemo/esbox/internal/api/vm/vmware src/org/maemo/esbox/internal/vm/vmware/ui/wizards

raul at garage.maemo.org raul at garage.maemo.org
Mon Aug 31 21:38:47 EEST 2009


Author: raul
Date: 2009-08-31 21:38:46 +0300 (Mon, 31 Aug 2009)
New Revision: 2064

Removed:
   branches/work_Raul/org.maemo.esbox.vm.vmware/data/
Modified:
   branches/work_Raul/org.maemo.esbox.vm.vmware/build.properties
   branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
   branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
   branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
   branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java
   branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
Log:
Bug fix #4444

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/build.properties
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/build.properties	2009-08-31 16:41:31 UTC (rev 2063)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/build.properties	2009-08-31 18:38:46 UTC (rev 2064)
@@ -6,5 +6,4 @@
                conf/,\
                about_files/,\
                about.html,\
-               data/,\
                icons/

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java	2009-08-31 16:41:31 UTC (rev 2063)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java	2009-08-31 18:38:46 UTC (rev 2064)
@@ -31,6 +31,8 @@
 	private String version;
 	
 	private String description;
+	
+	private String licenseText;
 
 	/** 
 	 * Constructor
@@ -40,15 +42,16 @@
 	 * @param description
 	 */
 	public MaemoSDKVMDescription(boolean isServerImage, String name,
-			String version, String description) {
+			String version, String description, String licenseText) {
 		this.isServerImage = isServerImage;
 		this.name = name;
 		this.version = version;
 		this.description = description;
+		this.licenseText = licenseText;
 	}
 	
 	public MaemoSDKVMDescription() {
-		this(true,"","","");
+		this(true,"","","","");
 	}
 
 	/**
@@ -79,6 +82,13 @@
 		return description;
 	}
 	
+	/**
+	 * @return the license of the virtual machine
+	 */
+	public String getLicense() {
+		return licenseText;
+	}
+	
 	@Override
 	public boolean equals(Object obj) {
 		if (obj == null)

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java	2009-08-31 16:41:31 UTC (rev 2063)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java	2009-08-31 18:38:46 UTC (rev 2064)
@@ -92,7 +92,7 @@
 			status = this.uncompressVM(shell, monitor);
 		
 		if (canProceed(status))
-			status = promptPreferencesDialog(shell);			
+			status = promptPreferencesDialog(shell, monitor);			
 		
 		if (canProceed(status) && installData.canInstallSbox())
 			status = this.installScratchbox(shell,monitor);
@@ -324,7 +324,10 @@
 	 * @param shell
 	 * @return
 	 */
-	private IStatus promptPreferencesDialog(final Shell shell) {		
+	private IStatus promptPreferencesDialog(final Shell shell, IProgressMonitor monitor) {		
+		monitor.subTask("Configuring Maemo SDK virtual image...");
+		reporter.logInfo("Configuring Maemo SDK virtual image...");
+		
 		final IStatus statuses[] = new IStatus[] {Policy.getCancelStatus(Activator.getDefault())};
 		
 		String vmLocation = configureInitialVMSettings();

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java	2009-08-31 16:41:31 UTC (rev 2063)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java	2009-08-31 18:38:46 UTC (rev 2064)
@@ -125,6 +125,8 @@
 				 * filter duplicated entries, for example, files split into two
 				 * parts.
 				 */
+				String license = getLicense(content);
+				
 				Pattern maemoVMPattern = Pattern
 						.compile("Maemo(\\s)+SDK(\\s)+Virtual(\\s)+Image(\\s)+with(\\s)+Ubuntu(\\s)+(\\w)+(\\s)+([\\d]*\\.[\\d]*)(\\s)+(Server|Desktop)(\\s\\-(Part)\\s\\d)?");
 				Matcher matcher = maemoVMPattern.matcher(content);
@@ -134,7 +136,7 @@
 					virtualImageName = processVirtualImageName(virtualImageName);
 					boolean isServer = virtualImageName.toLowerCase().contains("server");
 					String virtualImageDescription = isServer ? MaemoSDKVMDescription.SERVER_IMAGE_DESCRIPTION : MaemoSDKVMDescription.DESKTOP_IMAGE_DESCRIPTION;
-					virtualImagesDescriptors.add(new MaemoSDKVMDescription(isServer,virtualImageName,version,virtualImageDescription));
+					virtualImagesDescriptors.add(new MaemoSDKVMDescription(isServer,virtualImageName,version,virtualImageDescription,license));
 				}
 			} catch (Exception e) {
 				if (e instanceof InterruptedException)
@@ -163,6 +165,22 @@
 				return virtualImageName;
 			return virtualImageName.substring(0, indexOfPar).trim();
 		}
+		
+		/**
+		 * Get license from virtual images website.
+		 * @param content
+		 * @return
+		 */
+		private String getLicense(String content) {
+			final String LICENSE_PATTERN = "IMPORTANT:\\s*READ\\s*CAREFULLY\\s*BEFORE\\s*INSTALLING,\\s*DOWNLOADING,\\s*OR\\s*USING\\s*THE\\s*SOFTWARE(.*?)PLEASE\\s*SUBMIT\\s*ANY\\s*ACCOMPANYING\\s*REGISTRATION\\s*FORMS\\s*TO\\s*RECEIVE\\s*REGISTRATION\\s*BENEFITS\\s*WHERE\\s*APPLICABLE";
+			Pattern licensePattern = Pattern.compile(LICENSE_PATTERN,Pattern.DOTALL | Pattern.UNIX_LINES);
+			Matcher matcher = licensePattern.matcher(content);
+			String license = "";
+			while (matcher.find()) {
+				license = matcher.group(0);				
+			}
+			return license;
+		}
 	}
 
 	private Image vmImage;

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java	2009-08-31 16:41:31 UTC (rev 2063)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java	2009-08-31 18:38:46 UTC (rev 2064)
@@ -12,13 +12,14 @@
 
 import org.eclipse.jface.wizard.WizardPage;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMDescription;
 import org.maemo.esbox.internal.vm.vmware.Activator;
 
 /**
@@ -29,7 +30,7 @@
  */
 public class MaemoSDKVMLicenseWizardPage extends WizardPage {
 
-	private String license;
+	private Browser licenseText;
 	private boolean licenseTermsAgreed = false;
 	private boolean ok = false;
 
@@ -42,12 +43,6 @@
 	protected MaemoSDKVMLicenseWizardPage(NewMaemoSDKVMWizard wizard) {
 		super("maemovm_licensepage", "License",
 				Activator.MAEMO_VM_WIZBAN_DESCRIPTOR);
-		try {
-			license = Activator.readResourceFile("./data/license.txt");
-		} catch (Exception e) {
-			Activator.getErrorLogger().logAndShowError(
-					"Cannot open license terms file.", e);
-		}
 		setWizard(wizard);
 		ok = true;
 	}
@@ -60,70 +55,49 @@
 	 * .Composite)
 	 */
 	public void createControl(Composite parent) {
-		if (license != null) {
-			Composite container = new Composite(parent, SWT.NULL);
-			GridLayout layout = new GridLayout(1, false);
-			container.setLayout(layout);
-			GridData licenseGridData = new GridData(GridData.BEGINNING
-					| GridData.FILL_BOTH);
-			licenseGridData.widthHint = 500;
-			licenseGridData.heightHint = 300;
-			Text licenseText = new Text(container, SWT.BORDER | SWT.V_SCROLL
-					| SWT.WRAP);
+		Composite container = new Composite(parent, SWT.NULL);
+		GridLayout layout = new GridLayout(1, false);
+		container.setLayout(layout);
+		GridData licenseGridData = new GridData(GridData.BEGINNING
+				| GridData.FILL_BOTH);
+		licenseGridData.widthHint = 500;
+		licenseGridData.heightHint = 300;
+		licenseText = new Browser(container, SWT.BORDER | SWT.WRAP);
+		licenseText.setLayoutData(licenseGridData);
+		licenseText.setText("");
 
-			StringBuffer licenseTextBuffer = new StringBuffer();
-			licenseTextBuffer
-					.append("THIS LICENSE COVERS THE FOLLOWING COMPONENTS\n\n");
-			// licenseTextBuffer.append(image.getDescription() + "\n");
-			// licenseTextBuffer.append(flasher.getDescription() + "\n");
-			licenseTextBuffer.append("\n");
+		Button agreeButton = new Button(container, SWT.RADIO);
+		agreeButton.setText("I accept the terms of the license agreements"); //$NON-NLS-1$
+		agreeButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent event) {
+				// do nothing
+			}
 
-			licenseTextBuffer.append(license);
-			licenseText.setLayoutData(licenseGridData);
-			licenseText.setEditable(false);
-			// licenseText.setBackground(FlasherUtil.COLOR_WHITE);
+			public void widgetSelected(SelectionEvent event) {
+				licenseTermsAgreed = true;
+				setPageComplete(licenseTermsAgreed);
+			}
+		});
+		Button disagreeButton = new Button(container, SWT.RADIO);
+		disagreeButton
+				.setText("I do not accept the terms of the license agreements"); //$NON-NLS-1$
+		disagreeButton.setSelection(true);
+		disagreeButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent event) {
+				// do nothing
+			}
 
-			licenseText.setText(licenseTextBuffer.toString());
-			licenseText.setTopIndex(0);
+			public void widgetSelected(SelectionEvent event) {
+				licenseTermsAgreed = false;
+				((NewMaemoSDKVMWizard) getWizard()).getInstallData()
+						.setLicenseTermsAgreed(licenseTermsAgreed);
+				setPageComplete(licenseTermsAgreed);
+			}
+		});
 
-			Button agreeButton = new Button(container, SWT.RADIO);
-			agreeButton.setText("I accept the terms of the license agreements"); //$NON-NLS-1$
-			agreeButton.addSelectionListener(new SelectionListener() {
-				public void widgetDefaultSelected(SelectionEvent event) {
-					// do nothing
-				}
-
-				public void widgetSelected(SelectionEvent event) {
-					licenseTermsAgreed = true;
-					setPageComplete(licenseTermsAgreed);
-				}
-			});
-			Button disagreeButton = new Button(container, SWT.RADIO);
-			disagreeButton
-					.setText("I do not accept the terms of the license agreements"); //$NON-NLS-1$
-			disagreeButton.setSelection(true);
-			disagreeButton.addSelectionListener(new SelectionListener() {
-				public void widgetDefaultSelected(SelectionEvent event) {
-					// do nothing
-				}
-
-				public void widgetSelected(SelectionEvent event) {
-					licenseTermsAgreed = false;
-					((NewMaemoSDKVMWizard) getWizard()).getInstallData()
-							.setLicenseTermsAgreed(licenseTermsAgreed);
-					setPageComplete(licenseTermsAgreed);
-				}
-			});
-
-			setControl(container);
-		} else {
-			ok = false;
-			final String message = "Cannot fetch license terms";
-			Activator.getErrorLogger().logAndShowError(message, null); //$NON-NLS-1$
-		}
-
+		setControl(container);
 	}
-
+	
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -134,4 +108,17 @@
 		return ok && licenseTermsAgreed;
 	}
 
+	@Override
+	public void setVisible(boolean visible) {
+		super.setVisible(visible);
+		
+		MaemoSDKVMDescription descriptor = ((NewMaemoSDKVMWizard)getWizard()).getInstallData().getFileToDownload().getDescriptor();
+		
+		// if an existing Maemo SDK VM is being used, the license of latest VM is used instead.
+		// the text is not HTML-formmated. Then, it is necessary to add necessary HTML tags.
+		licenseText.setText("<html><body><pre>"+descriptor.getLicense()+"</pre></body></html>");
+		
+		((Composite)getControl()).layout();
+	}
+	
 }

Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java	2009-08-31 16:41:31 UTC (rev 2063)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java	2009-08-31 18:38:46 UTC (rev 2064)
@@ -383,7 +383,7 @@
 	private void setInitialValues() {
 		downloadLatest.setSelection(true);
 		usePreviousDownloadButton.setSelection(false);
-		destinationTextField.setText(MachineRegistry.getInstance().getLocalMachine().getUserHome().toString());
+		destinationTextField.setText(MachineRegistry.getInstance().getLocalMachine().getUserHome().toOSString());
 		existingVirtualImageTextField.setText("");
 		
 	}



More information about the Esbox-commits mailing list