Bug 293684 -  Selection is lost for 'Installed JREs' when cancelling duplicate option
diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java
index 8f7961f..87fe74c 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java
@@ -376,18 +376,24 @@
             standin.setName(generateName(selectedVM.getName()));
 			EditVMInstallWizard wizard = new EditVMInstallWizard(standin, (IVMInstall[]) fVMs.toArray(new IVMInstall[fVMs.size()]));
 			WizardDialog dialog = new WizardDialog(getShell(), wizard);
-			if (dialog.open() == Window.OK) {
+			int dialogResult = dialog.open();
+			if (dialogResult == Window.OK) {
 				VMStandin result = wizard.getResult();
 				if (result != null) {
-					// add the new VM
-					fVMs.add(result);
-					fVMList.refresh();
-					fVMList.setSelection(new StructuredSelection(result));
+					newEntries.add(result);
 				}
+			} else if (dialogResult == Window.CANCEL){
+				// Cancelling one wizard should cancel all subsequent wizards
+				break;
 			}
         }
-        fVMList.refresh();
-        fVMList.setSelection(new StructuredSelection(newEntries.toArray()));
+        if (newEntries.size() > 0){
+        	fVMs.addAll(newEntries);
+        	fVMList.refresh();
+        	fVMList.setSelection(new StructuredSelection(newEntries.toArray()));
+        } else {
+        	fVMList.setSelection(selection);
+        }
     }
 
 	/**