private void initTargetRuntime() { if (_ifpwc == null) { _settingsGroup .getTargetRuntimesList() .setSelection(new StructuredSelection(SwitchYardSettingsGroup.NULL_RUNTIME)); _settingsGroup.getTargetRuntimesList().getControl().setEnabled(false); return; } else { _ifpwc = SharedWorkingCopyManager.getWorkingCopy(_ifp); } final IRuntime runtime = _ifpwc.getPrimaryRuntime(); if (runtime == null) { _settingsGroup .getTargetRuntimesList() .setSelection(new StructuredSelection(SwitchYardSettingsGroup.NULL_RUNTIME)); } else { for (IRuntimeComponent component : runtime.getRuntimeComponents()) { if (SWITCHYARD_RUNTIME_ID.equals(component.getRuntimeComponentType().getId()) || FSW_RUNTIME_ID.equals(component.getRuntimeComponentType().getId())) { _settingsGroup .getTargetRuntimesList() .setSelection(new StructuredSelection(component), true); } } } _settingsGroup .getTargetRuntimesList() .addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.isEmpty() || selection.getFirstElement() == SwitchYardSettingsGroup.NULL_RUNTIME) { final IRuntime primaryRuntime = _ifpwc.getPrimaryRuntime(); if (primaryRuntime != null && !_configuredRuntimes.contains(primaryRuntime)) { _ifpwc.removeTargetedRuntime(primaryRuntime); } else if (primaryRuntime != null && selection.getFirstElement() == SwitchYardSettingsGroup.NULL_RUNTIME) { _ifpwc.removeTargetedRuntime(primaryRuntime); } _settingsGroup .getIntegrationVersionsList() .setSelection(new StructuredSelection("")); _switchYardProject.setIntegrationVersion(null); _settingsGroup.getKieVersionsList().setSelection(new StructuredSelection("")); _switchYardProject.setKieVersion(null); } else { final IRuntimeComponent component = (IRuntimeComponent) selection.getFirstElement(); final IRuntime runtime = component.getRuntime(); if (!_ifpwc.isTargeted( runtime)) { // if it's already targeted, we don't need to add it _ifpwc.addTargetedRuntime(runtime); } _ifpwc.setPrimaryRuntime(runtime); if (component != null) { ArtifactVersion intVersion = _settingsGroup.getIntegVersion(component); if (intVersion != null) { _settingsGroup .getIntegrationVersionsList() .setSelection(new StructuredSelection(intVersion)); } else { _settingsGroup .getIntegrationVersionsList() .setSelection(new StructuredSelection("")); } ArtifactVersion kieVersion = _settingsGroup.getKieVersion(component); if (kieVersion != null) { _settingsGroup .getKieVersionsList() .setSelection(new StructuredSelection(kieVersion)); } else { _settingsGroup.getKieVersionsList().setSelection(new StructuredSelection("")); } } } } }); }