[Esbox-commits] r2199 - in trunk: org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/api/scratchbox/core org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/scratchbox/core/sbrsh org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests org.maemo.esbox.tests org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm org.maemo.esbox.vm/src/org/maemo/esbox/vm/core org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox 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 org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards
eswartz at garage.maemo.org
eswartz at garage.maemo.org
Fri Sep 18 21:55:37 EEST 2009
Author: eswartz
Date: 2009-09-18 21:55:31 +0300 (Fri, 18 Sep 2009)
New Revision: 2199
Added:
trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java
Modified:
trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java
trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java
trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/api/scratchbox/core/OldStyleProjectProperties.java
trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/scratchbox/core/sbrsh/SBRSHPreferenceConstants.java
trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java
trunk/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java
trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1ProcessLauncher.java
trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1SDKProvider.java
trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2ProcessLauncher.java
trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2SDKProvider.java
trunk/org.maemo.esbox.tests/asthelper.completions
trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachine.java
trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java
trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java
trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuSettingsPreferencePage.java
trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachine.java
trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java
trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java
trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxSettingsPreferencePage.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/vm/vmware/VMwareMachine.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareUtils.java
trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/BaseVirtualMachinePreferencePage.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachine.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java
trunk/org.maemo.esbox.vm/src/org/maemo/esbox/vm/core/IVirtualMachine.java
Log:
Merge revs 2188:2198 from work_Ed branch
Copied: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java (from rev 2198, branches/work_Ed/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java)
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java (rev 0)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BaseMachinePreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (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:
+ * Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.maemosdk.ui.preferences;
+
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.ui.preferences.ComposedPreferencePage;
+
+/**
+ * @author eswartz
+ *
+ */
+public abstract class BaseMachinePreferencePage extends ComposedPreferencePage {
+
+ /**
+ * @param style
+ */
+ public BaseMachinePreferencePage(int style) {
+ super(style);
+ }
+
+ /**
+ * Recreate the machine from the current unsaved preferences
+ * @return new {@link IMachine}
+ */
+ public abstract IMachine createMachine();
+
+}
\ No newline at end of file
Modified: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/BuildMachinePreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -85,6 +85,9 @@
protected Map<String, IBuildMachine> machineMap;
private Label noMachineConfigUI;
private Button applyAndValidateButton;
+
+ private IComposablePreferencePage selectedMachinePage;
+ private IMachine lastValidatedMachine;
/**
*
@@ -272,11 +275,14 @@
}
machineConfigStackLayout.topControl = page.getControl();
selectedMachine = machine;
+ selectedMachinePage = page;
// wait a step since field editors on other pages
// will clear the message when they lose focus
Display.getDefault().asyncExec(new Runnable() {
public void run() {
+ setErrorMessage(null);
+ setMessage(null, INFORMATION);
page.revalidate();
updateApplyButton();
}
@@ -284,6 +290,7 @@
} else {
machineConfigStackLayout.topControl = noMachineConfigUI;
selectedMachine = null;
+ selectedMachinePage = null;
setErrorMessage(null);
setMessage(null, INFORMATION);
setValid(true);
@@ -366,9 +373,9 @@
if (changed) {
// changes in settings mean the machine should be relaunched
- shutDownMachines();
+ shutDownMachinesBeforeSwitchingTo(selectedMachine);
- // reset the build machines, since they were initialized from other prefs
+ // reset the build machines, since they were initialized from internal prefs
MachineRegistry.getInstance().refreshBuildMachines();
// these objects refer to the old values, so we compare them to detect a change,
@@ -380,6 +387,7 @@
newMachine = MachineRegistry.getInstance().setCurrentBuildMachine(newMachine.getName());
else
newMachine = MachineRegistry.getInstance().setCurrentBuildMachine(newMachine);
+
selectedMachine = newMachine;
}
} finally {
@@ -388,7 +396,9 @@
}
if (selectedMachine != null && !MachineManager.getInstance().isActive(selectedMachine)) {
- MachineManager.getInstance().scheduleAcquireMachine(selectedMachine);
+ //MachineManager.getInstance().scheduleAcquireMachine(selectedMachine);
+ // need to properly time the SDK refresh to use the new machine, so do this first
+ SDKManagerInternal.getInstance().refresh(true);
}
}
@@ -412,16 +422,16 @@
/**
*
*/
- protected boolean shutDownMachines() {
+ protected boolean shutDownMachinesBeforeSwitchingTo(IMachine selectedMachine) {
// shut down other VMs first
boolean vmRunning = false;
IMachine current = null;
- final IMachine[] currentMachines = MachineRegistry.getInstance().getCurrentBuildMachines();
+ IMachine[] currentMachines_ = MachineRegistry.getInstance().getCurrentBuildMachines();
- for (int i = 0; i < currentMachines.length; i++) {
- IMachine machine = currentMachines[i];
+ for (int i = 0; i < currentMachines_.length; i++) {
+ IMachine machine = currentMachines_[i];
if (machine instanceof ILocalMachine) {
- currentMachines[i] = null; // don't dare shut this down
+ currentMachines_[i] = null; // don't dare shut this down
continue;
}
@@ -430,8 +440,21 @@
current = machine;
}
}
+
+ if (lastValidatedMachine != null && current == null) {
+ if (MachineManager.getInstance().isActive(lastValidatedMachine)) {
+ vmRunning = true;
+ current = lastValidatedMachine;
+ currentMachines_ = new IMachine[] { current };
+ }
+ }
- if (vmRunning && selectedMachine != null) {
+ // a local machine is NOT a VM and should not be shut down
+ if (selectedMachine instanceof ILocalMachine)
+ vmRunning = false;
+
+ if (vmRunning && selectedMachine != null && !current.equals(selectedMachine)) {
+ final IMachine[] currentMachines = currentMachines_;
boolean doit;
String message;
if (selectedMachine.getName().equals(current.getName())) {
@@ -465,6 +488,7 @@
for (IMachine machine : currentMachines) {
if (machine == null)
continue;
+ monitor.setTaskName("Shutting down " + machine.getName());
MachineManager.getInstance().releaseMachine(machine, new SubProgressMonitor(monitor, 1));
if (monitor.isCanceled())
break;
@@ -536,32 +560,18 @@
@Override
protected void contributeButtons(Composite parent) {
applyAndValidateButton = new Button(parent, SWT.PUSH);
- applyAndValidateButton.setText("Apply and &Validate Machine");
+ applyAndValidateButton.setText("&Validate Machine");
applyAndValidateButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent ev) {
- performApply();
-
if (selectedMachine != null) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
- StyledTextProgressDialog dialog = new StyledTextProgressDialog(
- getShell(),
- "Virtual Machine Validation");
-
- dialog.open();
-
- ValidateMachineRunner runner = new ValidateMachineRunner(
- dialog.getProgressReporter(),
- selectedMachine);
- try {
- dialog.run(true, true, runner);
- } catch (Exception e) {
- UIActivator.getErrorLogger().logAndShowError("Unexpected exception running tests", e);
- }
+ validateMachine();
}
+
});
}
@@ -571,4 +581,35 @@
((GridLayout) parent.getLayout()).numColumns++;
}
+ /**
+ * Run the machine validation. This is called on the UI thread.
+ */
+ protected void validateMachine() {
+
+ StyledTextProgressDialog dialog = new StyledTextProgressDialog(
+ getShell(),
+ "Virtual Machine Validation");
+
+ dialog.open();
+
+ IMachine machineToValidate = selectedMachinePage instanceof BaseMachinePreferencePage ?
+ ((BaseMachinePreferencePage) selectedMachinePage).createMachine() :
+ selectedMachine;
+
+ shutDownMachinesBeforeSwitchingTo(machineToValidate);
+
+ ValidateMachineRunner runner = new ValidateMachineRunner(
+ dialog.getProgressReporter(),
+ machineToValidate);
+ try {
+ dialog.run(true, true, runner);
+ } catch (InterruptedException e) {
+ // ignore
+ } catch (Exception e) {
+ UIActivator.getErrorLogger().logAndShowError("Unexpected exception running tests", e);
+ }
+
+ lastValidatedMachine = machineToValidate;
+ }
+
}
Modified: trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java
===================================================================
--- trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.maemosdk.ui/src/org/maemo/esbox/internal/api/maemosdk/ui/preferences/ValidateMachineRunner.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -16,7 +16,6 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
@@ -30,7 +29,6 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Shell;
import org.maemo.esbox.internal.maemosdk.ui.UIActivator;
@@ -47,11 +45,11 @@
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.sdk.ISDK;
import org.maemo.mica.common.core.sdk.ISDKTarget;
-import org.maemo.mica.common.core.sdk.SDKManager;
import org.maemo.mica.common.core.ui.IProgressReporter;
import org.maemo.mica.common.core.ui.ProgressReporterStreamTextMonitor;
-import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
+import org.maemo.mica.internal.api.common.core.sdk.RefreshSDKManagerJob;
/**
* This class validates that a machine is properly configured.
@@ -370,33 +368,10 @@
monitor.beginTask("", 2);
step(monitor, "Testing visibility of shared folders in installed targets");
- SDKManager.getInstance().waitForRefreshComplete(new SubProgressMonitor(monitor, 1));
- ISDKTarget[] sdkTargets = getMachineProvidedTargets();
+ ISDKTarget[] sdkTargets = getMachineProvidedTargets(new SubProgressMonitor(monitor, 1));
-
if (sdkTargets.length == 0) {
- info("Did not find any installed targets in build machine.\n\nRetrying ...");
-
- ProgressMonitorDialog dlg2 = new ProgressMonitorDialog(shell);
- try {
- dlg2.run(false, true, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- SDKManagerInternal.getInstance().refreshFull(monitor);
- }
-
- });
- } catch (Exception e) {
- fail("Failed to refresh installed targets:\n{0}", e.getMessage());
- return false;
- }
-
- sdkTargets = getMachineProvidedTargets();
- if (sdkTargets.length == 0) {
- fail("Failed to find any installed targets in this machine... it is probably misconfigured or broken.");
- return false;
- }
+ info("Did not find any installed targets in build machine.");
}
// make sure we can see the shared folder in the target if it maps there
@@ -423,14 +398,16 @@
/**
* Get the SDK targets that are purported to be available from the machine.
+ * @param monitor
* @return non-<code>null</code> array
*/
- private ISDKTarget[] getMachineProvidedTargets() {
- List<ISDKTarget> sdktargetsList = new ArrayList<ISDKTarget>(Arrays.asList(
- SDKManager.getInstance().getAllSDKTargets()));
- for (Iterator<ISDKTarget> iter = sdktargetsList.iterator(); iter.hasNext(); ) {
- if (!iter.next().getSDK().getMachine().equals(machine))
- iter.remove();
+ private ISDKTarget[] getMachineProvidedTargets(IProgressMonitor monitor) {
+ RefreshSDKManagerJob job = new RefreshSDKManagerJob(machine, true);
+ job.run(monitor);
+
+ List<ISDKTarget> sdktargetsList = new ArrayList<ISDKTarget>();
+ for (ISDK sdk : job.getSDKs()) {
+ sdktargetsList.addAll(Arrays.asList(sdk.getSDKTargets()));
}
return (ISDKTarget[]) sdktargetsList.toArray(new ISDKTarget[sdktargetsList
.size()]);
Modified: trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/api/scratchbox/core/OldStyleProjectProperties.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/api/scratchbox/core/OldStyleProjectProperties.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/internal/api/scratchbox/core/OldStyleProjectProperties.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -60,11 +60,6 @@
this.project = project;
}
- /*
- * (non-Javadoc)
- *
- * @see org.maemo.esbox.common.core.IPropertyAccess#read(java.lang.String)
- */
private String readProperty(QualifiedName property) {
try {
return project.getPersistentProperty(property);
@@ -75,12 +70,7 @@
}
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.maemo.esbox.common.project.core.IProjectProperties#getExecutionEnvironment()
- */
+ @Override
public IExecutionEnvironment getExecutionEnvironment() {
IExecutionEnvironment execEnv = null;
String execEnvId = readProperty(executionEnvironmentProperty);
@@ -92,42 +82,27 @@
return execEnv;
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.maemo.esbox.common.project.core.IProjectProperties#getExecutionEnvironmentId
- * ()
- */
+ @Override
public String getExecutionEnvironmentId() {
return readProperty(executionEnvironmentProperty);
}
- /**
- * Get the SDK target (SDK + target name) for the project's configured SDK
- *
- * @return SDK target, never <code>null</code>
- * @throws MicaException
- * if no target known
- */
+ @Override
public ISDKTarget getSDKTarget() {
if (!project.isOpen())
return null;
ISDK sdk = getSDK();
+ if (sdk == null)
+ return null;
+
String targetName = getSDKTargetName();
ISDKTarget target = sdk.findSDKTarget(targetName);
return target;
}
- /**
- * Get the SDK for the project
- *
- * @return SDK, never <code>null</code>
- * @throws MicaException
- * if no SDK known
- */
+ @Override
public ISDK getSDK() {
ISDK sdk = null;
@@ -151,10 +126,12 @@
return sdk;
}
+ @Override
public synchronized String getSDKTargetName() {
return readProperty(targetNameProperty);
}
+ @Override
public synchronized String getSDKName() {
String sboxVersion = readProperty(scratchboxVersionProperty);
@@ -170,9 +147,6 @@
return null;
}
- /* (non-Javadoc)
- * @see org.maemo.mica.internal.api.common.project.core.model.AbstractBuildConfiguration#save(org.maemo.mica.internal.api.common.project.core.IPersistentPropertyAccess)
- */
@Override
public void save(IPersistentPropertyAccess access) throws CoreException {
throw newCoreException("This is a read-only configuration");
Modified: trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/scratchbox/core/sbrsh/SBRSHPreferenceConstants.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/scratchbox/core/sbrsh/SBRSHPreferenceConstants.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.core/src/org/maemo/esbox/scratchbox/core/sbrsh/SBRSHPreferenceConstants.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -24,6 +24,6 @@
/** Get the preference store that contains these preferences */
public static IPreferenceStore getPreferenceStore() {
return Activator.getDefault().getPreferenceStore();
- }
+ }
}
Modified: trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -497,6 +497,9 @@
}
} catch (ScratchboxException e2) {
+ if (e2.getMessage().contains("not properly set up"))
+ return;
+
// sb-conf killall can fail in the event there is some
// process with a space in its
// name... or if no targets exist yet; just log it and keep going
@@ -975,7 +978,11 @@
public void forceShutdown(IProgressMonitor monitor) throws MicaException {
monitor.beginTask("", 2);
- killSessions();
+ try {
+ killSessions();
+ } catch (MicaException e) {
+ // this is okay; it might not even have been started
+ }
monitor.worked(1);
if (monitor.isCanceled())
return;
Modified: trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/provider/Scratchbox1SDKProvider.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -12,8 +12,6 @@
package org.maemo.esbox.internal.scratchbox.sb1.provider;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.core.filesystem.IFileStore;
@@ -30,7 +28,6 @@
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.machine.IBuildMachine;
import org.maemo.mica.common.core.machine.IMachine;
-import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.preferences.CorePreferenceManager;
import org.maemo.mica.common.core.preferences.IPreferenceProvider;
import org.maemo.mica.common.core.sdk.ISDK;
@@ -66,36 +63,24 @@
*
* @see org.maemo.mica.common.core.sdk.ISDKProvider#createSDKs()
*/
- public List<ISDK> createSDKs(IProgressMonitor monitor) throws MicaException {
+ public List<ISDK> createSDKs(IMachine machine, IProgressMonitor monitor) throws MicaException {
if (monitor == null)
monitor = new NullProgressMonitor();
List<ISDK> sdks = new ArrayList<ISDK>();
- IBuildMachine[] buildMachines = MachineRegistry.getInstance().getBuildMachines();
- if (monitor.isCanceled())
+
+ if (!(machine instanceof IBuildMachine))
return sdks;
- monitor.beginTask("", buildMachines.length);
+ monitor.beginTask("", 1);
monitor.subTask("Scanning Scratchbox 1 installations");
- for (IMachine machine : buildMachines) {
- IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
- CorePreferenceManager.getInstance()
- .getPreferenceProvider(), machine);
- getMachineSDKs(prefProvider, machine, sdks,
- new SubProgressMonitor(monitor, 1));
- if (monitor.isCanceled())
- break;
- }
+ IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
+ CorePreferenceManager.getInstance()
+ .getPreferenceProvider(), machine);
+ getMachineSDKs(prefProvider, machine, sdks,
+ new SubProgressMonitor(monitor, 1));
- Collections.sort(sdks, new Comparator<ISDK>() {
-
- public int compare(ISDK o1, ISDK o2) {
- return o1.getName().compareTo(o2.getName());
- }
-
- });
-
return sdks;
}
@@ -107,15 +92,6 @@
private void getMachineSDKs(IPreferenceProvider prefProvider,
IMachine machine, List<ISDK> sdks, IProgressMonitor monitor) {
- if (!machine.isAlive())
- return;
-
- /*
- MachineUtils.acquireMachine(machine, new SubProgressMonitor(monitor, 9));
- if (monitor.isCanceled())
- return;
- */
-
String[] paths = prefProvider.getPreferenceValue(SB1PreferenceConstants.SB1_ROOTS).split(":");
monitor.beginTask("", paths.length);
Modified: trunk/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.sb2/src/org/maemo/esbox/internal/scratchbox/sb2/provider/Scratchbox2SDKProvider.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -12,8 +12,6 @@
package org.maemo.esbox.internal.scratchbox.sb2.provider;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import org.eclipse.core.filesystem.IFileStore;
@@ -32,8 +30,6 @@
import org.maemo.mica.common.core.filesystem.IFileSystemAccess;
import org.maemo.mica.common.core.machine.IBuildMachine;
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.preferences.CorePreferenceManager;
import org.maemo.mica.common.core.preferences.IPreferenceProvider;
import org.maemo.mica.common.core.sdk.ISDK;
@@ -71,57 +67,35 @@
*
* @see org.maemo.mica.common.core.sdk.ISDKProvider#createSDKs()
*/
- public List<ISDK> createSDKs(IProgressMonitor monitor) throws MicaException {
+ public List<ISDK> createSDKs(IMachine machine, IProgressMonitor monitor) throws MicaException {
if (monitor == null)
monitor = new NullProgressMonitor();
ErrorLogger logger = Activator.getErrorLogger();
List<ISDK> sdks = new ArrayList<ISDK>();
- IBuildMachine[] buildMachines = MachineRegistry.getInstance()
- .getBuildMachines();
-
- if (monitor.isCanceled())
+
+ if (!(machine instanceof IBuildMachine))
return sdks;
-
- monitor.beginTask("", buildMachines.length);
+
+ monitor.beginTask("", 1);
monitor.subTask("Scanning Scratchbox 2 installations");
- for (IMachine machine : buildMachines) {
- if (!machine.isAlive())
- continue;
-
- /*
- MachineUtils.acquireMachine(machine, new SubProgressMonitor(monitor, 9));
- if (monitor.isCanceled())
- return;
- */
-
-
- try {
- IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
- CorePreferenceManager.getInstance()
- .getPreferenceProvider(), machine);
- Scratchbox2SDK sdk = getMachineSDK(prefProvider, machine,
- new SubProgressMonitor(monitor, 1));
-
- if (sdk != null) {
- sdks.add(sdk);
- sdk.init();
- }
- } catch (ScratchboxException e) {
- logger.log(IStatus.INFO,
- "Problem scanning Scratchbox 2 installation", e);
+ try {
+ IPreferenceProvider prefProvider = new UserAwarePreferenceProviderWrapper(
+ CorePreferenceManager.getInstance()
+ .getPreferenceProvider(), machine);
+ Scratchbox2SDK sdk = getMachineSDK(prefProvider, machine,
+ new SubProgressMonitor(monitor, 1));
+
+ if (sdk != null) {
+ sdks.add(sdk);
+ sdk.init();
}
+ } catch (ScratchboxException e) {
+ logger.log(IStatus.INFO,
+ "Problem scanning Scratchbox 2 installation", e);
}
-
- Collections.sort(sdks, new Comparator<ISDK>() {
-
- public int compare(ISDK o1, ISDK o2) {
- return o1.getName().compareTo(o2.getName());
- }
-
- });
return sdks;
}
@@ -148,10 +122,6 @@
installRoot, prefProvider);
// see if the right programs seem to exist
- MachineUtils.acquireMachine(machine, new SubProgressMonitor(monitor, 8));
- if (monitor.isCanceled())
- return null;
-
IFileSystemAccess fileSystemAccess = machine.getFileSystemAccess();
IFileStore sb2 = fileSystemAccess.getFileStore(installRoot.append("sb2"));
IFileStore sb2config = fileSystemAccess.getFileStore(installRoot.append("sb2-config"));
@@ -164,8 +134,9 @@
sb2ConfigExists = false;
}
if (!sb2Exists || !sb2ConfigExists) {
- Activator.getErrorLogger().log(IStatus.WARNING,
- "Ignoring Scratchbox 2 installation at " + installRoot + " (sb2 or sb2-config does not exist)", null);
+ // don't litter Error Log with this
+ //Activator.getErrorLogger().log(IStatus.WARNING,
+ // "Ignoring Scratchbox 2 installation at " + installRoot + " (sb2 or sb2-config does not exist)", null);
return null;
}
Modified: trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1ProcessLauncher.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1ProcessLauncher.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1ProcessLauncher.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -22,6 +22,8 @@
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.env.EnvironmentModifierBlock;
import org.maemo.mica.common.core.env.IEnvironmentModifierBlock;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.process.AbstractProcessLauncher;
import org.maemo.mica.common.core.process.CommandLineArguments;
import org.maemo.mica.common.core.process.IProcessLauncher;
@@ -47,11 +49,18 @@
*/
public class TestSB1ProcessLauncher extends TestProcessLauncher {
ISDKProvider sb1Provider;
+ private IMachine machine;
private static List<ISDK> sdks;
@Override
protected void setUp() throws Exception {
super.setUp();
+
+ for (IMachine machine : MachineRegistry.getInstance().getBuildMachines()) {
+ this.machine = machine;
+ break;
+ }
+
SDKManager factory = SDKManagerInternal.getInstance();
factory.waitForRefreshComplete(null);
@@ -81,7 +90,7 @@
if (sb1Provider == null)
sdks = Collections.EMPTY_LIST;
else
- sdks = sb1Provider.createSDKs(null);
+ sdks = sb1Provider.createSDKs(machine, null);
}
SDKManager.getInstance().waitForRefreshComplete(null);
return sdks;
Modified: trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1SDKProvider.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1SDKProvider.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB1SDKProvider.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -27,6 +27,8 @@
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.filesystem.IMountPoint;
import org.maemo.mica.common.core.machine.ILocalMachine;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.preferences.CorePreferenceManager;
import org.maemo.mica.common.core.sdk.ISDK;
import org.maemo.mica.common.core.sdk.ISDKPlatform;
@@ -48,11 +50,17 @@
*/
public class TestSB1SDKProvider extends BaseTest {
private ISDKProvider sb1Provider;
-
+ private IMachine machine;
+
@Override
protected void setUp() throws Exception {
super.setUp();
+ for (IMachine machine : MachineRegistry.getInstance().getBuildMachines()) {
+ this.machine = machine;
+ break;
+ }
+
IPreferenceStore store = CorePreferenceManager.getInstance().getPreferenceStore(SB1PreferenceConstants.SB1_ROOTS);
store.setValue(SB1PreferenceConstants.SB1_ROOTS, "/scratchbox:/opt/scratchbox");
@@ -88,7 +96,7 @@
if (sb1Provider == null)
return;
- List<ISDK> sdks = sb1Provider.createSDKs(new NullProgressMonitor());
+ List<ISDK> sdks = sb1Provider.createSDKs(machine, new NullProgressMonitor());
assertNotNull(sdks);
for (ISDK sdk : sdks) {
@@ -117,7 +125,7 @@
if (sb1Provider == null)
return;
- List<ISDK> sdks = sb1Provider.createSDKs(new NullProgressMonitor());
+ List<ISDK> sdks = sb1Provider.createSDKs(machine, new NullProgressMonitor());
assertNotNull(sdks);
for (ISDK sdk : sdks) {
@@ -152,7 +160,7 @@
return;
boolean any = false;
- List<ISDK> sdks = sb1Provider.createSDKs(null);
+ List<ISDK> sdks = sb1Provider.createSDKs(machine, null);
for (ISDK sdk : sdks) {
ISDKTarget[] targets = sdk.getSDKTargets();
// for this test, we need to have something to test
@@ -303,7 +311,7 @@
fail("Refreshing took too long: " + (System.currentTimeMillis() - start) + " ms to scan " + count + " times");
try {
- List<ISDK> sdks = sb1Provider.createSDKs(null);
+ List<ISDK> sdks = sb1Provider.createSDKs(machine, null);
if (first) {
for (ISDK sdk : sdks) {
(((Scratchbox1SDK) sdk).getCache()).clear();
Modified: trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2ProcessLauncher.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2ProcessLauncher.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2ProcessLauncher.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -19,6 +19,8 @@
import org.junit.Test;
import org.maemo.esbox.internal.scratchbox.sb2.provider.Scratchbox2SDKProvider;
import org.maemo.mica.common.core.*;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.preferences.CorePreferenceConstants;
import org.maemo.mica.common.core.preferences.CorePreferenceManager;
import org.maemo.mica.common.core.process.*;
@@ -41,11 +43,18 @@
*/
public class TestSB2ProcessLauncher extends TestProcessLauncher {
ISDKProvider sb2Provider;
+ private IMachine machine;
private static List<ISDK> sdks;
@Override
protected void setUp() throws Exception {
super.setUp();
+
+ for (IMachine machine : MachineRegistry.getInstance().getBuildMachines()) {
+ this.machine = machine;
+ break;
+ }
+
IPreferenceStore preferenceStore = CorePreferenceManager.getInstance().getPreferenceStore(
CorePreferenceConstants.LOG_COMMANDS);
preferenceStore.setValue(
@@ -79,7 +88,7 @@
if (sb2Provider == null)
sdks = Collections.EMPTY_LIST;
else
- sdks = sb2Provider.createSDKs(new NullProgressMonitor());
+ sdks = sb2Provider.createSDKs(machine, new NullProgressMonitor());
}
SDKManager.getInstance().waitForRefreshComplete(null);
return sdks;
Modified: trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2SDKProvider.java
===================================================================
--- trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2SDKProvider.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.scratchbox.tests/src/org/maemo/esbox/scratchbox/tests/TestSB2SDKProvider.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -18,6 +18,8 @@
import org.maemo.esbox.scratchbox.core.sdk.IScratchboxSDKTarget;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.machine.ILocalMachine;
+import org.maemo.mica.common.core.machine.IMachine;
+import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.sdk.*;
import org.maemo.mica.common.core.tests.TestUtils;
import org.maemo.mica.internal.api.common.core.sdk.SDKManagerInternal;
@@ -36,12 +38,19 @@
*/
public class TestSB2SDKProvider extends TestCase {
private ISDKProvider sb2Provider;
+ private IMachine machine;
@Override
protected void setUp() throws Exception {
super.setUp();
+
+ for (IMachine machine : MachineRegistry.getInstance().getBuildMachines()) {
+ this.machine = machine;
+ break;
+ }
+
SDKManager factory = SDKManagerInternal.getInstance();
-
+
List<ISDKProvider> providers = factory.getSDKProviders();
assertNotNull(providers);
@@ -66,7 +75,7 @@
if (sb2Provider == null)
return;
- List<ISDK> sdks = sb2Provider.createSDKs(null);
+ List<ISDK> sdks = sb2Provider.createSDKs(machine, null);
assertNotNull(sdks);
for (ISDK sdk : sdks) {
@@ -93,7 +102,7 @@
if (sb2Provider == null)
return;
- List<ISDK> sdks = sb2Provider.createSDKs(new NullProgressMonitor());
+ List<ISDK> sdks = sb2Provider.createSDKs(machine, new NullProgressMonitor());
for (ISDK sdk : sdks) {
ISDKTarget[] targets = sdk.getSDKTargets();
for (ISDKTarget target : targets) {
@@ -203,7 +212,7 @@
fail("Refreshing took too long: " + (System.currentTimeMillis() - start) + " ms to scan " + count + " times");
try {
- List<ISDK> sdks = sb2Provider.createSDKs(null);
+ List<ISDK> sdks = sb2Provider.createSDKs(machine, null);
if (first) {
for (ISDK sdk : sdks) {
(((Scratchbox2SDK) sdk).getCache()).clear();
Modified: trunk/org.maemo.esbox.tests/asthelper.completions
===================================================================
(Binary files differ)
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseLaunchableVirtualMachineController.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -137,14 +137,6 @@
return false;
return !monitor.isCompleted();
- /*
- return true;
- try {
- launcher.getLastCreatedProcess().exitValue();
- return false;
- } catch (IllegalThreadStateException e) {
- return true;
- }*/
}
/**
@@ -195,13 +187,9 @@
public void cancel() {
setFailed(CANCEL_STATUS);
- // XXX: don't do this here... we can't distinguish explicit user cancel from
+ // don't cancel anything else here... we can't distinguish explicit user cancel from
// a nested cancellation (e.g. refresh SDKs launches machine, then the refresh is canceled).
// This can result in killing a perfectly fine machine
- //if (monitor != null)
- // monitor.terminate();
- //if (launcher != null)
- // launcher.getLastCreatedProcess().destroy();
}
}
/**
@@ -339,7 +327,7 @@
try {
sdk.forceShutdown(new SubProgressMonitor(monitor, 1));
} catch (MicaException e) {
- throw new MachineException(null, e);
+ Activator.getErrorLogger().logError("Problem when shutting down SDK before halting " + getMachine().getName(), e);
}
if (monitor.isCanceled())
return;
@@ -444,15 +432,12 @@
} else {
- // if the machine is timing out, might just be turned off
- if (status.getCode() == SSHErrorConstants.CODE_TIMEOUT) {
+ // if the machine is timing out, or is turned off,
+ // then this can't be repaired
+ if (status.getCode() == SSHErrorConstants.CODE_TIMEOUT
+ || !isMachineRunning()) {
return Result.IGNORE;
}
- //IStatus probeStatus = testSSHPort();
- //if (!probeStatus.isOK()) {
- // no one listening to the port, so probably machine not running; ignore the error and keep trying
- // return Result.IGNORE;
- //}
}
return super.doAskUserToRepairMachine(shell, status, mode);
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachine.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -30,4 +30,17 @@
super(id, name, os, arch, controller, sshConfiguration,
sharedFilesystemProvider);
}
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineBackend#isAlive()
+ */
+ @Override
+ public boolean isAlive() {
+ if (getMachineController() instanceof BaseLaunchableVirtualMachineController) {
+ boolean isVMRunning = ((BaseLaunchableVirtualMachineController) getMachineController()).isMachineRunning();
+ if (!isVMRunning)
+ return false;
+ }
+ return super.isAlive();
+ }
}
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineConfiguration.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -14,6 +14,8 @@
import java.io.IOException;
import java.io.StringWriter;
import java.net.URI;
+import java.util.Arrays;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.jface.dialogs.IDialogSettings;
@@ -46,15 +48,45 @@
final int prime = 31;
int result = 1;
result = prime * result;
+ String settingsString = getCanonicalSettingsString(settings);
+ result += settingsString.hashCode();
+ return result;
+ }
+
+ /**
+ * IDialogSettings has neither #equals nor a way to fetch all the keys...
+ * so we have to externalize it to detect differences.
+ * @param settings2
+ * @return
+ */
+ private String getCanonicalSettingsString(IDialogSettings settings) {
if (settings != null) {
StringWriter writer = new StringWriter();
try {
settings.save(writer);
} catch (IOException e) {
}
- result += writer.toString().hashCode();
+ String fullString = writer.toString();
+
+ // ignore the section name, since it's not predictable
+ fullString = fullString.replaceAll("name=\"[^\"]+\"", "name=\"temp\"");
+
+ // the lines are not necessarily sorted...
+ String[] lines1 = fullString.split("\n");
+ Arrays.sort(lines1,
+ new Comparator<String>() {
+
+ public int compare(String o1, String o2) {
+ if (o1.contains("<item") && o2.contains("<item")) {
+ return o1.compareTo(o2);
+ }
+ return 0;
+ }
+
+ });
+ return TextUtils.catenateStrings(lines1, "\n");
}
- return result;
+ return "";
}
/* (non-Javadoc)
@@ -69,18 +101,15 @@
if (getClass() != obj.getClass())
return false;
BaseVirtualMachineConfiguration other = (BaseVirtualMachineConfiguration) obj;
+
+ // DialogSettings does not implement #equals()
if (settings == null) {
if (other.settings != null)
return false;
} else {
- StringWriter writer1 = new StringWriter();
- StringWriter writer2 = new StringWriter();
- try {
- settings.save(writer1);
- other.settings.save(writer2);
- } catch (IOException e) {
- }
- if (!writer1.toString().equals(writer2.toString()))
+ String settingsString1 = getCanonicalSettingsString(settings);
+ String settingsString2 = getCanonicalSettingsString(other.settings);
+ if (!settingsString1.equals(settingsString2))
return false;
}
return true;
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/core/BaseVirtualMachineController.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -20,17 +20,22 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.PreferenceDialog;
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.BuildMachinePreferencePage;
+import org.maemo.esbox.internal.api.vm.ui.LaunchVirtualMachineDialog;
import org.maemo.esbox.internal.api.vm.ui.SlowVirtualMachineLaunchMonitorDialog;
import org.maemo.esbox.internal.api.vm.ui.SynchronizedProgressPartProgressMonitor;
import org.maemo.esbox.internal.vm.Activator;
+import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.mica.common.core.Policy;
+import org.maemo.mica.common.core.ProductUtils;
import org.maemo.mica.common.core.WorkspaceUtils;
import org.maemo.mica.common.core.machine.IMachine;
import org.maemo.mica.common.core.machine.MachineException;
@@ -84,14 +89,60 @@
IStatus status;
- /* we don't know where we are when this is called... let the caller decide
- status = doStopVirtualMachine(new SubProgressMonitor(monitor, 1));
- if (!status.isOK() && machine.isAlive())
- return status;
- if (monitor.isCanceled())
- return CANCEL_STATUS;
- */
+ boolean doLaunch;
+ if (WorkbenchUtils.isJUnitRunning()) {
+ doLaunch = true;
+ } else {
+ // ask the user first; don't auto-start VMs
+ final String name;
+ if (machine instanceof IVirtualMachine)
+ name = ((IVirtualMachine) machine).getDescriptiveName();
+ else
+ name = machine.getName();
+
+ final String message;
+
+ final boolean likelyNetworkIssue;
+ likelyNetworkIssue = (this instanceof BaseLaunchableVirtualMachineController
+ && ((BaseLaunchableVirtualMachineController) this).isMachineRunning());
+
+ if (likelyNetworkIssue)
+ message = MessageFormat.format("{0} cannot contact the VM:\n \n{1}.\n \n"
+ + "Launch it now, or look for solutions below?",
+ ProductUtils.getProductName(),
+ name);
+ else
+ message = MessageFormat.format("{0} needs to launch the VM:\n \n{1}.\n \n"
+ + "Launch it now?",
+ ProductUtils.getProductName(),
+ name);
+
+ final boolean launchRet[] = { false };
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ LaunchVirtualMachineDialog dialog = new LaunchVirtualMachineDialog(
+ null, "Virtual Machine Needed",
+ message,
+ "If the machine has already booted, you may need to synchronize the network settings or look for other problems.",
+ new ILookHereProvider[] {
+ getLookAtBuildMachinePrefs(),
+ getLookAtNetworkPrefs(),
+ getLookAtMaemoVMWare()
+ });
+
+ if (likelyNetworkIssue) {
+ dialog.setHelpExpanded(true);
+ }
+ launchRet[0] = dialog.open() == IDialogConstants.OK_ID;
+ }
+ });
+ doLaunch = launchRet[0];
+ }
+
+ if (!doLaunch)
+ return Status.CANCEL_STATUS;
+
final SynchronizedProgressPartProgressMonitor launchMonitor;
final SlowVirtualMachineLaunchMonitorDialog[] monitorDialog = { null };
@@ -103,11 +154,13 @@
if (!WorkspaceUtils.isJUnitRunning()) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
+ // wait 15 seconds before showing the dialog,
+ // just in case the configuration is so broken that
+ // the VM or engine cannot even start.
monitorDialog[0] = new SlowVirtualMachineLaunchMonitorDialog(
machine, BaseVirtualMachineController.this,
WorkbenchUtils.getSafeShell(),
- 1000 * 60,
- monitor);
+ 1000 * 15);
launchMonitor.setProgressPart(monitorDialog[0].getProgressPart());
launchMonitor.beginTask("", IProgressMonitor.UNKNOWN);
}
@@ -141,8 +194,65 @@
}
}
+
+ /**
+ * Create a "look here" provider pointing to the Maemo VMware project page.
+ * @return
+ */
+ protected ILookHereProvider getLookAtMaemoVMWare() {
+ return new ILookHereProvider() {
+ public String getId() {
+ return "maemovmware.prefs";
+ }
+
+ public String getLabel() {
+ return "Maemo SDK Virtual Image documentation";
+ }
+
+ public void handleSelected(Shell shell) {
+ WorkbenchUtils.showWebPageInExternalBrowser(
+ "http://maemovmware.garage.maemo.org/2nd_edition/documentation.html"); // $NON-NLS-1$
+ }
+
+ };
+ }
+
/**
+ * Create a "look here" provider pointing to Eclipse network preferences.
+ * @return
+ */
+ protected ILookHereProvider getLookAtBuildMachinePrefs() {
+ return new ILookHereProvider() {
+
+ public String getId() {
+ return "buildmachine.prefs";
+ }
+
+ public String getLabel() {
+ return "Build Machines preferences";
+ }
+
+ public void handleSelected(Shell shell) {
+ Display.getDefault().asyncExec(new Runnable() {
+
+ public void run() {
+ final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ null,
+ BuildMachinePreferencePage.PAGE_ID,
+ null,
+ null);
+ dialog.setBlockOnOpen(false);
+ dialog.open();
+ }
+
+ });
+ }
+
+ };
+ }
+
+ /**
* Start the machine in the VM specific way.
* @param monitor
* @return status of start (OK for no-op or success)
@@ -222,8 +332,11 @@
Activator.getImageDescriptor("icons/full/etool16/virtual_machine_64.png").createImage(),
- MessageFormat.format("Cannot start or connect to virtual machine ''{0}''",
- getName()),
+ MessageFormat.format("Cannot start or connect to virtual machine ''{0}'' at {1}:{2}",
+ getName(),
+ getConfiguration().getTargetAddress(),
+ "" + getConfiguration().getTargetPort()
+ ),
"Be sure the machine is configured properly and that its software is launched, and that the running VM has network connectivity.",
@@ -232,4 +345,5 @@
);
}
+
}
Copied: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java (from rev 2198, branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java)
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java (rev 0)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/AbstractExpandableLookHereDialog.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -0,0 +1,187 @@
+/*******************************************************************************
+ * Copyright (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:
+ * Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.vm.ui;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.mica.internal.api.common.core.ILookHereProvider;
+import org.maemo.mica.internal.api.common.core.ui.LookHereMessageWidget;
+
+/**
+ * @author eswartz
+ *
+ */
+public class AbstractExpandableLookHereDialog extends MessageDialog {
+
+ protected LookHereMessageWidget lookHere;
+ protected final ILookHereProvider[] lookHereProviders;
+ protected final String helpMessage;
+ private Group lookHereGroup;
+ private GridData lookHereGridData;
+ private boolean initExpanded;
+ private Button helpButton;
+
+ /**
+ * @param parentShell
+ * @param dialogTitle
+ * @param dialogTitleImage
+ * @param dialogMessage
+ * @param dialogImageType
+ * @param dialogButtonLabels
+ * @param defaultIndex
+ */
+ public AbstractExpandableLookHereDialog(Shell parentShell,
+ String dialogTitle,
+ Image dialogTitleImage,
+ String dialogMessage,
+ int dialogImageType,
+ String helpMessage,
+ ILookHereProvider[] providers,
+ String[] dialogButtonLabels,
+ int defaultIndex) {
+ super(parentShell, dialogTitle, dialogTitleImage, dialogMessage,
+ dialogImageType, dialogButtonLabels, defaultIndex);
+ setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MIN);
+ this.helpMessage = helpMessage;
+ this.lookHereProviders = providers;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.ErrorDialog#buttonPressed(int)
+ */
+ @Override
+ protected void buttonPressed(int id) {
+ if (id == IDialogConstants.HELP_ID) {
+ // let our own listener act
+ return;
+ }
+ super.buttonPressed(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.MessageDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createButtonsForButtonBar(Composite parent) {
+ super.createButtonsForButtonBar(parent);
+
+ // get help
+
+ // NOTE: we really want to use SWT.TOGGLE here, but the button
+ // looks totally different from a pushbutton on OS X :p
+
+ helpButton = new Button(parent, SWT.PUSH);
+ helpButton.setFont(JFaceResources.getDialogFont());
+ helpButton.setData(IDialogConstants.HELP_ID);
+
+ ((GridLayout) parent.getLayout()).numColumns++;
+ setButtonLayoutData(helpButton);
+
+ helpButton.addSelectionListener(new SelectionAdapter() {
+ boolean toggled = false;
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ toggled = !toggled;
+ //if (helpButton.getSelection()) {
+ updateHelp(toggled);
+ }
+ });
+ }
+
+ /**
+ * @param toggled
+ */
+ protected void updateHelp(boolean toggled) {
+ if (toggled) {
+ helpButton.setText("<< " + IDialogConstants.HELP_LABEL);
+ lookHereGridData.heightHint = SWT.DEFAULT;
+ lookHereGridData.exclude = false;
+ lookHereGroup.setVisible(true);
+ }
+ else {
+ helpButton.setText(IDialogConstants.HELP_LABEL + " >>");
+ lookHereGridData.exclude = true;
+ lookHereGridData.heightHint = 0;
+ lookHereGroup.setVisible(false);
+ }
+ getShell().pack();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IconAndMessageDialog#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite contents = (Composite) super.createContents(parent);
+
+ lookHereGroup = new Group(contents, SWT.SHADOW_IN);
+ lookHereGridData = GridDataFactory.fillDefaults().span(2, 1).exclude(true).create();
+ lookHereGroup.setLayoutData(lookHereGridData);
+ lookHereGroup.setLayout(new GridLayout());
+ lookHereGroup.setVisible(false);
+
+ lookHere = new LookHereMessageWidget(lookHereGroup,
+ helpMessage,
+ lookHereProviders);
+ lookHere.setLinkSelectedListener(new LookHereMessageWidget.LinkSelectedListener() {
+
+ public void notifyLinkSelected() {
+ // must close this dialog right now, since these handlers are
+ // likely to put up UI which will only appear behind the dialog
+ AbstractExpandableLookHereDialog.this.setReturnCode(IDialogConstants.CANCEL_ID);
+ AbstractExpandableLookHereDialog.this.close();
+ }
+
+ });
+
+ updateHelp(initExpanded);
+
+ return contents;
+ }
+
+ @Override
+ protected Control createMessageArea(Composite composite) {
+ Composite control = (Composite) super.createMessageArea(composite);
+
+ GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER)
+ .applyTo(this.imageLabel);
+
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
+ .align(SWT.LEFT, SWT.BEGINNING)
+ .applyTo(messageLabel);
+
+ return control;
+ }
+
+ /**
+ * Set the default state of the help portion (before initialization)
+ */
+ public void setHelpExpanded(boolean initExpanded) {
+ this.initExpanded = initExpanded;
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java (from rev 2198, branches/work_Ed/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java)
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java (rev 0)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/LaunchVirtualMachineDialog.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.api.vm.ui;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.maemo.esbox.internal.vm.Activator;
+import org.maemo.mica.internal.api.common.core.ILookHereProvider;
+
+/**
+ * Create a dialog describing a problem with an machine,
+ * passing an IStatus from a failed machine acquire/probe call.
+ * This will present some hyperlinks allowing to user to find
+ * possible sources of help.
+ * @author eswartz
+ *
+ */
+public class LaunchVirtualMachineDialog extends AbstractExpandableLookHereDialog {
+
+ public LaunchVirtualMachineDialog(Shell parent,
+ String title,
+ String mainMessage,
+ String helpMessage,
+ ILookHereProvider[] providers) {
+ super(parent, title, null, mainMessage, MessageDialog.QUESTION,
+ helpMessage,
+ providers,
+ new String[] { "Launch", IDialogConstants.CANCEL_LABEL }, 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return Activator.getImageDescriptor("icons/full/etool16/virtual_machine_64.png").createImage();
+ }
+}
\ No newline at end of file
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/SlowVirtualMachineLaunchMonitorDialog.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -21,16 +21,13 @@
import org.eclipse.jface.wizard.ProgressMonitorPart;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import org.maemo.mica.common.core.ProductUtils;
import org.maemo.mica.common.core.machine.IMachine;
import org.maemo.mica.common.core.machine.IMachineController;
-import org.maemo.mica.internal.api.common.core.ui.LookHereMessageWidget;
import org.maemo.mica.internal.api.protocol.ssh.SSHMachineControllerBase;
import org.maemo.mica.protocol.ssh.SSHConfiguration;
@@ -40,33 +37,34 @@
* @author eswartz
*
*/
-public class SlowVirtualMachineLaunchMonitorDialog extends MessageDialog {
+public class SlowVirtualMachineLaunchMonitorDialog extends AbstractExpandableLookHereDialog {
- /**
- *
- */
- private final IMachineController machineController;
- protected LookHereMessageWidget lookHere;
private Timer timer;
- private final IProgressMonitor monitor;
private ProgressMonitorPart progressPart;
private final IMachine machine;
public SlowVirtualMachineLaunchMonitorDialog(
IMachine machine_, IMachineController machineController, Shell parent,
- int longOperationTime, IProgressMonitor monitor) {
+ int longOperationTime) {
super(parent, "Launching Virtual Machine", null,
- "Launching " + machine_.getName() + "...",
+ "Waiting for " + machine_.getName() + " to boot up and respond to SSH...",
MessageDialog.INFORMATION,
+ getHelpMessage(machineController),
+ machineController.createLookHereProviders(),
new String[] { IDialogConstants.OK_LABEL },
0);
this.machine = machine_;
- this.monitor = monitor;
- setShellStyle(getShellStyle() | SWT.RESIZE);
+ setShellStyle(getShellStyle() & ~(SWT.APPLICATION_MODAL + SWT.SYSTEM_MODAL));
setBlockOnOpen(false);
- this.machineController = machineController;
+ // create immediately but do not open until later
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ create();
+ getButton(IDialogConstants.OK_ID).setText(IDialogConstants.CLOSE_LABEL);
+ }
+ });
timer = new Timer(true);
timer.schedule(new TimerTask() {
@@ -100,17 +98,34 @@
}, longOperationTime);
- // create immediately but do not open until later
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- create();
- getButton(IDialogConstants.OK_ID).setText(IDialogConstants.CLOSE_LABEL);
- }
- });
-
}
+ /**
+ * @param machineController
+ * @return
+ */
+ private static String getHelpMessage(IMachineController machineController) {
+
+ StringBuilder builder = new StringBuilder();
+ // the weird spaces between newlines are for OS X
+ builder.append("If the machine booted successfully but this dialog doesn't go away, then the network settings may need to be synchronized.\n \n");
+
+ if (machineController instanceof SSHMachineControllerBase) {
+ SSHConfiguration config = ((SSHMachineControllerBase) machineController).getConfiguration();
+ builder.append(MessageFormat.format(
+ "{0} expects to connect to the machine at address {1}:{2}, and for the machine to talk back to the host at address {3} (which you can verify with a ping).\n \n",
+ ProductUtils.getProductName(),
+ config.getTargetAddress(), config.getTargetPort() + "",
+ config.getHostAddress()));
+ }
+
+ builder.append("A Maemo SDK virtual image runs 'dhclient3' at the end of its boot sequence; you should see the Target IP Address 'bound to' in the console.");
+
+ return builder.toString();
+ }
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.Dialog#getInitialSize()
*/
@@ -138,47 +153,7 @@
protected Control createMessageArea(Composite parent) {
Composite composite = (Composite) super.createMessageArea(parent);
- GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER)
- .applyTo(this.imageLabel);
-
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
- .align(SWT.LEFT, SWT.BEGINNING)
- .applyTo(messageLabel);
-
- Group group = new Group(composite, SWT.SHADOW_IN);
- GridDataFactory.fillDefaults().span(2, 1).applyTo(group);
- group.setLayout(new GridLayout());
-
- StringBuilder builder = new StringBuilder();
- // the weird spaces are for OS X
- builder.append("The virtual machine is still launching but is not accessible yet.\n \n");
- builder.append("If the machine boots successfully but this dialog doesn't go away, then the network settings may need to be synchronized.\n \n");
-
- if (machineController instanceof SSHMachineControllerBase) {
- SSHConfiguration config = ((SSHMachineControllerBase) machineController).getConfiguration();
- builder.append(MessageFormat.format(
- "{0} expects to connect to the machine at address {1}:{2}, and for the machine to talk back to the host at address {3} (which you can verify with a ping).\n \n",
- ProductUtils.getProductName(),
- config.getTargetAddress(), config.getTargetPort() + "",
- config.getHostAddress()));
- }
-
- builder.append("A Maemo SDK virtual image runs 'dhclient' at the end of its boot sequence; you should see the Target IP Address 'bound to' in the console.");
-
- lookHere = new LookHereMessageWidget(group,
- builder.toString(),
- machineController.createLookHereProviders());
-
- lookHere.setLinkSelectedListener(new LookHereMessageWidget.LinkSelectedListener() {
-
- public void notifyLinkSelected() {
- monitor.setCanceled(true);
- close();
- }
-
- });
-
- progressPart = new ProgressMonitorPart(composite, null);
+ progressPart = new ProgressMonitorPart(composite, null);
GridDataFactory.fillDefaults().span(2, 1).applyTo(progressPart);
progressPart.beginTask("Waiting...", IProgressMonitor.UNKNOWN);
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/BaseVirtualMachinePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/BaseVirtualMachinePreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/BaseVirtualMachinePreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -15,11 +15,10 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.Point;
+import org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage;
import org.maemo.esbox.internal.api.maemosdk.ui.preferences.SharedFoldersPreferencePage;
-import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.core.VirtualMachinePreferenceConstants;
-import org.maemo.mica.common.ui.preferences.ComposedPreferencePage;
import org.maemo.mica.internal.api.common.core.DialogSettingsPreferenceStore;
/**
@@ -28,7 +27,7 @@
* @author eswartz
*
*/
-public abstract class BaseVirtualMachinePreferencePage extends ComposedPreferencePage {
+public abstract class BaseVirtualMachinePreferencePage extends BaseMachinePreferencePage {
protected IVirtualMachineSettingsPreferencePage vmPrefPage;
protected CommonVirtualMachineSettingsPreferencePage commonPrefPage;
@@ -83,12 +82,6 @@
abstract protected IVirtualMachineAddressConfigurator createAddressConfigurator();
/**
- * Recreate the machine from the current unsaved preferences
- * @return new {@link IVirtualMachine}
- */
- abstract protected IVirtualMachine createMachine();
-
- /**
* Call from a VM page if some settings influence the network
* settings.
*/
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/api/vm/ui/preferences/CommonVirtualMachineSettingsPreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -29,6 +29,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
+import org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage;
import org.maemo.esbox.internal.vm.Activator;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.core.VirtualMachinePreferenceConstants;
@@ -54,11 +55,11 @@
//private IntegerFieldEditor feCifsHostPort;
private IVirtualMachineAddressConfigurator addressConfigurator;
private Button configNetworkButton;
- /*private*/ final BaseVirtualMachinePreferencePage basePrefPage;
+ /*private*/ final BaseMachinePreferencePage basePrefPage;
public CommonVirtualMachineSettingsPreferencePage(
IPreferenceStore preferenceStore,
- IVirtualMachineAddressConfigurator addressConfigurator, BaseVirtualMachinePreferencePage basePrefPage) {
+ IVirtualMachineAddressConfigurator addressConfigurator, BaseMachinePreferencePage basePrefPage) {
super();
this.addressConfigurator = addressConfigurator;
this.basePrefPage = basePrefPage;
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachine.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachine.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachine.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -1,58 +1,108 @@
-/*******************************************************************************
- * Copyright (c) 2008-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:
- * Ed Swartz (Nokia) - initial API and implementation
- *******************************************************************************/
-
-package org.maemo.esbox.internal.vm;
-
-import org.eclipse.core.runtime.Platform;
-import org.maemo.esbox.internal.api.vm.core.BaseVirtualBuildMachine;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.mica.common.core.machine.IComposablePreferencePage;
-import org.maemo.mica.internal.api.common.core.filesystem.BaseSharedFilesystemProvider;
-
-/**
- * Manually launched machine.
- * @author eswartz
- *
- */
-public class ManualVirtualMachine extends BaseVirtualBuildMachine {
-
- private static final String ID = Activator.PLUGIN_ID + ".manual_vm";
- private ManualVirtualMachineConfiguration configuration;
-
- /**
- * @param name
- * @param preferenceManualVMConfiguration
- */
- public ManualVirtualMachine(String name,
- ManualVirtualMachineConfiguration configuration) {
- super(ID, name, Platform.OS_LINUX, Platform.ARCH_X86,
- new ManualVirtualMachineController(configuration),
- configuration.getSSHConfiguration(),
- new BaseSharedFilesystemProvider(configuration.getSharedFolders()));
- this.configuration = configuration;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.mica.common.core.machine.IBuildMachine#createPreferencePage()
- */
- public IComposablePreferencePage createPreferencePage() {
- return new ManualVirtualMachinePreferencePage(configuration);
- }
-
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.vm.core.IVirtualMachine#getConfiguration()
- */
- public IVirtualMachineConfiguration getConfiguration() {
- return configuration;
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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:
+ * Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.vm;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.Platform;
+import org.maemo.esbox.internal.api.vm.core.BaseVirtualBuildMachine;
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+import org.maemo.mica.common.core.machine.IComposablePreferencePage;
+import org.maemo.mica.internal.api.common.core.filesystem.BaseSharedFilesystemProvider;
+
+/**
+ * Manually launched machine.
+ * @author eswartz
+ *
+ */
+public class ManualVirtualMachine extends BaseVirtualBuildMachine {
+
+ private static final String ID = Activator.PLUGIN_ID + ".manual_vm";
+ private ManualVirtualMachineConfiguration configuration;
+
+ /**
+ * @param name
+ * @param preferenceManualVMConfiguration
+ */
+ public ManualVirtualMachine(String name,
+ ManualVirtualMachineConfiguration configuration) {
+ super(ID, name, Platform.OS_LINUX, Platform.ARCH_X86,
+ new ManualVirtualMachineController(configuration),
+ configuration.getSSHConfiguration(),
+ new BaseSharedFilesystemProvider(configuration.getSharedFolders()));
+ this.configuration = configuration;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ // ONLY check configuration
+ int result = 1;
+ result = prime * result
+ + ((configuration == null) ? 0 : configuration.hashCode());
+ return result;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ // ONLY check configuration
+ //if (!super.equals(obj))
+ // return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ManualVirtualMachine other = (ManualVirtualMachine) obj;
+ if (configuration == null) {
+ if (other.configuration != null)
+ return false;
+ } else if (!configuration.equals(other.configuration))
+ return false;
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#getDescriptiveName()
+ */
+ public String getDescriptiveName() {
+ return MessageFormat.format("{0} at {1}",
+ getName(),
+ configuration.getSSHConfiguration().toString());
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.mica.common.core.machine.IBuildMachine#createPreferencePage()
+ */
+ public IComposablePreferencePage createPreferencePage() {
+ return new ManualVirtualMachinePreferencePage(configuration);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#getConfiguration()
+ */
+ public IVirtualMachineConfiguration getConfiguration() {
+ return configuration;
+ }
+
+}
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/internal/vm/ManualVirtualMachinePreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -1,90 +1,90 @@
-/*******************************************************************************
- * Copyright (c) 2008-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:
- * Ed Swartz (Nokia) - initial API and implementation
- *******************************************************************************/
-
-package org.maemo.esbox.internal.vm;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.DialogSettings;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.maemo.esbox.internal.api.vm.ui.preferences.AddressProvider;
-import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
-import org.maemo.esbox.internal.api.vm.ui.preferences.HostInterfaceAddressProvider;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IHostTargetAddressReconciler;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineAddressConfigurator;
-import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
-import org.maemo.esbox.internal.api.vm.ui.preferences.LocalhostTargetInterfaceAddressProvider;
-import org.maemo.esbox.internal.api.vm.ui.preferences.SameSubnetHostTargetAddressConciler;
-import org.maemo.esbox.vm.core.IVirtualMachine;
-import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
-import org.maemo.mica.common.core.machine.IComposablePreferencePage;
-import org.maemo.mica.common.core.ui.IProgressReporter;
-
-/**
- * @author eswartz
- *
- */
-public class ManualVirtualMachinePreferencePage extends
- BaseVirtualMachinePreferencePage implements IComposablePreferencePage {
-
- public ManualVirtualMachinePreferencePage(IVirtualMachineConfiguration config) {
- super(config);
- }
-
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
- */
- @Override
- protected IVirtualMachine createMachine() {
- ManualVirtualMachineConfiguration config =
- new ManualVirtualMachineConfiguration(new DialogSettings("temp"));
- commonPrefPage.saveTo(config);
- config.setSharedFolders(sharedFoldersPrefPage.getSharedFolders());
- return new ManualVirtualMachine("Test Manual Machine", config);
- }
-
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createVirtualMachinePreferencePage()
- */
- @Override
- protected IVirtualMachineSettingsPreferencePage createVirtualMachinePreferencePage(IPreferenceStore store) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createAddressConfigurator()
- */
- @Override
- protected IVirtualMachineAddressConfigurator createAddressConfigurator() {
- return new IVirtualMachineAddressConfigurator() {
-
- public AddressProvider getDefaultHostAddressProvider() {
- return new HostInterfaceAddressProvider();
- }
-
- public AddressProvider getDefaultTargetAddressProvider() {
- return new LocalhostTargetInterfaceAddressProvider();
- }
-
- public IHostTargetAddressReconciler getHostTargetAddressReconciler() {
- return new SameSubnetHostTargetAddressConciler();
- }
-
- public void configureNetworkSettings(IProgressReporter reporter) {
- // no clues
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "Cannot guess anything for a manually configured machine."));
- }
-
- };
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2008-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:
+ * Ed Swartz (Nokia) - initial API and implementation
+ *******************************************************************************/
+
+package org.maemo.esbox.internal.vm;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.maemo.esbox.internal.api.vm.ui.preferences.AddressProvider;
+import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
+import org.maemo.esbox.internal.api.vm.ui.preferences.HostInterfaceAddressProvider;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IHostTargetAddressReconciler;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineAddressConfigurator;
+import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
+import org.maemo.esbox.internal.api.vm.ui.preferences.LocalhostTargetInterfaceAddressProvider;
+import org.maemo.esbox.internal.api.vm.ui.preferences.SameSubnetHostTargetAddressConciler;
+import org.maemo.esbox.vm.core.IVirtualMachine;
+import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
+import org.maemo.mica.common.core.machine.IComposablePreferencePage;
+import org.maemo.mica.common.core.ui.IProgressReporter;
+
+/**
+ * @author eswartz
+ *
+ */
+public class ManualVirtualMachinePreferencePage extends
+ BaseVirtualMachinePreferencePage implements IComposablePreferencePage {
+
+ public ManualVirtualMachinePreferencePage(IVirtualMachineConfiguration config) {
+ super(config);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
+ */
+ @Override
+ public IVirtualMachine createMachine() {
+ ManualVirtualMachineConfiguration config =
+ new ManualVirtualMachineConfiguration(new DialogSettings("temp"));
+ commonPrefPage.saveTo(config);
+ config.setSharedFolders(sharedFoldersPrefPage.getSharedFolders());
+ return new ManualVirtualMachine("Test Manual Machine", config);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createVirtualMachinePreferencePage()
+ */
+ @Override
+ protected IVirtualMachineSettingsPreferencePage createVirtualMachinePreferencePage(IPreferenceStore store) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createAddressConfigurator()
+ */
+ @Override
+ protected IVirtualMachineAddressConfigurator createAddressConfigurator() {
+ return new IVirtualMachineAddressConfigurator() {
+
+ public AddressProvider getDefaultHostAddressProvider() {
+ return new HostInterfaceAddressProvider();
+ }
+
+ public AddressProvider getDefaultTargetAddressProvider() {
+ return new LocalhostTargetInterfaceAddressProvider();
+ }
+
+ public IHostTargetAddressReconciler getHostTargetAddressReconciler() {
+ return new SameSubnetHostTargetAddressConciler();
+ }
+
+ public void configureNetworkSettings(IProgressReporter reporter) {
+ // no clues
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "Cannot guess anything for a manually configured machine."));
+ }
+
+ };
+ }
+}
Modified: trunk/org.maemo.esbox.vm/src/org/maemo/esbox/vm/core/IVirtualMachine.java
===================================================================
--- trunk/org.maemo.esbox.vm/src/org/maemo/esbox/vm/core/IVirtualMachine.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm/src/org/maemo/esbox/vm/core/IVirtualMachine.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -26,4 +26,11 @@
* @return IVirtualMachineConfiguration instance, never <code>null</code>
*/
IVirtualMachineConfiguration getConfiguration();
+
+ /**
+ * Get the name of the VM which has some specific data about the machine
+ * (opposed to #getName()).
+ * @return String
+ */
+ String getDescriptiveName();
}
Modified: trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachine.java
===================================================================
--- trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachine.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachine.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -18,6 +18,7 @@
import org.maemo.mica.internal.api.common.core.filesystem.BaseSharedFilesystemProvider;
import java.net.URI;
+import java.text.MessageFormat;
/**
@@ -38,8 +39,57 @@
new BaseSharedFilesystemProvider(configuration.getSharedFolders()));
this.configuration = configuration;
}
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ // ONLY check configuration
+ int result = 1;
+ result = prime * result
+ + ((configuration == null) ? 0 : configuration.hashCode());
+ return result;
+ }
+
/* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ // ONLY check configuration
+ //if (!super.equals(obj))
+ // return false;
+ if (getClass() != obj.getClass())
+ return false;
+ QemuMachine other = (QemuMachine) obj;
+ if (configuration == null) {
+ if (other.configuration != null)
+ return false;
+ } else if (!configuration.equals(other.configuration))
+ return false;
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#getDescriptiveName()
+ */
+ public String getDescriptiveName() {
+ return MessageFormat.format("{0} ({1}:{2})",
+ getName(),
+ configuration.getSSHConfiguration().getTargetAddress(),
+ "" + configuration.getSSHConfiguration().getTargetPort());
+ }
+
+ /* (non-Javadoc)
* @see org.maemo.esbox.vm.core.IVirtualMachine#createPreferencePage(org.eclipse.swt.widgets.Composite)
*/
public IComposablePreferencePage createPreferencePage() {
Modified: trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuMachineController.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
+import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.qemu.IQemuConfiguration;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.machine.IProcess;
@@ -215,6 +216,12 @@
// re-check if things might be fishy
scheduleProbe();
}
+
+ // make sure it looks like QEMU is running
+ if (!isMachineRunning())
+ return Activator.createErrorStatus("QEMU is not running "
+ + ((IVirtualMachine) machine).getDescriptiveName(), null);
+
IStatus status = super.doProbeMachine(monitor);
//if (launchInfo != null && !status.isOK())
// launchInfo.setFailed(status);
Modified: trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuPreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -50,7 +50,7 @@
* @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
*/
@Override
- protected IVirtualMachine createMachine() {
+ public IVirtualMachine createMachine() {
IQemuConfiguration config = new QemuConfiguration(new DialogSettings("temp"));
commonPrefPage.saveTo(config);
config.setSharedFolders(sharedFoldersPrefPage.getSharedFolders());
Modified: trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuSettingsPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuSettingsPreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.qemu/src/org/maemo/esbox/internal/vm/qemu/QemuSettingsPreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -17,6 +17,7 @@
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.qemu.IQemuConfiguration;
import org.maemo.mica.common.ui.preferences.BaseComposableFieldEditorPreferencePage;
+import org.maemo.mica.common.ui.preferences.FileListFieldEditor;
import org.maemo.mica.common.ui.preferences.NonValidatingFileFieldEditor;
/**
@@ -83,7 +84,7 @@
text = feRamSize.getTextControl(getFieldEditorParent());
text.setToolTipText("Specify the size of RAM for the machine, in megabytes. Note: at least 512 Mb is recommended.");
- feDiskPath = new NonValidatingFileFieldEditor(
+ feDiskPath = new FileListFieldEditor(
QemuPreferenceConstants.QEMU_DISK_IMAGE_PATHS,
"Disk image(s):", getFieldEditorParent());
addField(feDiskPath);
Modified: trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachine.java
===================================================================
--- trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachine.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachine.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -12,14 +12,13 @@
import org.eclipse.core.runtime.Platform;
import org.maemo.esbox.internal.api.vm.core.BaseVirtualBuildMachine;
-import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.virtualbox.IVirtualBoxConfiguration;
import org.maemo.mica.common.core.machine.IComposablePreferencePage;
import org.maemo.mica.internal.api.common.core.filesystem.BaseSharedFilesystemProvider;
-import org.maemo.mica.internal.api.common.core.machine.IBuildMachineImpl;
import java.net.URI;
+import java.text.MessageFormat;
/**
@@ -27,7 +26,7 @@
* @author eswartz
*
*/
-public class VirtualBoxMachine extends BaseVirtualBuildMachine implements IVirtualMachine, IBuildMachineImpl {
+public class VirtualBoxMachine extends BaseVirtualBuildMachine {
public final static String ID = Activator.PLUGIN_ID + ".virtualbox_machine";
//
@@ -41,8 +40,57 @@
this.configuration = configuration;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ // ONLY check configuration
+ int result = 1;
+ result = prime * result
+ + ((configuration == null) ? 0 : configuration.hashCode());
+ return result;
+ }
+
/* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ // ONLY check configuration
+ //if (!super.equals(obj))
+ // return false;
+ if (getClass() != obj.getClass())
+ return false;
+ VirtualBoxMachine other = (VirtualBoxMachine) obj;
+ if (configuration == null) {
+ if (other.configuration != null)
+ return false;
+ } else if (!configuration.equals(other.configuration))
+ return false;
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#getDescriptiveName()
+ */
+ public String getDescriptiveName() {
+ return MessageFormat.format("{0} ({1} at {2}:{3})",
+ getName(),
+ configuration.getMachineName(),
+ configuration.getSSHConfiguration().getTargetAddress(),
+ "" + configuration.getSSHConfiguration().getTargetPort());
+ }
+
+ /* (non-Javadoc)
* @see org.maemo.esbox.vm.core.IVirtualMachine#createPreferencePage(org.eclipse.swt.widgets.Composite)
*/
public IComposablePreferencePage createPreferencePage() {
Modified: trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxMachineController.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -27,6 +27,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
+import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.virtualbox.IVirtualBoxConfiguration;
import org.maemo.mica.common.core.MicaException;
@@ -82,7 +83,7 @@
}
public String getLabel() {
- return "Enable port forwarding";
+ return "Enable port forwarding for NAT";
}
public void handleSelected(final Shell shell) {
@@ -102,7 +103,6 @@
if (MessageDialog.openQuestion(null, title, question)) {
VirtualBoxUtils.setPortForwarding(configuration, hostPort, targetPort);
-
if (isMachineRunning() && DialogUtils.showQuestionDialog(null, "Restart VirtualBox",
"VirtualBox needs to be restarted to apply changes.",
"Restart", "Leave running")) {
@@ -195,12 +195,25 @@
for (String line : results.getStdoutLines()) {
// handle 2.1, which lists only UUIDs, and 2.2, which lists the same format as "list vms"
- if (line.contains(machineUUID))
+ if (line.contains(machineUUID) || line.contains("\"" + machineName + "\""))
return true;
}
return false;
}
+ /* (non-Javadoc)
+ * @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineControllerBase#doProbeMachine(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ protected IStatus doProbeMachine(IProgressMonitor monitor) {
+ // make sure it looks like VirtualBox is running
+ if (!isMachineRunning())
+ return Activator.createErrorStatus("VirtualBox is not running "
+ + ((IVirtualMachine) machine).getDescriptiveName(), null);
+
+ return super.doProbeMachine(monitor);
+ }
+
/**
* Ensure we know the UUID for the machine
* @return
@@ -235,7 +248,8 @@
launchInfo.monitor.waitForCompletion(null);
// we need a little delay between that exit
- // and the actual launch
+ // and the actual launch, since it takes some time
+ // before the machine appears in the runningvms list.
int timeout = 5000;
while (timeout > 0) {
if (isMachineRunning())
Modified: trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxPreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -55,7 +55,7 @@
* @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
*/
@Override
- protected IVirtualMachine createMachine() {
+ public IVirtualMachine createMachine() {
IVirtualBoxConfiguration config = createConfiguration();
return new VirtualBoxMachine("Test VirtualBox Machine", config);
}
Modified: trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxSettingsPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxSettingsPreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.virtualbox/src/org/maemo/esbox/internal/vm/virtualbox/VirtualBoxSettingsPreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -57,7 +57,8 @@
private ComboViewer machineViewer;
private Job fetchMachinesJob;
private Collection<String> machineNames = Collections.emptyList();
-
+ private boolean hasScannedVirtualMachines;
+
/**
* @param preferenceStore
*
@@ -197,6 +198,9 @@
VirtualBoxPreferenceConstants.VIRTUALBOX_MACHINE_NAME);
if (!getComposite().isDisposed())
feVboxMachineName.setViewerModel(current);
+
+ hasScannedVirtualMachines = true;
+ validate();
}
});
@@ -228,10 +232,13 @@
setValid(false);
if (machineNames != null && !machineNames.isEmpty())
setErrorMessage("Please select a machine name after ensuring the Executable field is valid.");
+ else if (hasScannedVirtualMachines)
+ setErrorMessage("No VirtualBox VMs are registered or detected. Please ensure the Executable field is valid first.");
else
- setErrorMessage("No VirtualBox VMs are registered or detected. Please ensure the Executable field is valid first.");
+ setMessage("Scanning VirtualBox VMs...", INFORMATION);
} else {
setValid(true);
+ setMessage(null);
setErrorMessage(null);
}
}
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-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/api/vm/vmware/MaemoSDKVMInfo.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -11,7 +11,6 @@
package org.maemo.esbox.internal.api.vm.vmware;
import java.io.File;
-import java.net.URISyntaxException;
import java.net.URL;
import org.eclipse.jface.operation.IRunnableWithProgress;
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachine.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -11,7 +11,9 @@
package org.maemo.esbox.internal.vm.vmware;
import java.net.URI;
+import java.text.MessageFormat;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.maemo.esbox.internal.api.vm.core.BaseVirtualBuildMachine;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
@@ -39,8 +41,57 @@
this.configuration = configuration;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ // ONLY check configuration
+ int result = 1;
+ result = prime * result
+ + ((configuration == null) ? 0 : configuration.hashCode());
+ return result;
+ }
+
/* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ // ONLY check configuration
+ //if (!super.equals(obj))
+ // return false;
+ if (getClass() != obj.getClass())
+ return false;
+ VMwareMachine other = (VMwareMachine) obj;
+ if (configuration == null) {
+ if (other.configuration != null)
+ return false;
+ } else if (!configuration.equals(other.configuration))
+ return false;
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.maemo.esbox.vm.core.IVirtualMachine#getDescriptiveName()
+ */
+ public String getDescriptiveName() {
+ return MessageFormat.format("{0} ({1} at {2}:{3})",
+ getName(),
+ new Path(configuration.getVmxPath()).lastSegment(),
+ configuration.getSSHConfiguration().getTargetAddress(),
+ "" + configuration.getSSHConfiguration().getTargetPort());
+ }
+
+ /* (non-Javadoc)
* @see org.maemo.esbox.vm.core.IVirtualMachine#createPreferencePage(org.eclipse.swt.widgets.Composite)
*/
public IComposablePreferencePage createPreferencePage() {
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareMachineController.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -12,6 +12,7 @@
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IPath;
@@ -21,11 +22,14 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.maemo.esbox.internal.api.vm.core.BaseLaunchableVirtualMachineController;
+import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
import org.maemo.mica.common.core.HostUtils;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.machine.IProcess;
+import org.maemo.mica.common.core.machine.IProcessLister;
import org.maemo.mica.common.core.machine.MachineException;
+import org.maemo.mica.common.core.machine.MachineRegistry;
import org.maemo.mica.common.core.process.CommandLineArguments;
import org.maemo.mica.common.core.process.ProcessLauncherParameters;
import org.maemo.mica.common.core.process.ShellTemplateSubstitutor;
@@ -44,6 +48,46 @@
super("VMware", configuration);
}
+ /**
+ * Try to detect VMware running with the given vmx.
+ * @param program
+ * @param vmx
+ * @return list of possible matches
+ */
+ protected IProcess[] getRunningVMwareVMXInstances(File program, File vmx) {
+ IProcessLister processLister = MachineRegistry.getInstance().getLocalMachine().getProcessLister();
+ List<IProcess> allProcesses = processLister.getProcesses(null);
+
+ List<IProcess> matches = new ArrayList<IProcess>();
+
+ // First, see if we find the vmx referenced.
+ // (On OS X, a separate process handles the VMX itself, so it
+ // won't necessarily be the program we expect)
+ for (IProcess process : allProcesses) {
+ if (process.getCommandLine().contains(vmx.getName())) {
+ if (process.getName().contains(program.getName())
+ || process.getName().contains("vmware-vmx")) {
+ matches.add(process);
+ }
+ }
+ }
+
+ if (!matches.isEmpty())
+ return (IProcess[]) matches.toArray(new IProcess[matches.size()]);
+
+ // If on Windows, we'll never find the match, since command
+ // lines are empty. Be looser.
+ if (HostUtils.isWindows()) {
+ for (IProcess process : allProcesses) {
+ if (process.getName().contains(program.getName())) {
+ matches.add(process);
+ }
+ }
+ }
+
+ return (IProcess[]) matches.toArray(new IProcess[matches.size()]);
+ }
+
/* (non-Javadoc)
* @see org.maemo.esbox.internal.api.vm.core.IVirtualMachineController#isMachineRunning()
*/
@@ -54,28 +98,14 @@
return true;
}
- try {
- // TODO: check the product and use vmrun if possible (or not... that utility
- // is not available widely enough to be of any use)
- IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
-
- File exe = new File(config.getExecutable());
- IProcess[] runningVMwares = getRunningProcesses(exe, null);
- if (runningVMwares.length == 0)
- return false;
-
- if (!HostUtils.isWindows()) {
- // we can't tell anything on Windows
- File vmx = new File(config.getVmxPath());
- IProcess[] runningExactInstances = getRunningProcesses(exe, vmx);
- return runningExactInstances.length > 0;
- } else {
- return true;
- }
- } catch (MicaException e) {
- Activator.getErrorLogger().logError("Can't check running VMWare processes", e);
- return false;
- }
+ // TODO: check the product and use vmrun if possible (or not... that utility
+ // is not available widely enough to be of any use)
+ IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
+
+ File exe = new File(config.getExecutable());
+ File vmx = new File(config.getVmxPath());
+ IProcess[] runningVMwares = getRunningVMwareVMXInstances(exe, vmx);
+ return (runningVMwares.length > 0);
}
/* (non-Javadoc)
@@ -108,7 +138,10 @@
monitor.beginTask("Starting VMware...", 10);
monitor.subTask("Checking existing VMware instances...");
- // first, see if we recognize any other VMware instances
+ // First, see if we recognize any other VMware instances at all.
+ // We don't care about our vmx itself, but for the fact that
+ // the new process exits immediately if the executable is
+ // already running
IVMwareConfiguration config = (IVMwareConfiguration) machineConfiguration;
File exe = new File(config.getExecutable());
IProcess[] runningEngines;
@@ -181,11 +214,16 @@
* @see org.maemo.mica.internal.api.protocol.ssh.SSHMachineControllerBase#doProbeMachine(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- protected synchronized IStatus doProbeMachine(IProgressMonitor monitor) {
+ protected IStatus doProbeMachine(IProgressMonitor monitor) {
if (launchInfo != null && !launchInfo.isAlive()) {
// re-check if things might be fishy
scheduleProbe();
}
+
+ if (!isMachineRunning())
+ return Activator.createErrorStatus("VMware is not running "
+ + ((IVirtualMachine) machine).getDescriptiveName(), null);
+
IStatus status = super.doProbeMachine(monitor);
return status;
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwarePreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -11,6 +11,7 @@
package org.maemo.esbox.internal.vm.vmware;
+import java.io.IOException;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -29,6 +30,7 @@
import org.maemo.esbox.internal.api.vm.ui.preferences.SameSubnetHostTargetAddressConciler;
import org.maemo.esbox.vm.core.IVirtualMachine;
import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
+import org.maemo.mica.common.core.HostUtils;
import org.maemo.mica.common.core.MicaException;
import org.maemo.mica.common.core.ui.IProgressReporter;
import org.maemo.mica.internal.api.common.core.IPNetmaskFilter;
@@ -54,7 +56,7 @@
* @see org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage#createMachine()
*/
@Override
- protected IVirtualMachine createMachine() {
+ public IVirtualMachine createMachine() {
IVMwareConfiguration config = new VMwareConfiguration(new DialogSettings("temp"));
commonPrefPage.saveTo(config);
config.setSharedFolders(sharedFoldersPrefPage.getSharedFolders());
@@ -119,7 +121,7 @@
networkType = VMwareUtils.getNetworkConfig(config);
if (networkType.equals(VMwareUtils.NETWORK_CONFIG_NAT)) {
vmnet = "vmnet8";
- reporter.logInfo("Configuring for NAT networking.");
+ reporter.logInfo("Configuring for NAT networking on " + vmnet + ".");
isNAT = true;
}
else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_HOSTONLY)) {
@@ -127,6 +129,7 @@
reporter.log(Activator.createStatus(IStatus.ERROR,
"This VM is configured for host-only networking, which usually means it cannot be contacted from the host, nor access the Internet. Please reconfigure it for NAT or Bridged networking if problems occur."));
} else if (networkType.equals(VMwareUtils.NETWORK_CONFIG_BRIDGED)) {
+ //vmnet = "vmnet0"; // not a real interface
reporter.logInfo("Configuring for bridged networking.");
} else {
reporter.log(Activator.createStatus(IStatus.WARNING,
@@ -141,30 +144,169 @@
}
String port = "22";
- if (isNAT) {
- port = "2222";
- reporter.logInfo("Set SSH Target Port to the default recommendation for NAT ("+port+").");
- reporter.logInfo("If you're using Port Forwarding and NAT, this may need to be edited.");
+ commonPrefPage.getSSHHostPort().setStringValue(port);
+ reporter.logInfo("Set SSH Host Port to the default ("+port+").");
+
+
+ InetAddress hostAddr = null;
+
+ if (vmnet != null) {
+ Map<String, InetAddress> vmnets = VMwareUtils.getVMNetMappings();
+ hostAddr = vmnets.get(vmnet);
+
+ if (hostAddr == null) {
+ reporter.log(Activator.createStatus(IStatus.ERROR,
+ "Could not find the " + vmnet + " interface. The VMX file may be referencing a missing, misconfigured, or unknown interface."));
+ }
+ else if (isNAT && HostUtils.isWindows()) {
+ // supposedly, VMware creates a network interface where you can access the guest
+ // from the host... but it almost never works in Windows.
+ // http://communities.vmware.com/thread/153905;jsessionid=718043D50BAB7B5E4614ABBDBD0ECCF2?start=0&tstart=0
+
+ vmnet = null;
+
+ // Bah, let's not bother boring the user
+
+ /*
+ byte[] targetAddr = hostAddr.getAddress();
+ targetAddr[3] = (byte) 128;
+ InetAddress expectedTarget;
+ try {
+ expectedTarget = InetAddress.getByAddress(targetAddr);
+ } catch (UnknownHostException e) {
+ // unlikely
+ expectedTarget = hostAddr;
+ }
+ String expectedAddr = expectedTarget.getHostAddress();
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "We could try to use the " + vmnet + " interface to connect to the guest from the host, "+
+ "but it's a known issue that is unreliable in Windows: "+
+ "<http://communities.vmware.com/thread/153905;jsessionid=718043D50BAB7B5E4614ABBDBD0ECCF2?start=0&tstart=0>.\n \n"+
+ "If you want to try, go to Control Panel > Network Connections and edit the Properties of this interface "+
+ " (VMware Virtual Ethernet Adapter for " + vmnet + ") and enable the 'Internet Protocol (TCP/IP)' item.\n \n"+
+ "Launch the machine and see if you can ping the VMnet8 address that the machine is using (e.g. " + expectedAddr +"). " +
+ "If that works, feel free to use that Target Address, and a Target SSH port of 22.\n \n"+
+ "Since this is unreliable, though, I will recommend the NAT configuration using virtual ports. " +
+ "This assumes you have a Port Forwarding entry for SSH under " +
+ "Edit > Virtual Network Editor... > NAT > Edit > Port Forwarding... and added an entry with Host Port = 2222 " +
+ "and Virtual Machine IP Address = " + expectedAddr + "."));
+ */
+
+ } else if (!canAccessAddress(hostAddr)) {
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "Could not access the address of the " + vmnet + " interface."));
+
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "Not using vmnet address to access machine."));
+ vmnet = null;
+ }
+ }
+
+ if (vmnet != null) {
+ setupForVMnet(reporter, vmnet, hostAddr);
} else {
- reporter.logInfo("Set SSH Target Port to the default ("+port+").");
+ setupForUnknownNetwork(reporter, isNAT);
}
- commonPrefPage.getSSHTargetPort().setStringValue(port);
+
+ }
+ /**
+ * @param hostAddr
+ * @return
+ */
+ private boolean canAccessAddress(InetAddress hostAddr) {
+ try {
+ return hostAddr.isReachable(2500);
+ } catch (IOException e) {
+ return false;
+ }
+ }
+
+ /**
+ * We have a known VMnet, so configure for it by attaching to the
+ * endpoints of the subnet and using the standard SSH ports.
+ * @param reporter
+ * @param vmnet
+ */
+ private void setupForVMnet(IProgressReporter reporter, String vmnet, InetAddress hostAddr) {
+ String port;
port = "22";
- commonPrefPage.getSSHHostPort().setStringValue(port);
- reporter.logInfo("Set SSH Host Port to the default ("+port+").");
+ commonPrefPage.getSSHTargetPort().setStringValue(port);
+ reporter.logInfo("Set Target Port to " + port);
+ InetAddress targetAddr = null;
+
+ try {
+ // the network is *.1, but the endpoint is *.2
+ byte[] addr = hostAddr.getAddress();
+ if (addr.length == 4 && addr[3] == 1) {
+ addr[3] = 2;
+ hostAddr = Inet4Address.getByAddress(addr);
+ }
+ } catch (UnknownHostException e) {
+ reporter.log(Activator.createErrorStatus(
+ "Could not correct the local host address",
+ e));
+ }
+ commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
+
+ reporter.logInfo("Set Host Address to " + vmnet + " endpoint address " + hostAddr);
+
+ if (targetAddr == null) {
+ // guess the target address as being on the same subnet as the host
+ targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
+ }
+
+ if (targetAddr != null) {
+ commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
+
+ reporter.logInfo("Set Target Address to likely " + vmnet + " DHCP address " + targetAddr);
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "You may need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
+
+ } else {
+ reporter.log(Activator.createStatus(IStatus.WARNING,
+ "Unable to determine the likely target address for the " + vmnet + " interface."));
+ }
+
+ }
+
+ /**
+ * We don't know what vmnet is being used, so we have to basically guess.
+ * @param reporter
+ * @param isNAT
+ */
+ private void setupForUnknownNetwork(IProgressReporter reporter,
+ boolean isNAT) {
InetAddress hostAddr = null;
InetAddress targetAddr = null;
- if (vmnet == null) {
- // the host is the default in non-NAT, non-bridged modes
- try {
- hostAddr = InetAddress.getLocalHost();
- commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
-
- reporter.logInfo("Set Host Address to LAN address " + hostAddr);
+ String port = null;
+ try {
+ hostAddr = InetAddress.getLocalHost();
+ commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
+
+ reporter.logInfo("Set Host Address to LAN address " + hostAddr);
+
+ if (isNAT) {
+ try {
+ targetAddr = Inet4Address.getByAddress(new byte[] { 127, 0, 0, 1});
+
+ port = commonPrefPage.getSSHTargetPort().getStringValue();
+ if (port == null || port.length() == 0 || port.equals("0") || port.equals("22")) {
+ port = "2222";
+ reporter.logInfo("Set Target Port to the NAT default (" + port + ")");
+ commonPrefPage.getSSHTargetPort().setStringValue(port);
+ }
+ } catch (UnknownHostException e) {
+ // unlikely...
+ // guess the target address as being on the same subnet as the host
+ targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
+ }
+ }
+
+ if (targetAddr == null) {
// Dunno target -- it's DHCP. Reset the low byte if it's not on the same subnet.
targetAddr = commonPrefPage.getSSHTargetAddr().getAddress();
if (targetAddr instanceof Inet4Address) {
@@ -177,73 +319,38 @@
targetAddr = null;
}
}
-
- if (targetAddr == null) {
- targetAddr = InetAddress.getLocalHost();
- if (targetAddr instanceof Inet4Address) {
- byte[] addrBytes = targetAddr.getAddress();
- addrBytes[3] = 0;
- targetAddr = InetAddress.getByAddress(addrBytes);
- }
- commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
- reporter.logInfo("Set Target Address to LAN address " + targetAddr + " (please edit)");
+ }
+
+ if (targetAddr == null) {
+ targetAddr = InetAddress.getLocalHost();
+ if (targetAddr instanceof Inet4Address) {
+ byte[] addrBytes = targetAddr.getAddress();
+ addrBytes[3] = 0;
+ targetAddr = InetAddress.getByAddress(addrBytes);
}
+ }
+
+ commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
+ reporter.logInfo("Set Target Address to " + targetAddr +
+ (isNAT ? "" : " (please edit)"));
+
+ if (!isNAT) {
reporter.log(Activator.createStatus(IStatus.WARNING,
- "You will need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
- } catch (UnknownHostException e) {
- // dunno!
- reporter.log(Activator.createErrorStatus(
- "Could not construct the local host address",
- e));
- }
+ "You will need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
+ }
- } else {
- // configure based on the network in use
- Map<String, InetAddress> vmnets = VMwareUtils.getVMNetMappings();
- hostAddr = vmnets.get(vmnet);
- if (hostAddr != null) {
- try {
- // the network is *.1, but the endpoint is *.2
- byte[] addr = hostAddr.getAddress();
- if (addr.length == 4 && addr[3] == 1) {
- addr[3] = 2;
- hostAddr = Inet4Address.getByAddress(addr);
- }
- } catch (UnknownHostException e) {
- reporter.log(Activator.createErrorStatus(
- "Could not correct the local host address",
- e));
- }
- commonPrefPage.getSSHHostAddr().setAddress(hostAddr);
-
- reporter.logInfo("Set Host Address to " + vmnet + " endpoint address " + hostAddr);
-
- if (isNAT) {
- try {
- targetAddr = Inet4Address.getByAddress(new byte[] { 127, 0, 0, 1});
- } catch (UnknownHostException e) {
- // unlikely
- }
- }
- if (targetAddr == null) {
- // guess the target address
- targetAddr = VMwareUtils.convertToLikelyDHCPAddress(hostAddr);
- }
-
- if (targetAddr != null) {
- commonPrefPage.getSSHTargetAddr().setAddress(targetAddr);
-
- reporter.logInfo("Set Target Address to likely " + vmnet + " DHCP address " + targetAddr);
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "You may need to manually edit the Target Address after the VM boots, by inspecting the output of 'sudo dhclient3' or '/sbin/ifconfig'."));
-
- }
- } else {
- reporter.log(Activator.createStatus(IStatus.WARNING,
- "Could not find the address of the " + vmnet + " interface. The VMX file may be referencing a missing, misconfigured, or unknown interface."));
+ if (port == null) {
+ port = "22";
+ commonPrefPage.getSSHTargetPort().setStringValue(port);
+ reporter.logInfo("Set Target Port to " + port);
}
+
+ } catch (UnknownHostException e) {
+ // dunno!
+ reporter.log(Activator.createErrorStatus(
+ "Could not construct the local host address",
+ e));
}
-
}
}
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareSettingsPreferencePage.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -17,7 +17,7 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.widgets.Text;
-import org.maemo.esbox.internal.api.vm.ui.preferences.BaseVirtualMachinePreferencePage;
+import org.maemo.esbox.internal.api.maemosdk.ui.preferences.BaseMachinePreferencePage;
import org.maemo.esbox.internal.api.vm.ui.preferences.IVirtualMachineSettingsPreferencePage;
import org.maemo.esbox.vm.core.IVirtualMachineConfiguration;
import org.maemo.esbox.vm.vmware.IVMwareConfiguration;
@@ -36,14 +36,14 @@
private FileFieldEditor feVmxPath;
private StringFieldEditor feVMWAREExeName;
private StringFieldEditor feVMWARELaunchPattern;
- /*private*/ final BaseVirtualMachinePreferencePage vmPrefPage;
+ /*private*/ final BaseMachinePreferencePage vmPrefPage;
/**
* @param preferenceStore
* @param vmPrefPage
*
*/
- public VMwareSettingsPreferencePage(IPreferenceStore preferenceStore, BaseVirtualMachinePreferencePage vmPrefPage) {
+ public VMwareSettingsPreferencePage(IPreferenceStore preferenceStore, BaseMachinePreferencePage vmPrefPage) {
this.vmPrefPage = vmPrefPage;
setTitle("VMware Options");
setPreferenceStore(preferenceStore);
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareUtils.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareUtils.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/VMwareUtils.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -81,7 +81,7 @@
WindowsRegistry registry = WindowsRegistry.getRegistry();
if (registry != null) {
String baseKey = "SOFTWARE\\VMware, Inc.\\VMnetLib\\VMnetConfig\\vmnet";
- for (int iface = 1; iface <= 9; iface++) {
+ for (int iface = 0; iface <= 9; iface++) {
String value = registry.getLocalMachineValue(baseKey + iface, "IPSubnetAddress");
if (value != null) {
try {
Modified: trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java
===================================================================
--- trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java 2009-09-18 18:19:15 UTC (rev 2198)
+++ trunk/org.maemo.esbox.vm.vmware/src/org/maemo/esbox/internal/vm/vmware/ui/wizards/MaemoSDKVMInstallData.java 2009-09-18 18:55:31 UTC (rev 2199)
@@ -54,7 +54,7 @@
this.fileToDownload = downloadFile;
if (fileToDownload.getInstallLocation() == null && installationPath != null)
try {
- fileToDownload.setInstallLocation(new File(installationPath).toURL());
+ fileToDownload.setInstallLocation(new File(installationPath).toURI().toURL());
} catch (MalformedURLException e) {
Activator.getErrorLogger().logAndShowError(
"Cannot get location for file "
@@ -100,7 +100,7 @@
public void setInstallationPath(String installationPath) {
this.installationPath = installationPath;
try {
- fileToDownload.setInstallLocation(new File(installationPath).toURL());
+ fileToDownload.setInstallLocation(new File(installationPath).toURI().toURL());
} catch (MalformedURLException e) {
Activator.getErrorLogger().logAndShowError(
"Cannot get location for file "
More information about the Esbox-commits
mailing list