[Esbox-commits] r2136 - in trunk: 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/commands 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
Thu Sep 10 01:29:50 EEST 2009
Author: eswartz
Date: 2009-09-10 01:29:39 +0300 (Thu, 10 Sep 2009)
New Revision: 2136
Modified:
trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java
trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/commands/TestScratchboxFacade.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DefaultVMZipExtractor.java
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/MaemoSDKVMInfo.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/api/vm/vmware/Tool7zip.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
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/MaemoSDKVMUncompressInfoWizardPage.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java
Log:
Merge revs 2106:2135 from work_Ed branch. Bugs 4500, 4517
Modified: trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1SDKWizard.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -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: trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/ui/wizard/NewScratchbox1TargetWizard.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -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: trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/commands/TestScratchboxFacade.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/commands/TestScratchboxFacade.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/commands/TestScratchboxFacade.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -109,36 +109,16 @@
cputranspExpected
.add("/scratchbox/devkits/cputransp/bin/qemu-arm-0.8.2-sb2");
cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-armeb-0.8.1-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-armeb-0.8.2-sb2");
- cputranspExpected
.add("/scratchbox/devkits/cputransp/bin/qemu-i386-0.7.0-sb2");
cputranspExpected
.add("/scratchbox/devkits/cputransp/bin/qemu-i386-0.8.1-sb2");
cputranspExpected
.add("/scratchbox/devkits/cputransp/bin/qemu-i386-0.8.2-sb2");
cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-mips-0.8.1-sb2");
+ .add("/scratchbox/devkits/qemu/bin/qemu-arm-sb");
cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-mips-0.8.2-sb2");
+ .add("/scratchbox/devkits/qemu/bin/qemu-i386-sb");
cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-mipsel-0.8.1-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-mipsel-0.8.2-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-ppc-0.7.0-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-ppc-0.8.0-m2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-ppc-0.8.1-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-ppc-0.8.2-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-sparc-0.7.0-sb2");
- cputranspExpected
- .add("/scratchbox/devkits/cputransp/bin/qemu-sparc-0.8.1-sb2");
- cputranspExpected
.add("/scratchbox/devkits/cputransp/bin/qemu-sparc-0.8.2-sb2");
cputranspExpected.add("/scratchbox/devkits/cputransp/bin/sbrsh");
@@ -279,7 +259,7 @@
List<String> compilers = getCompilers();
String compiler = "host-gcc";
for (String c : compilers) {
- if (c.matches("cs2005.*arm")) {
+ if (c.matches("cs200[5-9].*arm.*")) {
compiler = c;
break;
}
@@ -287,7 +267,7 @@
List<String> cputransps = getCputransps();
String cputransp = "sbrsh";
for (String c : cputransps) {
- if (c.matches("qemu.*arm.*sb2")) {
+ if (c.matches("qemu.*arm.*sb.*")) {
cputransp = c;
break;
}
@@ -296,7 +276,7 @@
sdk.createTarget(
TARGET_NAME,
compiler,
- "doctools:cputransp",
+ "doctools:perl",
cputransp);
List<String> targetsAvailable;//ScratchboxFacade.getInstance().getTargets(sdk);
@@ -404,53 +384,4 @@
// fail("Not yet implemented");
}
- /**
- * Test method for
- * {@link org.maemo.esbox.common.core.scratchbox.ScratchboxFacade#showTarget(java.lang.String)}.
- *
- * @throws ESboxException
- */
- /*
- @Test
- public void testShowTarget() throws ESboxException {
- final String TARGET_ARMEL = "SDK_ARMEL";
-
- ScratchboxTarget target = ScratchboxFacade.getInstance().showTarget(sdk,
- TARGET_ARMEL);
-
- assertEquals(TARGET_ARMEL, target.getName());
- assertEquals("cs2005q3.2-glibc-arm", target.getCompiler());
- assertEquals("/scratchbox/devkits/cputransp/bin/qemu-arm-0.8.2-sb2",
- target.getCputransp());
-
- List<String> devkitsExpected = new ArrayList<String>();
- devkitsExpected.add("perl");
- devkitsExpected.add("maemo3-tools");
- devkitsExpected.add("doctools");
- devkitsExpected.add("debian-sarge");
- devkitsExpected.add("maemo3-debian");
- devkitsExpected.add("cputransp");
-
- List<String> devkitsActual = target.getDevkits();
- for (String devkit : devkitsActual) {
- assertTrue(devkitsExpected.contains(devkit));
- }
- }
- */
-
- /**
- * Test method for
- * {@link org.maemo.esbox.common.core.scratchbox.ScratchboxFacade#execSimpleCommand(java.lang.String)}.
- *
- * @throws ESboxException
- */
-// @Test
-// public void testExecSimpleCommand() throws ESboxException {
-// ISDKTarget sdkTarget = sdk.getSDKTargets()[0];
-// List<String> currentTarget = ScratchboxFacade.getInstance().execSimpleCommand(
-// sdkTarget,
-// CommandLineArguments.createFromVarArgs("sb-conf", "current"));
-// assertEquals(sdkTarget.getName(), currentTarget.get(0));
-// }
-
}
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DefaultVMZipExtractor.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DefaultVMZipExtractor.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/DefaultVMZipExtractor.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -24,8 +24,10 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.maemo.esbox.internal.vm.vmware.Activator;
import org.maemo.mica.common.core.Policy;
@@ -50,9 +52,9 @@
*/
public static IStatus extract(final String fileName, final Shell shell,
final String destinationPath, final IProgressReporter reporter) {
- final IStatus[] status = new IStatus[1];
+ final IStatus[] status = { Status.OK_STATUS };
- shell.getDisplay().syncExec(new ZipExtractor(status, shell, reporter, fileName, destinationPath));
+ Display.getDefault().syncExec(new ZipExtractor(status, shell, reporter, fileName, destinationPath));
return status[0];
}
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-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -82,6 +82,11 @@
try {
remoteURL = getLinkFor(downloadPage, downloadFile.getDescriptor().getName());
+ if (remoteURL == null) {
+ throw new MicaException("Cannot locate ''" + downloadFile.getDescriptor().getName()
+ + "'' on " + MaemoSDKVMInfo.DOWNLOAD_PAGE);
+ }
+
if(downloadFile.isMultipart() && nPart != null){
String url = remoteURL.toExternalForm();
int i = url.lastIndexOf('.');
@@ -98,11 +103,6 @@
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);
}
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -121,11 +121,8 @@
}
private File internalResolveLocalFile(String fileName) {
- try {
- return new File(getInstallLocation().toURI().resolve(fileName));
- } catch (URISyntaxException e) {
- return null;
- }
+ String path = getInstallLocation().getPath();
+ return new File(path, fileName);
}
/**
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-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInstaller.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -11,6 +11,7 @@
package org.maemo.esbox.internal.api.vm.vmware;
import java.io.File;
+import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -18,8 +19,10 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+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;
@@ -39,6 +42,7 @@
import org.maemo.mica.common.core.sdk.SDKManager;
import org.maemo.mica.common.core.ui.IProgressReporter;
import org.maemo.mica.common.ui.dialogs.DialogUtils;
+import org.maemo.mica.common.ui.dialogs.StyledTextProgressDialog;
import org.maemo.mica.internal.api.common.core.GeneralUtils;
import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
import org.maemo.mica.internal.api.linux.packages.core.aptinstall.AptInstallerHelper;
@@ -53,7 +57,6 @@
public class MaemoSDKVMInstaller {
private MaemoSDKVMInstallData installData;
- private IProgressReporter reporter;
/**
* Constructor.
@@ -63,10 +66,8 @@
* @param reporter
* the progress reporter
*/
- public MaemoSDKVMInstaller(MaemoSDKVMInstallData installData,
- IProgressReporter reporter) {
+ public MaemoSDKVMInstaller(MaemoSDKVMInstallData installData) {
this.installData = installData;
- this.reporter = reporter;
}
/**
@@ -86,7 +87,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);
@@ -117,9 +118,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();
@@ -154,6 +155,47 @@
* @return the result of process as IStatus.
*/
public IStatus uncompressVM(final Shell shell, IProgressMonitor monitor) {
+ final StyledTextProgressDialog dialog = new StyledTextProgressDialog(shell, "Uncompressing Image");
+ dialog.setBlockOnOpen(false);
+
+ dialog.open();
+
+ final IStatus[] statuses = { Policy.getCancelStatus(Activator.getDefault()) };
+ final IProgressReporter reporter = dialog.getProgressReporter();
+ try {
+ dialog.run(true, true, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ statuses[0] = doUncompressVM(dialog.getShell(), reporter, monitor);
+ }
+ });
+
+ reporter.log(statuses[0]);
+
+ if (statuses[0].isOK() || statuses[0].getSeverity() == IStatus.INFO) {
+ dialog.close();
+ }
+
+ return statuses[0];
+ } catch (Exception e) {
+ Throwable t;
+ if (e instanceof InvocationTargetException)
+ t = ((InvocationTargetException) e).getCause();
+ else
+ t = e;
+ IStatus status = Activator.createErrorStatus("Failed to extract image", t);
+ Activator.getErrorLogger().log(status);
+ return status;
+ }
+ }
+
+ /**
+ * Uncompress the Maemo SDK virtual image.
+ *
+ * @return the result of process as IStatus.
+ */
+ private IStatus doUncompressVM(final Shell shell, IProgressReporter reporter, IProgressMonitor monitor) {
monitor.subTask("Uncompressing image...");
reporter.logInfo("Uncompressing Maemo SDK virtual image...");
@@ -221,11 +263,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();
@@ -244,18 +286,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];
}
@@ -267,7 +324,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())};
@@ -275,7 +332,7 @@
if (!vmLocation.trim().equals("")) {
- shell.getDisplay().syncExec(new Runnable() {
+ Display.getDefault().syncExec(new Runnable() {
public void run() {
try {
@@ -385,7 +442,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());
@@ -393,7 +450,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: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/Tool7zip.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/Tool7zip.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/Tool7zip.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -1,141 +1,141 @@
-package org.maemo.esbox.internal.api.vm.vmware;
-
-import java.io.File;
-
-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.maemo.esbox.internal.vm.vmware.Activator;
-import org.maemo.mica.common.core.MicaException;
-import org.maemo.mica.common.core.machine.IMachine;
-import org.maemo.mica.common.core.machine.MachineRegistry;
-import org.maemo.mica.common.core.machine.MachineUtils;
-import org.maemo.mica.common.core.process.CommandLineArguments;
-import org.maemo.mica.common.core.process.IProcessLauncher;
-import org.maemo.mica.common.core.process.IProcessLauncherFactory;
-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.ui.IProgressReporter;
-import org.maemo.mica.common.core.ui.ProgressReporterStreamTextMonitor;
-
-/**
- * @author Fabrício S Epaminondas
- *
- */
-public class Tool7zip {
- /**
- * No error
- */
- public static int EXIT_CODE_NO_ERROR = 0;
- /**
- * Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
- */
- public static int EXIT_CODE_WARNING = 1;
- /**
- * Fatal error
- */
- public static int EXIT_CODE_FATAL = 2;
- /**
- * Command line error
- */
- public static int EXIT_CODE_ERROR = 7;
- /**
- * Not enough memory for operation
- */
- public static int EXIT_CODE_NOT_ENOUGH_MEMORY = 8;
- /**
- * User stopped the process
- */
- public static int EXIT_CODE_STOPPED = 255;
-
- private String path;
- private final IMachine machine;
-
-
- /**
- * Creates a 7z tool reference using default path
- */
- public Tool7zip() {
- super();
- this.machine = MachineRegistry.getInstance().getLocalMachine();
- IPath path = MachineUtils.findProgramOnPath(machine, "7z");
-
- if(path ==null)
- throw new IllegalArgumentException("7zip could not be found on machine.");
- this.path = path.toOSString();
-
- }
- /**
- * Creates a 7z tool reference using the passed path
- * @param path
- * @param machine
- * @throws MicaException
- */
- public Tool7zip(String path) {
- super();
- this.machine = MachineRegistry.getInstance().getLocalMachine();
-
- if(!machine.getFileSystemAccess().getFileStore(new Path(path)).fetchInfo().exists())
- throw new IllegalArgumentException("7zip could not be found on machine.");
- this.path = path;
- }
-
-
- /**
- * @param machine
- * @param fileName
- * @param destinationPath
- * @param monitor
- * @return
- * @throws MicaException
- */
- public int extract(String fileName,
- String destinationPath, final IProgressReporter reporter, IProgressMonitor monitor) throws MicaException {
- String[] commandArray = new String[] {path, "-y", "x", "-o" +destinationPath, fileName};
- IProcessLauncherFactory factory = machine.getProcessLauncherFactory();
- IProcessLauncher launcher = factory.createProcessLauncher(ProcessLauncherParameters.create(
- new Path(new File(fileName).getParent()),
- CommandLineArguments.createFromArray(commandArray)));
-
- return ProcessLauncherUtils.launchAndMonitorStandardStreams(launcher,
- new IStreamMonitor[] { new ProgressReporterStreamTextMonitor(reporter)}, monitor);
- }
-
-
- /**
- * @param machine
- * @param fileName
- * @param destinationPath
- * @param monitor
- * @return
- * @throws MicaException
- */
- public IStatus extractAndGetStatus(String fileName,
- String destinationPath, IProgressReporter reporter, IProgressMonitor monitor) {
- IStatus status = Activator.createStatus(IStatus.OK, "No error.");
- try {
- int exit = extract(fileName, destinationPath, reporter, monitor);
- if(exit == EXIT_CODE_NO_ERROR){
- //Ok, no error
- }else if(exit == -1){
- status = Activator.createStatus(IStatus.ERROR, "The file could not be uncompressed.");
- }else if(exit == EXIT_CODE_WARNING){
- status = Activator.createStatus(IStatus.WARNING, "One or more files can be locked by some other application, so they were not compressed.");
- }else if(exit == EXIT_CODE_FATAL){
- status = Activator.createStatus(IStatus.ERROR, "Fatal error.");
- }else if(exit == EXIT_CODE_ERROR){
- status = Activator.createStatus(IStatus.ERROR, "Command line error.");
- }else if(exit == EXIT_CODE_NOT_ENOUGH_MEMORY){
- status = Activator.createStatus(IStatus.CANCEL, "Not enough memory for operation.");
- }else if(exit == EXIT_CODE_STOPPED){
- status = Activator.createStatus(IStatus.CANCEL, "User stopped the process.");
- }
- } catch (MicaException e) {
- status = Activator.createErrorStatus("Uncompression failed.", e);
- }
-
- return status;
- }
-}
+package org.maemo.esbox.internal.api.vm.vmware;
+
+import java.io.File;
+
+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.maemo.esbox.internal.vm.vmware.Activator;
+import org.maemo.mica.common.core.MicaException;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.core.machine.MachineUtils;
+import org.maemo.mica.common.core.process.CommandLineArguments;
+import org.maemo.mica.common.core.process.IProcessLauncher;
+import org.maemo.mica.common.core.process.IProcessLauncherFactory;
+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.ui.IProgressReporter;
+import org.maemo.mica.common.core.ui.ProgressReporterStreamTextMonitor;
+
+/**
+ * @author Fabrício S Epaminondas
+ *
+ */
+public class Tool7zip {
+ /**
+ * No error
+ */
+ public static int EXIT_CODE_NO_ERROR = 0;
+ /**
+ * Warning (Non fatal error(s)). For example, one or more files were locked by some other application, so they were not compressed.
+ */
+ public static int EXIT_CODE_WARNING = 1;
+ /**
+ * Fatal error
+ */
+ public static int EXIT_CODE_FATAL = 2;
+ /**
+ * Command line error
+ */
+ public static int EXIT_CODE_ERROR = 7;
+ /**
+ * Not enough memory for operation
+ */
+ public static int EXIT_CODE_NOT_ENOUGH_MEMORY = 8;
+ /**
+ * User stopped the process
+ */
+ public static int EXIT_CODE_STOPPED = 255;
+
+ private String path;
+ private final IMachine machine;
+
+
+ /**
+ * Creates a 7z tool reference using default path
+ */
+ public Tool7zip() {
+ super();
+ this.machine = MachineRegistry.getInstance().getLocalMachine();
+ IPath path = MachineUtils.findProgramOnPath(machine, "7z");
+
+ if(path ==null)
+ throw new IllegalArgumentException("7zip could not be found on machine.");
+ this.path = path.toOSString();
+
+ }
+ /**
+ * Creates a 7z tool reference using the passed path
+ * @param path
+ * @param machine
+ * @throws MicaException
+ */
+ public Tool7zip(String path) {
+ super();
+ this.machine = MachineRegistry.getInstance().getLocalMachine();
+
+ if(!machine.getFileSystemAccess().getFileStore(new Path(path)).fetchInfo().exists())
+ throw new IllegalArgumentException("7zip could not be found on machine.");
+ this.path = path;
+ }
+
+
+ /**
+ * @param machine
+ * @param fileName
+ * @param destinationPath
+ * @param monitor
+ * @return
+ * @throws MicaException
+ */
+ public int extract(String fileName,
+ String destinationPath, final IProgressReporter reporter, IProgressMonitor monitor) throws MicaException {
+ String[] commandArray = new String[] {path, "-y", "x", "-o" +destinationPath, fileName};
+ IProcessLauncherFactory factory = machine.getProcessLauncherFactory();
+ IProcessLauncher launcher = factory.createProcessLauncher(ProcessLauncherParameters.create(
+ new Path(new File(fileName).getParent()),
+ CommandLineArguments.createFromArray(commandArray)));
+
+ return ProcessLauncherUtils.launchAndMonitorStandardStreams(launcher,
+ new IStreamMonitor[] { new ProgressReporterStreamTextMonitor(reporter)}, monitor);
+ }
+
+
+ /**
+ * @param machine
+ * @param fileName
+ * @param destinationPath
+ * @param monitor
+ * @return
+ * @throws MicaException
+ */
+ public IStatus extractAndGetStatus(String fileName,
+ String destinationPath, IProgressReporter reporter, IProgressMonitor monitor) {
+ IStatus status = Activator.createStatus(IStatus.OK, "No error.");
+ try {
+ int exit = extract(fileName, destinationPath, reporter, monitor);
+ if(exit == EXIT_CODE_NO_ERROR){
+ //Ok, no error
+ }else if(exit == -1){
+ status = Activator.createStatus(IStatus.ERROR, "The file could not be uncompressed.");
+ }else if(exit == EXIT_CODE_WARNING){
+ status = Activator.createStatus(IStatus.WARNING, "One or more files can be locked by some other application, so they were not compressed.");
+ }else if(exit == EXIT_CODE_FATAL){
+ status = Activator.createStatus(IStatus.ERROR, "Fatal error.");
+ }else if(exit == EXIT_CODE_ERROR){
+ status = Activator.createStatus(IStatus.ERROR, "Command line error.");
+ }else if(exit == EXIT_CODE_NOT_ENOUGH_MEMORY){
+ status = Activator.createStatus(IStatus.CANCEL, "Not enough memory for operation.");
+ }else if(exit == EXIT_CODE_STOPPED){
+ status = Activator.createStatus(IStatus.CANCEL, "User stopped the process.");
+ }
+ } catch (MicaException e) {
+ status = Activator.createErrorStatus("Uncompression failed.", e);
+ }
+
+ return status;
+ }
+}
Property changes on: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/Tool7zip.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -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: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -1,271 +1,271 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (c) 2009 Nokia Corporation
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.vm.vmware.ui.wizards;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.eclipse.swt.graphics.Image;
-import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMDescription;
-import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo;
-import org.maemo.esbox.internal.vm.vmware.Activator;
-import org.maemo.mica.internal.api.common.ui.LazyLoadingThreadTableContentProvider;
-
-import com.nokia.cpp.internal.api.utils.core.FileUtils;
-
-/**
- * Content and label provider for table that shows available Maemo SDK virtual
- * images.
- *
- * @author raulherbster
- *
- */
-public class MaemoSDKVMInstallerContentLabelProvider extends
- LazyLoadingThreadTableContentProvider {
-
- /**
- * Thread to access information about available Maemo SDK virtual images on
- * website.
- *
- * @author raulherbster
- *
- */
- protected class MaemoVMInstallScriptFetcherThread extends Thread {
- protected Object newInput;
-
- /**
- * Construtor.
- *
- * @param newInput
- */
- public MaemoVMInstallScriptFetcherThread(Object newInput) {
- this.newInput = newInput;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Thread#run()
- */
- public void run() {
- doFetchScripts();
-
- contents.remove(LOADING_LABEL);
- doFireContentChanged();
- }
-
- /**
- * Implement by querying the input and/or calling fetchScriptsFromUrl()
- * and adding them to contents.
- */
- protected void doFetchScripts() {
- List<MaemoSDKVMDescription> virtualImagesNames = fetchVMNamesFromUrl(MaemoSDKVMInfo.DOWNLOAD_PAGE);
- for (MaemoSDKVMDescription maemoSDKVM : virtualImagesNames) {
- MaemoSDKVMInfo downloadFile = new MaemoSDKVMInfo();
- downloadFile.setDescriptor(maemoSDKVM);
- if (!contents.contains(downloadFile))
- contents.add(downloadFile);
- else {
- int indexOfExistingDownloadFile = contents
- .indexOf(downloadFile);
- MaemoSDKVMInfo info = ((MaemoSDKVMInfo) contents.get(indexOfExistingDownloadFile));
- info.setNumberOfParts(info.getNumParts() +1);
- }
- }
- }
-
- /**
- * Get available Maemo SDK virtual image from given URL.
- *
- * @param urlString
- * the url of website that contains information about
- * available Maemo SDK virtual images.
- * @return a list with the names of available Maemo SDK virtual images.
- */
- protected List<MaemoSDKVMDescription> fetchVMNamesFromUrl(String urlString) {
- URL url;
- try {
- url = new URL(urlString);
- } catch (MalformedURLException e) {
- Activator.getErrorLogger().logAndShowError(
- "Invalid URL: " + urlString, e);
- return Collections.emptyList();
- }
-
- List<MaemoSDKVMDescription> virtualImagesDescriptors = new ArrayList<MaemoSDKVMDescription>();
- try {
-
- URLConnection connection = url.openConnection();
- connection.setConnectTimeout(1000 * 10);
- connection.connect();
-
- // apparently this fetches the HTML...
- String content = new String(FileUtils.readInputStreamContents(
- connection.getInputStream(), "UTF-8"));
-
- /*
- * The names of virtual images are on
- * http://tablets-dev.nokia.com/maemo-dev-env-downloads.php
- * (front-page). Basically, they list have the following format:
- * Maemo ANY_WORD Virtual ANY_WORD Image ANY_WORD Also, we
- * 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);
- while (matcher.find()) {
- String virtualImageName = matcher.group(0);
- String version = matcher.group(9);
- 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,license));
- }
- } catch (Exception e) {
- if (e instanceof InterruptedException)
- return virtualImagesDescriptors;
-
- if (!isInterrupted())
- Activator.getErrorLogger().logAndShowError(
- "Could not fetch listing from " + url, e);
- }
-
- return virtualImagesDescriptors;
- }
-
- /**
- * Process the description of Maemo SDK virtual image and only returns
- * the main description.
- *
- * @param virtualImageName
- * the complete description of a certain Maemo SDK virtual
- * image.
- * @return the main description of a certain Maemo SDK virtual image.
- */
- private String processVirtualImageName(String virtualImageName) {
- int indexOfPar = virtualImageName.indexOf("(");
- if (indexOfPar < 0)
- 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;
-
- /**
- * Construtor.
- */
- public MaemoSDKVMInstallerContentLabelProvider() {
- super();
- vmImage = Activator.MAEMO_VM_DESCRIPTOR.createImage();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.maemo.mica.common.ui.common.LazyLoadingThreadTableContentProvider
- * #createContentFetchThread(java.lang.Object)
- */
- @Override
- protected Thread createContentFetchThread(Object newInput) {
- return new MaemoVMInstallScriptFetcherThread(newInput);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
- * Object)
- */
- public Object[] getChildren(Object parentElement) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object
- * )
- */
- public Object getParent(Object element) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
- * Object)
- */
- public boolean hasChildren(Object element) {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getColumnText(Object element, int column) {
- if (element == LOADING_LABEL)
- return super.getColumnText(element, column);
-
- if (element instanceof MaemoSDKVMInfo) {
- MaemoSDKVMInfo data = (MaemoSDKVMInfo) element;
- if (column == 0)
- return data.getDescriptor().getName();
- }
- return "";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- public Image getColumnImage(Object element, int column) {
- if (element instanceof MaemoSDKVMInfo) {
- if (column == 0)
- return vmImage;
- }
- return null;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (c) 2009 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.vm.vmware.ui.wizards;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.swt.graphics.Image;
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMDescription;
+import org.maemo.esbox.internal.api.vm.vmware.MaemoSDKVMInfo;
+import org.maemo.esbox.internal.vm.vmware.Activator;
+import org.maemo.mica.internal.api.common.ui.LazyLoadingThreadTableContentProvider;
+
+import com.nokia.cpp.internal.api.utils.core.FileUtils;
+
+/**
+ * Content and label provider for table that shows available Maemo SDK virtual
+ * images.
+ *
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMInstallerContentLabelProvider extends
+ LazyLoadingThreadTableContentProvider {
+
+ /**
+ * Thread to access information about available Maemo SDK virtual images on
+ * website.
+ *
+ * @author raulherbster
+ *
+ */
+ protected class MaemoVMInstallScriptFetcherThread extends Thread {
+ protected Object newInput;
+
+ /**
+ * Construtor.
+ *
+ * @param newInput
+ */
+ public MaemoVMInstallScriptFetcherThread(Object newInput) {
+ this.newInput = newInput;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Thread#run()
+ */
+ public void run() {
+ doFetchScripts();
+
+ contents.remove(LOADING_LABEL);
+ doFireContentChanged();
+ }
+
+ /**
+ * Implement by querying the input and/or calling fetchScriptsFromUrl()
+ * and adding them to contents.
+ */
+ protected void doFetchScripts() {
+ List<MaemoSDKVMDescription> virtualImagesNames = fetchVMNamesFromUrl(MaemoSDKVMInfo.DOWNLOAD_PAGE);
+ for (MaemoSDKVMDescription maemoSDKVM : virtualImagesNames) {
+ MaemoSDKVMInfo downloadFile = new MaemoSDKVMInfo();
+ downloadFile.setDescriptor(maemoSDKVM);
+ if (!contents.contains(downloadFile))
+ contents.add(downloadFile);
+ else {
+ int indexOfExistingDownloadFile = contents
+ .indexOf(downloadFile);
+ MaemoSDKVMInfo info = ((MaemoSDKVMInfo) contents.get(indexOfExistingDownloadFile));
+ info.setNumberOfParts(info.getNumParts() +1);
+ }
+ }
+ }
+
+ /**
+ * Get available Maemo SDK virtual image from given URL.
+ *
+ * @param urlString
+ * the url of website that contains information about
+ * available Maemo SDK virtual images.
+ * @return a list with the names of available Maemo SDK virtual images.
+ */
+ protected List<MaemoSDKVMDescription> fetchVMNamesFromUrl(String urlString) {
+ URL url;
+ try {
+ url = new URL(urlString);
+ } catch (MalformedURLException e) {
+ Activator.getErrorLogger().logAndShowError(
+ "Invalid URL: " + urlString, e);
+ return Collections.emptyList();
+ }
+
+ List<MaemoSDKVMDescription> virtualImagesDescriptors = new ArrayList<MaemoSDKVMDescription>();
+ try {
+
+ URLConnection connection = url.openConnection();
+ connection.setConnectTimeout(1000 * 10);
+ connection.connect();
+
+ // apparently this fetches the HTML...
+ String content = new String(FileUtils.readInputStreamContents(
+ connection.getInputStream(), "UTF-8"));
+
+ /*
+ * The names of virtual images are on
+ * http://tablets-dev.nokia.com/maemo-dev-env-downloads.php
+ * (front-page). Basically, they list have the following format:
+ * Maemo ANY_WORD Virtual ANY_WORD Image ANY_WORD Also, we
+ * 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);
+ while (matcher.find()) {
+ String virtualImageName = matcher.group(0);
+ String version = matcher.group(9);
+ 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,license));
+ }
+ } catch (Exception e) {
+ if (e instanceof InterruptedException)
+ return virtualImagesDescriptors;
+
+ if (!isInterrupted())
+ Activator.getErrorLogger().logAndShowError(
+ "Could not fetch listing from " + url, e);
+ }
+
+ return virtualImagesDescriptors;
+ }
+
+ /**
+ * Process the description of Maemo SDK virtual image and only returns
+ * the main description.
+ *
+ * @param virtualImageName
+ * the complete description of a certain Maemo SDK virtual
+ * image.
+ * @return the main description of a certain Maemo SDK virtual image.
+ */
+ private String processVirtualImageName(String virtualImageName) {
+ int indexOfPar = virtualImageName.indexOf("(");
+ if (indexOfPar < 0)
+ 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;
+
+ /**
+ * Construtor.
+ */
+ public MaemoSDKVMInstallerContentLabelProvider() {
+ super();
+ vmImage = Activator.MAEMO_VM_DESCRIPTOR.createImage();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.maemo.mica.common.ui.common.LazyLoadingThreadTableContentProvider
+ * #createContentFetchThread(java.lang.Object)
+ */
+ @Override
+ protected Thread createContentFetchThread(Object newInput) {
+ return new MaemoVMInstallScriptFetcherThread(newInput);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
+ * Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object
+ * )
+ */
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
+ * Object)
+ */
+ public boolean hasChildren(Object element) {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ public String getColumnText(Object element, int column) {
+ if (element == LOADING_LABEL)
+ return super.getColumnText(element, column);
+
+ if (element instanceof MaemoSDKVMInfo) {
+ MaemoSDKVMInfo data = (MaemoSDKVMInfo) element;
+ if (column == 0)
+ return data.getDescriptor().getName();
+ }
+ return "";
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ public Image getColumnImage(Object element, int column) {
+ if (element instanceof MaemoSDKVMInfo) {
+ if (column == 0)
+ return vmImage;
+ }
+ return null;
+ }
+
+}
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-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -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) {
@@ -530,6 +533,8 @@
private MaemoSDKVMInfo getLatestVMInstallData(LabelProviderChangedEvent event) {
LazyLoadingThreadTableContentProvider provider = (LazyLoadingThreadTableContentProvider)event.getSource();
Object[] elements = provider.getElements(new Object[0]);
+ if (elements.length == 0)
+ return null;
Arrays.sort(elements);
return (MaemoSDKVMInfo) elements[0];
}
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMUncompressInfoWizardPage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMUncompressInfoWizardPage.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMUncompressInfoWizardPage.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -1,186 +1,186 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (c) 2009 Nokia Corporation
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.vm.vmware.ui.wizards;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.layout.GridLayoutFactory;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.maemo.esbox.internal.vm.vmware.Activator;
-import org.maemo.mica.common.core.machine.IMachine;
-import org.maemo.mica.common.core.machine.MachineRegistry;
-import org.maemo.mica.common.core.machine.MachineUtils;
-import org.maemo.mica.common.ui.dialogs.DialogUtils;
-
-/**
- * This page displays information about Maemo SDK virtual machine configuration.
- *
- * @author raulherbster
- *
- */
-public class MaemoSDKVMUncompressInfoWizardPage extends WizardPage {
-
- // options for uncompress tool
- private Text uncompressToolTextField;
-
- /**
- * Constructor.
- *
- * @param wizard
- * parent wizard.
- */
- protected MaemoSDKVMUncompressInfoWizardPage(NewMaemoSDKVMWizard wizard) {
- super("maemovm_uncompresstool", "Uncompress tool specification",
- Activator.MAEMO_VM_WIZBAN_DESCRIPTOR);
- setDescription("Specify the tool used to uncompress Maemo SDK Virtual Image.");
- setWizard(wizard);
- setPageComplete(false);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
- * .Composite)
- */
- public void createControl(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayoutFactory.fillDefaults().numColumns(4).applyTo(composite);
- GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
- setControl(composite);
-
- Label mainMessage = new Label(composite, SWT.WRAP);
- mainMessage.setText("Maemo SDK Virtual Image wizard also uncompress the virtual machine for you. " +
- "However, since Maemo SDK Virtual Images are considerable large, most of existing tools cannot uncompress them.\n" +
- "This wizard uses 7zip tool for uncompression, please specify a valid path for 7zip tool bellow.");
-
- GridData labelData = new GridData();
- labelData.horizontalSpan = 4;
- labelData.horizontalAlignment = SWT.FILL;
- Rectangle rect = getShell().getMonitor().getClientArea();
- labelData.widthHint = rect.width / 4;
- mainMessage.setLayoutData(labelData);
-
- Label separator = new Label(composite, SWT.NONE);
- GridDataFactory.swtDefaults().span(4, 1).align(SWT.LEFT, SWT.CENTER)
- .applyTo(separator);
-
-
- Label uncompressToollabel = new Label(composite, SWT.NONE);
- uncompressToollabel.setText("Uncompress tool path:");
- GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER)
- .applyTo(uncompressToollabel);
-
- uncompressToolTextField = new Text(composite, SWT.BORDER);
- uncompressToolTextField.setText(getDefault7zPath());
- uncompressToolTextField.setToolTipText("Specify the path of tool to uncompress Maemo SDK Virtual Image.");
- GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(
- uncompressToolTextField);
-
- Listener textFieldValidator = new Listener() {
- public void handleEvent(Event event) {
- validatePage();
- }
- };
-
- uncompressToolTextField.addListener(SWT.SELECTED, textFieldValidator);
- uncompressToolTextField.addListener(SWT.KeyDown, textFieldValidator);
- uncompressToolTextField.addListener(SWT.KeyUp, textFieldValidator);
-
- Button browserButton = new Button(composite, SWT.PUSH);
- browserButton.setText("Browse...");
- GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(
- browserButton);
- browserButton.addSelectionListener(new SelectionAdapter() {
-
- public void widgetSelected(SelectionEvent evt) {
- FileDialog dialog = new FileDialog(DialogUtils.getShell(),
- SWT.OPEN);
-
- String currentFile = uncompressToolTextField.getText();
- if (currentFile.length() > 0) {
- File current = new File(currentFile);
- dialog.setFilterPath(current.getParent());
- dialog.setFileName(current.getName());
- }
- dialog.setText("Select the path of uncompress tool");
- String pathDirectory = dialog.open();
- if (pathDirectory != null) {
- uncompressToolTextField.setText(pathDirectory);
- validatePage();
- }
- }
- });
-
- validatePage();
- }
-
- /**
- * Validate the wizard page.
- */
- public void validatePage() {
- String errorMessage = null;
-
- String uncompressToolPath = uncompressToolTextField.getText().trim();
- if (uncompressToolPath.equals("")){
- errorMessage = "You must specify the path of tool to uncompress the Maemo SDK Virtual Image.";
- } else {
- File file = new File(uncompressToolPath);
- if (!file.exists() || file.isDirectory()){
- errorMessage = "Invalid path for uncompress tool. Please, select a valid directory.";
- } else {
- ((NewMaemoSDKVMWizard) getWizard()).getInstallData().setUncompressToolPath(uncompressToolPath);
- }
- }
-
- setErrorMessage(errorMessage);
- setPageComplete(errorMessage == null);
- }
-
-
- public static String getDefault7zPath(){
- String path = "/usr/bin/7z";
-
- IMachine machine = MachineRegistry.getInstance().getLocalMachine();
- IPath defaultPath = MachineUtils.findProgramOnPath(machine, "7z");
-
- if(defaultPath !=null)
- return defaultPath.toOSString();
-
- if (machine.getOS().equals(Platform.OS_WIN32))
- return "C:/Program Files/7-Zip/7z.exe";
-
- if (machine.getOS().equals(Platform.OS_LINUX)) {
- return "/usr/bin/7z";
- }
- if (machine.getOS().equals(Platform.OS_MACOSX)) {
- return "/usr/bin/7z";
- }
- return path;
-
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (c) 2009 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.vm.vmware.ui.wizards;
+
+import java.io.File;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
+import org.maemo.esbox.internal.vm.vmware.Activator;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
+import org.maemo.mica.common.core.machine.MachineUtils;
+import org.maemo.mica.common.ui.dialogs.DialogUtils;
+
+/**
+ * This page displays information about Maemo SDK virtual machine configuration.
+ *
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMUncompressInfoWizardPage extends WizardPage {
+
+ // options for uncompress tool
+ private Text uncompressToolTextField;
+
+ /**
+ * Constructor.
+ *
+ * @param wizard
+ * parent wizard.
+ */
+ protected MaemoSDKVMUncompressInfoWizardPage(NewMaemoSDKVMWizard wizard) {
+ super("maemovm_uncompresstool", "Uncompress tool specification",
+ Activator.MAEMO_VM_WIZBAN_DESCRIPTOR);
+ setDescription("Specify the tool used to uncompress Maemo SDK Virtual Image.");
+ setWizard(wizard);
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ public void createControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().numColumns(4).applyTo(composite);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
+ setControl(composite);
+
+ Label mainMessage = new Label(composite, SWT.WRAP);
+ mainMessage.setText("Maemo SDK Virtual Image wizard also uncompress the virtual machine for you. " +
+ "However, since Maemo SDK Virtual Images are considerable large, most of existing tools cannot uncompress them.\n" +
+ "This wizard uses 7zip tool for uncompression, please specify a valid path for 7zip tool bellow.");
+
+ GridData labelData = new GridData();
+ labelData.horizontalSpan = 4;
+ labelData.horizontalAlignment = SWT.FILL;
+ Rectangle rect = getShell().getMonitor().getClientArea();
+ labelData.widthHint = rect.width / 4;
+ mainMessage.setLayoutData(labelData);
+
+ Label separator = new Label(composite, SWT.NONE);
+ GridDataFactory.swtDefaults().span(4, 1).align(SWT.LEFT, SWT.CENTER)
+ .applyTo(separator);
+
+
+ Label uncompressToollabel = new Label(composite, SWT.NONE);
+ uncompressToollabel.setText("Uncompress tool path:");
+ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER)
+ .applyTo(uncompressToollabel);
+
+ uncompressToolTextField = new Text(composite, SWT.BORDER);
+ uncompressToolTextField.setText(getDefault7zPath());
+ uncompressToolTextField.setToolTipText("Specify the path of tool to uncompress Maemo SDK Virtual Image.");
+ GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(
+ uncompressToolTextField);
+
+ Listener textFieldValidator = new Listener() {
+ public void handleEvent(Event event) {
+ validatePage();
+ }
+ };
+
+ uncompressToolTextField.addListener(SWT.SELECTED, textFieldValidator);
+ uncompressToolTextField.addListener(SWT.KeyDown, textFieldValidator);
+ uncompressToolTextField.addListener(SWT.KeyUp, textFieldValidator);
+
+ Button browserButton = new Button(composite, SWT.PUSH);
+ browserButton.setText("Browse...");
+ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(
+ browserButton);
+ browserButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent evt) {
+ FileDialog dialog = new FileDialog(DialogUtils.getShell(),
+ SWT.OPEN);
+
+ String currentFile = uncompressToolTextField.getText();
+ if (currentFile.length() > 0) {
+ File current = new File(currentFile);
+ dialog.setFilterPath(current.getParent());
+ dialog.setFileName(current.getName());
+ }
+ dialog.setText("Select the path of uncompress tool");
+ String pathDirectory = dialog.open();
+ if (pathDirectory != null) {
+ uncompressToolTextField.setText(pathDirectory);
+ validatePage();
+ }
+ }
+ });
+
+ validatePage();
+ }
+
+ /**
+ * Validate the wizard page.
+ */
+ public void validatePage() {
+ String errorMessage = null;
+
+ String uncompressToolPath = uncompressToolTextField.getText().trim();
+ if (uncompressToolPath.equals("")){
+ errorMessage = "You must specify the path of tool to uncompress the Maemo SDK Virtual Image.";
+ } else {
+ File file = new File(uncompressToolPath);
+ if (!file.exists() || file.isDirectory()){
+ errorMessage = "Invalid path for uncompress tool. Please, select a valid directory.";
+ } else {
+ ((NewMaemoSDKVMWizard) getWizard()).getInstallData().setUncompressToolPath(uncompressToolPath);
+ }
+ }
+
+ setErrorMessage(errorMessage);
+ setPageComplete(errorMessage == null);
+ }
+
+
+ public static String getDefault7zPath(){
+ String path = "/usr/bin/7z";
+
+ IMachine machine = MachineRegistry.getInstance().getLocalMachine();
+ IPath defaultPath = MachineUtils.findProgramOnPath(machine, "7z");
+
+ if(defaultPath !=null)
+ return defaultPath.toOSString();
+
+ if (machine.getOS().equals(Platform.OS_WIN32))
+ return "C:/Program Files/7-Zip/7z.exe";
+
+ if (machine.getOS().equals(Platform.OS_LINUX)) {
+ return "/usr/bin/7z";
+ }
+ if (machine.getOS().equals(Platform.OS_MACOSX)) {
+ return "/usr/bin/7z";
+ }
+ return path;
+
+ }
+}
Property changes on: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMUncompressInfoWizardPage.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java 2009-09-09 22:01:56 UTC (rev 2135)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/NewMaemoSDKVMWizard.java 2009-09-09 22:29:39 UTC (rev 2136)
@@ -1,173 +1,166 @@
-/*******************************************************************************
- * Copyright (c) 2009 INdT, (c) 2009 Nokia Corporation
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Raul Herbster (INdT) - initial API and implementation
- *******************************************************************************/
-package org.maemo.esbox.internal.vm.vmware.ui.wizards;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-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.internal.api.common.ui.wizards.WizardWorkProgressPageBase;
-
-/**
- * The Maemo SDK Virtual Image wizard provides an easy method to install SDK
- * Virtual Image for pre-installed VMWare Player/Fusion (download, install and
- * configure latest empty server image for Maemo)
- *
- * @author raulherbster
- *
- */
-public class NewMaemoSDKVMWizard extends Wizard implements INewWizard {
-
- private MaemoSDKVMSelectionWizardPage targetPage;
- private MaemoSDKVMInstallationWorkPage downloadUncompressWorkPage;
- private MaemoSDKVMConfigurationWizardPage configurationPage;
- private MaemoSDKVMUncompressInfoWizardPage uncompressToolPage;
- private MaemoSDKVMLicenseWizardPage licensePage;
- private MaemoSDKVMInstallData installData;
-
- /**
- * Constructor
- */
- public NewMaemoSDKVMWizard() {
- initialize();
- // create an empty install data
- installData = new MaemoSDKVMInstallData();
- }
-
- /**
- * Initialize main information about this wizard.
- */
- private void initialize() {
- setNeedsProgressMonitor(true);
- setWindowTitle("Install Maemo SDK Virtual Machine");
- ImageDescriptor image = Activator.MAEMO_VM_WIZBAN_DESCRIPTOR;
- setDefaultPageImageDescriptor(image);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#addPages()
- */
- public void addPages() {
- targetPage = new MaemoSDKVMSelectionWizardPage(this);
- addPage(targetPage);
- uncompressToolPage = new MaemoSDKVMUncompressInfoWizardPage(this);
- addPage(uncompressToolPage);
- configurationPage = new MaemoSDKVMConfigurationWizardPage(this);
- addPage(configurationPage);
- licensePage = new MaemoSDKVMLicenseWizardPage(this);
- addPage(licensePage);
- downloadUncompressWorkPage = new MaemoSDKVMInstallationWorkPage(this);
- addPage(downloadUncompressWorkPage);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
- * org.eclipse.jface.viewers.IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * Get the work page to show information about installation process.
- *
- * @return the work page of this wizard.
- */
- public WizardWorkProgressPageBase getWorkPage() {
- return downloadUncompressWorkPage;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.wizard.Wizard#performFinish()
- */
- public boolean performFinish() {
- final IStatus status = doWork();
-
- final boolean success = (status.isOK() || status.matches(IStatus.INFO));
-
- 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;
- }
-
- protected IStatus doWork() {
-
- getWorkPage().showAndClearLog();
-
- final IStatus[] statuses = { Policy.getCancelStatus(Activator
- .getDefault()) };
- try {
- getContainer().run(true, true, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
-
- IStatus status = null;
-
- IProgressReporter reporter = getWorkPage().getProgressReporter();
-
- MaemoSDKVMInstaller vmInstaller = new MaemoSDKVMInstaller(installData, reporter);
-
- status = vmInstaller.installVirtualImage(((MaemoSDKVMInstallationWorkPage)getWorkPage()).getTimeout(), getShell(), monitor);
-
- if (status.matches(IStatus.CANCEL))
- status = Activator.createErrorStatus("The Maemo SDK virtual image installation was canceled.", null);
-
- if (status.matches(IStatus.CANCEL) || status.matches(IStatus.ERROR))
- reporter.appendStreamText(status.getMessage(), true);
-
- statuses[0] = status;
- }
-
- });
- } catch (Exception e) {
- Activator.getErrorLogger().logAndShowError(e.getMessage(),
- e.getCause());
- statuses[0] = Activator.createErrorStatus("Maemo SDK virtual image installation failed unexpectedly",
- e);
- }
- return statuses[0];
- }
-
- /**
- * Get the installation data that contains information to install Maemo SDK
- * virtual image.
- *
- * @return the installation data.
- */
- public MaemoSDKVMInstallData getInstallData() {
- return installData;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2009 INdT, (c) 2009 Nokia Corporation
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Raul Herbster (INdT) - initial API and implementation
+ *******************************************************************************/
+package org.maemo.esbox.internal.vm.vmware.ui.wizards;
+
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+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.ui.dialogs.DialogUtils;
+import org.maemo.mica.internal.api.common.ui.wizards.WizardWorkProgressPageBase;
+
+/**
+ * The Maemo SDK Virtual Image wizard provides an easy method to install SDK
+ * Virtual Image for pre-installed VMWare Player/Fusion (download, install and
+ * configure latest empty server image for Maemo)
+ *
+ * @author raulherbster
+ *
+ */
+public class NewMaemoSDKVMWizard extends Wizard implements INewWizard {
+
+ private MaemoSDKVMSelectionWizardPage targetPage;
+ private MaemoSDKVMInstallationWorkPage downloadUncompressWorkPage;
+ private MaemoSDKVMConfigurationWizardPage configurationPage;
+ private MaemoSDKVMUncompressInfoWizardPage uncompressToolPage;
+ private MaemoSDKVMLicenseWizardPage licensePage;
+ private MaemoSDKVMInstallData installData;
+ private int httpTimeout;
+
+ /**
+ * Constructor
+ */
+ public NewMaemoSDKVMWizard() {
+ initialize();
+ // create an empty install data
+ installData = new MaemoSDKVMInstallData();
+ }
+
+ /**
+ * Initialize main information about this wizard.
+ */
+ private void initialize() {
+ setNeedsProgressMonitor(true);
+ setWindowTitle("Install Maemo SDK Virtual Machine");
+ ImageDescriptor image = Activator.MAEMO_VM_WIZBAN_DESCRIPTOR;
+ setDefaultPageImageDescriptor(image);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ public void addPages() {
+ targetPage = new MaemoSDKVMSelectionWizardPage(this);
+ addPage(targetPage);
+ uncompressToolPage = new MaemoSDKVMUncompressInfoWizardPage(this);
+ addPage(uncompressToolPage);
+ configurationPage = new MaemoSDKVMConfigurationWizardPage(this);
+ addPage(configurationPage);
+ licensePage = new MaemoSDKVMLicenseWizardPage(this);
+ addPage(licensePage);
+ downloadUncompressWorkPage = new MaemoSDKVMInstallationWorkPage(this);
+ addPage(downloadUncompressWorkPage);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
+ * org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Get the work page to show information about installation process.
+ *
+ * @return the work page of this wizard.
+ */
+ public WizardWorkProgressPageBase getWorkPage() {
+ 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() {
+ 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));
+
+ 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));
+ }
+ });
+ }
+ });
+
+ return true;
+ }
+
+ /**
+ * Get the installation data that contains information to install Maemo SDK
+ * virtual image.
+ *
+ * @return the installation data.
+ */
+ public MaemoSDKVMInstallData getInstallData() {
+ return installData;
+ }
+
+}
More information about the Esbox-commits
mailing list