org.symbian.tools.mtw.ui/src/org/symbian/tools/mtw/internal/deployment/DeploymentTargetWizardPage.java
changeset 458 5ff93668b08c
parent 457 f1087591ff71
child 460 c0bff5ed874c
equal deleted inserted replaced
457:f1087591ff71 458:5ff93668b08c
   157         context.setLogging(logging);
   157         context.setLogging(logging);
   158     }
   158     }
   159 
   159 
   160     protected void doBluetoothSearch(final Button search) {
   160     protected void doBluetoothSearch(final Button search) {
   161         try {
   161         try {
       
   162             final ISelection sel = list.getSelection();
   162             getContainer().run(true, true, new IRunnableWithProgress() {
   163             getContainer().run(true, true, new IRunnableWithProgress() {
   163                 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
   164                 public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
   164                     monitor.beginTask("Searching for Bluetooth devices", IProgressMonitor.UNKNOWN);
   165                     monitor.beginTask("Searching for Bluetooth devices", IProgressMonitor.UNKNOWN);
   165                     try {
   166                     try {
   166                         context.doSearch(new SubProgressMonitor(monitor, 100));
   167                         context.doSearch(new SubProgressMonitor(monitor, 100));
   169                     }
   170                     }
   170                     monitor.done();
   171                     monitor.done();
   171                     search.getDisplay().asyncExec(new Runnable() {
   172                     search.getDisplay().asyncExec(new Runnable() {
   172                         public void run() {
   173                         public void run() {
   173                             list.setInput(context.getDeploymentTargets());
   174                             list.setInput(context.getDeploymentTargets());
   174                             ISelection selection = list.getSelection();
   175                             if (!sel.isEmpty()) {
   175                             if (selection.isEmpty()) {
   176                                 list.setSelection(sel);
   176                                 selectDeploymentTarget(null);
   177                                 selectDeploymentTarget((DeploymentTargetWrapper) ((IStructuredSelection)sel).getFirstElement());
   177                             } else {
   178                             } else {
   178                                 selectDeploymentTarget((DeploymentTargetWrapper) ((IStructuredSelection) selection)
   179                                 DeploymentTargetWrapper[] deploymentTargets = context.getDeploymentTargets();
   179                                         .getFirstElement());
   180                                 if (deploymentTargets.length == 0) {
       
   181                                     selectDeploymentTarget(null);
       
   182                                 } else {
       
   183                                     list.setSelection(new StructuredSelection(deploymentTargets[0]));
       
   184                                     selectDeploymentTarget(deploymentTargets[0]);
       
   185                                 }
   180                             }
   186                             }
   181                         }
   187                         }
   182                     });
   188                     });
   183                 }
   189                 }
   184             });
   190             });