- if (selection != null && selection instanceof TreeSelection)
- {
- TreeSelection treeSelection = (TreeSelection) selection;
- Object[] selectedElements = treeSelection.toArray();
- for (Object selectedElement : selectedElements)
- {
- IDebugTarget debugTarget;
- if (selectedElement instanceof IDebugElement)
- debugTarget = ((IDebugElement) selectedElement).getDebugTarget();
- else if (selectedElement instanceof ILaunch)
- debugTarget = ((ILaunch) selectedElement).getDebugTarget();
- else
- continue;
- if (!(debugTarget instanceof MachineDebugTarget))
- continue;
- if (debugTarget.isTerminated())
- continue;
- // we found a selected MachineDebugTarget
- if (this.debugTarget != debugTarget)
- bindToDebugTarget((MachineDebugTarget) debugTarget);
- return;
- }
- }
- // we didn't find a selected MachineDebugTarget
- // call binToDebugTarget even if this.debugTarget==null
- bindToDebugTarget(null);
+ // call binToDebugTarget even if we didn't find a selected MachineDebugTarget
+ bindToDebugTarget(newTarget.orElse(null));