org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java
changeset 458 5ff93668b08c
parent 457 f1087591ff71
child 460 c0bff5ed874c
--- a/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java	Wed Jul 28 15:43:33 2010 -0700
+++ b/org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java	Thu Jul 29 10:00:34 2010 -0700
@@ -159,6 +159,7 @@
 
     protected void doBluetoothSearch(final Button search) {
         try {
+            final ISelection sel = list.getSelection();
             getContainer().run(true, true, new IRunnableWithProgress() {
                 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                     monitor.beginTask("Searching for Bluetooth devices", IProgressMonitor.UNKNOWN);
@@ -171,12 +172,17 @@
                     search.getDisplay().asyncExec(new Runnable() {
                         public void run() {
                             list.setInput(context.getDeploymentTargets());
-                            ISelection selection = list.getSelection();
-                            if (selection.isEmpty()) {
-                                selectDeploymentTarget(null);
+                            if (!sel.isEmpty()) {
+                                list.setSelection(sel);
+                                selectDeploymentTarget((DeploymentTargetWrapper) ((IStructuredSelection)sel).getFirstElement());
                             } else {
-                                selectDeploymentTarget((DeploymentTargetWrapper) ((IStructuredSelection) selection)
-                                        .getFirstElement());
+                                DeploymentTargetWrapper[] deploymentTargets = context.getDeploymentTargets();
+                                if (deploymentTargets.length == 0) {
+                                    selectDeploymentTarget(null);
+                                } else {
+                                    list.setSelection(new StructuredSelection(deploymentTargets[0]));
+                                    selectDeploymentTarget(deploymentTargets[0]);
+                                }
                             }
                         }
                     });