[Esbox-commits] r2002 - in branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal: api/vm/vmware vm/vmware/ui/wizards
raul at garage.maemo.org
raul at garage.maemo.org
Wed Aug 26 01:34:20 EEST 2009
Author: raul
Date: 2009-08-26 01:34:18 +0300 (Wed, 26 Aug 2009)
New Revision: 2002
Added:
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java
Modified:
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.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/MaemoSDKVMSelectionWizardPage.java
Log:
Fixing bugs 4433 and 4429
Added: 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 (rev 0)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDescription.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.api.vm.vmware;
+
+/**
+ * @author raulherbster
+ *
+ */
+public class MaemoSDKVMDescription {
+
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+ public static final String SERVER_IMAGE_DESCRIPTION = "This is a virtual disk image usable as a Build Machine in ESbox. This does not have X installed." + LINE_SEPARATOR +
+ "Scratchbox and the Maemo SDK are not installed by default, but the wizard can install these for you.";
+
+ public static final String DESKTOP_IMAGE_DESCRIPTION = "This is a virtual disk image which has X and ESbox installed by default." + LINE_SEPARATOR +
+ "It may also be used as a Build Machine in ESbox, but is intended for standalone usage. Scratchbox and" + LINE_SEPARATOR +
+ "the Maemo SDK are not installed by default, but the wizard can install these for you.";
+
+ private boolean isServerImage;
+
+ private String name;
+
+ private String description;
+
+ /**
+ * Constructor
+ *
+ * @param isServerImage
+ * @param name
+ * @param description
+ */
+ public MaemoSDKVMDescription(boolean isServerImage, String name,
+ String description) {
+ this.isServerImage = isServerImage;
+ this.name = name;
+ this.description = description;
+ }
+
+ public MaemoSDKVMDescription() {
+ this(true,"","");
+ }
+
+ /**
+ * @return the isServerImage
+ */
+ public boolean isServerImage() {
+ return isServerImage;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+
+}
Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-08-24 21:15:02 UTC (rev 2001)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMDownloader.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -77,8 +77,8 @@
URL remoteURL;
int fileSize = 0;
try {
- fileSize = getSizeFor(downloadPage, downloadFile.getDescription());
- remoteURL = getLinkFor(downloadPage, downloadFile.getDescription());
+ fileSize = getSizeFor(downloadPage, downloadFile.getDescriptor().getName());
+ remoteURL = getLinkFor(downloadPage, downloadFile.getDescriptor().getName());
} catch (MalformedURLException e) {
Activator.getErrorLogger().logAndShowError("Invalid file URL", e);
return null;
Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-08-24 21:15:02 UTC (rev 2001)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -34,7 +34,7 @@
}
// main information
- private String description;
+ private MaemoSDKVMDescription descriptor;
private long size;
private long downloaded;
private Status status;
@@ -60,7 +60,7 @@
this.localPathURL = localURL;
size = -1;
downloaded = 0;
- description = "";
+ descriptor = null;
status = Status.DOWNLOADING;
}
@@ -69,18 +69,18 @@
*
* @return the description of this file.
*/
- public String getDescription() {
- return description;
+ public MaemoSDKVMDescription getDescriptor() {
+ return descriptor;
}
/**
* Set the description of this file.
*
- * @param description
+ * @param descriptor
* the new description.
*/
- public void setDescription(String description) {
- this.description = description;
+ public void setDescriptor(MaemoSDKVMDescription descriptor) {
+ this.descriptor = descriptor;
}
/**
@@ -196,7 +196,7 @@
if (obj.getClass() != this.getClass())
return false;
MaemoSDKVMInfo downloadFile = (MaemoSDKVMInfo) obj;
- return description.equals(downloadFile.getDescription());
+ return descriptor.equals(downloadFile.getDescriptor());
}
Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java 2009-08-24 21:15:02 UTC (rev 2001)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMConfigurationWizardPage.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -51,7 +51,7 @@
* parent wizard.
*/
protected MaemoSDKVMConfigurationWizardPage(NewMaemoSDKVMWizard wizard) {
- super("maemovm_postdonwload", "Maemo SDK Virtual Image Downloaded",
+ super("maemovm_postdonwload", "Maemo SDK Virtual Image Configuration",
Activator.MAEMO_VM_WIZBAN_DESCRIPTOR);
setDescription("Select configuration options for Maemo SDK Virtual Image.");
setWizard(wizard);
@@ -71,9 +71,10 @@
GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);
setControl(composite);
- Label message = new Label(composite, SWT.NONE);
- message
- .setText("The virtual image XXX was properly saved on your machine");
+ Label message = new Label(composite, SWT.WRAP);
+ String imageName = ((NewMaemoSDKVMWizard)getWizard()).getInstallData().getFileToDownload().getDescriptor().getName();
+ message.setText("You just selected virtual image ''" + imageName + "'' to be installed on your machine.\n" +
+ " Please, select the following options in order to properly configure your Maemo SDK virtual machine");
GridDataFactory.swtDefaults().span(1, 1).align(SWT.LEFT, SWT.CENTER)
.applyTo(message);
Modified: branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java
===================================================================
--- branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java 2009-08-24 21:15:02 UTC (rev 2001)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -57,7 +57,7 @@
} catch (MalformedURLException e) {
Activator.getErrorLogger().logAndShowError(
"Cannot get location for file "
- + downloadFile.getDescription(), e);
+ + downloadFile.getDescriptor(), e);
}
}
@@ -103,7 +103,7 @@
} catch (MalformedURLException e) {
Activator.getErrorLogger().logAndShowError(
"Cannot get location for file "
- + fileToDownload.getDescription(), e);
+ + fileToDownload.getDescriptor(), e);
}
}
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-24 21:15:02 UTC (rev 2001)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallerContentLabelProvider.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -20,6 +20,7 @@
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;
@@ -72,10 +73,10 @@
* and adding them to contents.
*/
protected void doFetchScripts() {
- List<String> virtualImagesNames = fetchVMNamesFromUrl("http://tablets-dev.nokia.com/maemo-dev-env-downloads.php");
- for (String name : virtualImagesNames) {
+ List<MaemoSDKVMDescription> virtualImagesNames = fetchVMNamesFromUrl("http://tablets-dev.nokia.com/maemo-dev-env-downloads.php");
+ for (MaemoSDKVMDescription maemoSDKVM : virtualImagesNames) {
MaemoSDKVMInfo downloadFile = new MaemoSDKVMInfo();
- downloadFile.setDescription(name);
+ downloadFile.setDescriptor(maemoSDKVM);
if (!contents.contains(downloadFile))
contents.add(downloadFile);
else {
@@ -95,7 +96,7 @@
* available Maemo SDK virtual images.
* @return a list with the names of available Maemo SDK virtual images.
*/
- protected List<String> fetchVMNamesFromUrl(String urlString) {
+ protected List<MaemoSDKVMDescription> fetchVMNamesFromUrl(String urlString) {
URL url;
try {
url = new URL(urlString);
@@ -105,7 +106,7 @@
return Collections.emptyList();
}
- List<String> virtualImagesNames = new ArrayList<String>();
+ List<MaemoSDKVMDescription> virtualImagesDescriptors = new ArrayList<MaemoSDKVMDescription>();
try {
URLConnection connection = url.openConnection();
@@ -130,18 +131,20 @@
while (matcher.find()) {
String virtualImageName = matcher.group(0);
virtualImageName = processVirtualImageName(virtualImageName);
- virtualImagesNames.add(virtualImageName);
+ boolean isServer = virtualImageName.toLowerCase().contains("server");
+ String virtualImageDescription = isServer ? MaemoSDKVMDescription.SERVER_IMAGE_DESCRIPTION : MaemoSDKVMDescription.DESKTOP_IMAGE_DESCRIPTION;
+ virtualImagesDescriptors.add(new MaemoSDKVMDescription(isServer,virtualImageName,virtualImageDescription));
}
} catch (Exception e) {
if (e instanceof InterruptedException)
- return virtualImagesNames;
+ return virtualImagesDescriptors;
if (!isInterrupted())
Activator.getErrorLogger().logAndShowError(
"Could not fetch listing from " + url, e);
}
- return virtualImagesNames;
+ return virtualImagesDescriptors;
}
/**
@@ -228,7 +231,7 @@
if (element instanceof MaemoSDKVMInfo) {
MaemoSDKVMInfo data = (MaemoSDKVMInfo) element;
if (column == 0)
- return data.getDescription();
+ return data.getDescriptor().getName();
}
return "";
}
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-24 21:15:02 UTC (rev 2001)
+++ branches/work_Raul/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMSelectionWizardPage.java 2009-08-25 22:34:18 UTC (rev 2002)
@@ -29,14 +29,18 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
+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.common.core.machine.MachineRegistry;
import org.maemo.mica.common.ui.NetworkSettingsUI;
import org.maemo.mica.common.ui.dialogs.DialogUtils;
@@ -52,9 +56,10 @@
private static final MaemoSDKVMInfo latestVMInstallData = getLatestVMInstallFile();
private static MaemoSDKVMInfo getLatestVMInstallFile() {
+ MaemoSDKVMDescription descriptor = new MaemoSDKVMDescription(true,
+ "Maemo Diablo SDK Virtual Image with Ubuntu Intrepid Server",MaemoSDKVMDescription.SERVER_IMAGE_DESCRIPTION);
MaemoSDKVMInfo downloadFile = new MaemoSDKVMInfo();
- downloadFile
- .setDescription("Maemo Diablo SDK Virtual Image with Ubuntu Intrepid Server");
+ downloadFile.setDescriptor(descriptor);
return downloadFile;
}
@@ -70,7 +75,13 @@
private Button advancedButton;
private Composite advancedContent;
private Text existingVirtualImageTextField;
-
+
+ // listener for changes on text fields
+ private Listener textFieldsValidator;
+
+ // text area for description
+ private Text imageDescription;
+
/**
* Constructor.
*
@@ -80,11 +91,11 @@
protected MaemoSDKVMSelectionWizardPage(NewMaemoSDKVMWizard wizard) {
super("maemovm_selection", "Select Maemo SDK Virtual Image",
Activator.MAEMO_VM_WIZBAN_DESCRIPTOR);
- setDescription("Select the Maemo SDK Virtual Image you want to install.");
- setPageComplete(false);
+ setDescription("A virtual image is a disk image with an installation of Linux/x86 " +
+ "capable of hosting Scratchbox and the Maemo SDK.");
setWizard(wizard);
- // set latest maemo SDK VM
- wizard.getInstallData().setFileToDownload(latestVMInstallData);
+
+ textFieldsValidator = createTextFieldValidatorListener();
}
/*
@@ -102,15 +113,21 @@
createVirtualImagesSelector(composite);
+ createDescriptionContent(composite);
+
createOptionsContent(composite);
createAdvancedContent(composite);
+
+ setInitialValues();
virtualImagesTable.setInput(new Object[0]);
for (TableColumn column : virtualImagesTable.getTable().getColumns()) {
column.pack();
}
+
+ validatePage();
}
/**
@@ -130,10 +147,11 @@
.applyTo(link);
downloadLatest = createButton(composite, SWT.CHECK ,
- "Download latest empty server image for Maemo");
- downloadLatest.setSelection(true);
+ "Download latest Maemo SDK server image");
GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).span(4, 1)
.applyTo(downloadLatest);
+ downloadLatest.setToolTipText("Selects the latest tested virtual disk image for use as a " +
+ "Build Machine in ESbox. This does not have X installed.");
downloadLatest.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -146,9 +164,8 @@
});
virtualImagesTable = new TableViewer(composite, SWT.BORDER | SWT.SCROLL_PAGE);
- virtualImagesTable
- .addSelectionChangedListener(new ISelectionChangedListener() {
-
+ virtualImagesTable.addSelectionChangedListener(new ISelectionChangedListener() {
+
public void selectionChanged(SelectionChangedEvent event) {
Object element = ((IStructuredSelection) event
.getSelection()).getFirstElement();
@@ -201,23 +218,26 @@
* parent composite.
*/
public void createOptionsContent(Composite composite) {
+ Label separator = new Label(composite, SWT.NONE);
+ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).span(4, 1)
+ .applyTo(separator);
+
usePreviousDownloadButton = createButton(composite, SWT.CHECK,
"Use previous download");
GridDataFactory.swtDefaults().span(4, 1).align(SWT.LEFT, SWT.CENTER)
.applyTo(usePreviousDownloadButton);
usePreviousDownloadButton
- .setToolTipText("If checked, continue from a previous download of the virtual image if possible, else, always download.");
+ .setToolTipText("If checked, continue from a previous download of the virtual image if possible; otherwise, always download.");
usePreviousDownloadButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
- boolean usePreviousDownload = usePreviousDownloadButton
- .getSelection();
+ boolean usePreviousDownload = usePreviousDownloadButton.getSelection();
downloadLatest.setEnabled(!usePreviousDownload);
- virtualImagesTable.getTable().setEnabled(
- !usePreviousDownload && !downloadLatest.getSelection());
- advancedButton.setEnabled(usePreviousDownload);
+ virtualImagesTable.getTable().setEnabled(!usePreviousDownload && !downloadLatest.getSelection());
+ setAdvancedAreaEnablement(usePreviousDownload);
((NewMaemoSDKVMWizard) getWizard()).getInstallData()
.setUsePreviousInstallation(usePreviousDownload);
+ validatePage();
}
});
@@ -228,10 +248,12 @@
.applyTo(label);
destinationTextField = new Text(composite, SWT.BORDER);
- destinationTextField
- .setToolTipText("Specify the location of Maemo SDK Virtual Image.");
+ destinationTextField.setToolTipText("Specify the location of Maemo SDK Virtual Image.");
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(
destinationTextField);
+ destinationTextField.addListener(SWT.SELECTED, textFieldsValidator);
+ destinationTextField.addListener(SWT.KeyDown, textFieldsValidator);
+ destinationTextField.addListener(SWT.KeyUp, textFieldsValidator);
Button browserButton = createButton(composite, SWT.PUSH ,
"Browse...");
@@ -240,10 +262,8 @@
browserButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent evt) {
- DirectoryDialog dialog = new DirectoryDialog(DialogUtils
- .getShell(), SWT.OPEN);
- dialog
- .setText("Select the directory to save the Maemo SDK Virtual Image");
+ DirectoryDialog dialog = new DirectoryDialog(DialogUtils.getShell(), SWT.OPEN);
+ dialog.setText("Select the directory to save the Maemo SDK virtual image");
String pathDirectory = dialog.open();
if (pathDirectory != null) {
destinationTextField.setText(pathDirectory);
@@ -288,7 +308,11 @@
.setToolTipText("Specify the location of existing compressed Maemo SDK Virtual Image.");
GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(
existingVirtualImageTextField);
-
+ existingVirtualImageTextField.addListener(SWT.SELECTED, textFieldsValidator);
+ existingVirtualImageTextField.addListener(SWT.KeyDown, textFieldsValidator);
+ existingVirtualImageTextField.addListener(SWT.KeyUp, textFieldsValidator);
+
+
Button browserButton = createButton(advancedContent, SWT.PUSH, "Browse...");
GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).applyTo(
browserButton);
@@ -298,8 +322,7 @@
FileDialog dialog = new FileDialog(DialogUtils.getShell(),
SWT.OPEN);
dialog.setFilterExtensions(new String[] { "*.zip" });
- dialog
- .setText("Select the location of compressed virtual image");
+ dialog.setText("Select the location of compressed virtual image");
String pathDirectory = dialog.open();
if (pathDirectory != null) {
existingVirtualImageTextField.setText(pathDirectory);
@@ -322,48 +345,86 @@
}
});
}
+
+ private void createDescriptionContent(Composite composite) {
+ Label label = new Label(composite, SWT.NONE);
+ label.setText("Description: ");
+ GridDataFactory.swtDefaults().align(SWT.LEFT, SWT.CENTER).span(4, 1)
+ .applyTo(label);
+
+ imageDescription = new Text(composite,SWT.BORDER | SWT.MULTI | SWT.WRAP);
+ imageDescription.setEditable(false);
+ GridDataFactory.fillDefaults().grab(true, true).span(4, 1).applyTo(
+ imageDescription);
+ }
+
+ private void setInitialValues() {
+ downloadLatest.setSelection(true);
+ usePreviousDownloadButton.setSelection(false);
+ destinationTextField.setText(MachineRegistry.getInstance().getLocalMachine().getUserHome().toString());
+ existingVirtualImageTextField.setText("");
+
+ // set latest maemo SDK VM
+ doChangeVMChoice(latestVMInstallData);
+ }
/**
* Validate information of the wizard page, so we can check if it is
* possible to proceed or not.
*/
private void validatePage() {
- String imageLocation = destinationTextField.getText();
String errorMessage = null;
- errorMessage = validatePathLocation(imageLocation);
if (!downloadLatest.getSelection()
&& virtualImagesTable.getSelection().isEmpty()
&& !usePreviousDownloadButton.getSelection()) {
- errorMessage = "Select a virtual image to be installed on your host machine";
+ errorMessage = "Select a Maemo SDK virtual image to be installed on your host machine";
}
- if (usePreviousDownloadButton.getSelection()) {
- String existingVirtualImageLocation = existingVirtualImageTextField
- .getText().trim();
- errorMessage = validatePathLocation(existingVirtualImageLocation);
- }
- setErrorMessage(errorMessage);
- setPageComplete(errorMessage == null);
+
+ if (errorMessage == null) {
+ validateTextFields();
+ } else {
+ setErrorMessage(errorMessage);
+ setPageComplete(false);
+ }
+
}
/**
- * Check if the given path is valid.
- *
- * @param path
- * @return
+ * Validate text fields of Maemo SDK selection wizard page.
+ * It checks if destination of Maemo SDK VM is properly defined; if location of existing Maemo SDK VM really
+ * exists.
*/
- private String validatePathLocation(String path) {
+ private void validateTextFields() {
String errorMessage = null;
- if (path.trim().equals("")) {
- errorMessage = "Please, insert a valid location.";
+
+ String destination = destinationTextField.getText().trim();
+ if (destination.equals("")){
+ errorMessage = "You must specify the destination of Maemo SDK virtual image";
} else {
- File imageLocationPath = new File(path);
- if (!imageLocationPath.exists())
- errorMessage = "The path inserted " + path
- + " does not exist. Please, insert a valid location.";
+ File file = new File(destination);
+ if (!file.exists() || !file.isDirectory()){
+ errorMessage = "Invalid location for Maemo SDK virtual image. Please, select a valid directory.";
+ }
}
- return errorMessage;
+
+ String existingVirtualImageLocation = "";
+ if (errorMessage == null && usePreviousDownloadButton.getSelection()) {
+ existingVirtualImageLocation = existingVirtualImageTextField.getText().trim();
+ if (existingVirtualImageLocation.equals("")){
+ errorMessage = "You must specify the location of an existing Maemo SDK virtual image";
+ } else {
+ File file = new File(existingVirtualImageLocation);
+ if (!file.exists() || file.isDirectory()){
+ errorMessage = "Invalid Maemo SDK virtual image. You must select a zipped file that contains Maemo SDK virtual image.";
+ }
+ }
+ }
+
+ setErrorMessage(errorMessage);
+ setPageComplete(errorMessage == null);
}
-
+
+
/**
* Utility method to create button.
*
@@ -388,6 +449,8 @@
installData.setFileToDownload(data);
String localURL = destinationTextField.getText();
setDownloadFileLocalURL(localURL);
+
+ imageDescription.setText(data.getDescriptor().getDescription());
}
}
@@ -409,4 +472,18 @@
getShell().pack();
}
+
+ private void setAdvancedAreaEnablement(boolean isEnabled) {
+ advancedButton.setEnabled(isEnabled);
+ existingVirtualImageTextField.setEnabled(isEnabled);
+ }
+
+ protected Listener createTextFieldValidatorListener(){
+ return new Listener() {
+ public void handleEvent(Event event) {
+ validateTextFields();
+ }
+ };
+ }
+
}
More information about the Esbox-commits
mailing list