[Esbox-commits] r2068 - in branches/work_Ed/org.maemo.esbox.vm.vmware: . src/org/maemo/esbox/internal/api/vm/vmware src/org/maemo/esbox/internal/vm/vmware/ui/wizards
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Tue Sep 1 15:36:23 EEST 2009
Author: eswartz
Date: 2009-09-01 15:36:21 +0300 (Tue, 01 Sep 2009)
New Revision: 2068
Removed:
branches/work_Ed/org.maemo.esbox.vm.vmware/data/
Modified:
branches/work_Ed/org.maemo.esbox.vm.vmware/build.properties
branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.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/MaemoSDKVMInstallerContentLabelProvider.java
branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java
branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java
Log:
Merge revs 2062:2067 from trunk
Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/build.properties
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/build.properties 2009-09-01 02:15:12 UTC (rev 2067)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/build.properties 2009-09-01 12:36:21 UTC (rev 2068)
@@ -6,5 +6,4 @@
conf/,\
about_files/,\
about.html,\
- data/,\
icons/
Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java 2009-09-01 02:15:12 UTC (rev 2067)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java 2009-09-01 12:36:21 UTC (rev 2068)
@@ -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)
@@ -98,5 +108,4 @@
return 1;
return (-1) * (getVersion() + (isServerImage() ? "server" : "desktop")).compareTo(o.getVersion() + (o.isServerImage() ? "server" : "desktop"));
}
-
-}
\ No newline at end of file
+}
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-01 02:15:12 UTC (rev 2067)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java 2009-09-01 12:36:21 UTC (rev 2068)
@@ -28,6 +28,7 @@
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.preference.PreferenceDialog;
+import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.PreferencesUtil;
import org.maemo.esbox.internal.api.maemosdk.ui.preferences.MaemoSDKPreferenceIds;
@@ -47,6 +48,7 @@
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;
/**
@@ -92,7 +94,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);
@@ -225,9 +227,9 @@
if (previousProgressValue < progressValue) {
previousProgressValue = progressValue;
monitor.worked(1);
- if (monitor.isCanceled())
- return;
}
+ if (monitor.isCanceled())
+ break;
monitor.subTask("Uncompressing " + zipEntry
+ "\t\t"
+ String.format(Locale.US, "%.2f", getProgress(lenght,totalRead)) + "%");
@@ -235,7 +237,13 @@
}
fileOutputStream.close();
zipInputStream.closeEntry();
- zipEntry = zipInputStream.getNextEntry();
+
+ if (monitor.isCanceled()) {
+ statuses[0] = Activator.createErrorStatus("Installation was cancelled.", null);
+ return;
+ } else {
+ zipEntry = zipInputStream.getNextEntry();
+ }
}
} catch (IOException ioe) {
@@ -255,10 +263,10 @@
} 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);
- }
+ }
}
});
-
+
return statuses[0];
}
@@ -324,7 +332,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();
@@ -334,21 +345,34 @@
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.");
+ try {
+ SDKManagerInternal.getInstance().lock();
+
+ 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);
+ int result = dialog.open();
+
+ // user clicked on Cancel
+ if (result == Window.CANCEL) {
+ statuses[0] = Activator.createErrorStatus("Installation was cancelled.", null);
+ return;
+ }
+
+ // 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.");
+
+ } finally {
+ SDKManagerInternal.getInstance().unlock();
+ }
}
});
}
Modified: branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-09-01 02:15:12 UTC (rev 2067)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-09-01 12:36:21 UTC (rev 2068)
@@ -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_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java 2009-09-01 02:15:12 UTC (rev 2067)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMLicenseWizardPage.java 2009-09-01 12:36:21 UTC (rev 2068)
@@ -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_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-01 02:15:12 UTC (rev 2067)
+++ branches/work_Ed/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java 2009-09-01 12:36:21 UTC (rev 2068)
@@ -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