@Override
  public void dispose() {
    if (_switchYardProject != null) {
      _switchYardProject.dispose();
    }

    if (_ifpwc != null) {
      SharedWorkingCopyManager.releaseWorkingCopy(_ifp);
    }

    super.dispose();
  }
  private void initControls() {

    _switchYardProject =
        SwitchYardProjectManager.instance().getSwitchYardProject(getProject()).createWorkingCopy();
    if (_switchYardProject.needsLoading()) {
      BusyIndicator.showWhile(
          getShell().getDisplay(),
          new Runnable() {
            @Override
            public void run() {
              _switchYardProject.load(new NullProgressMonitor());
            }
          });
    }
    try {
      _ifp = ProjectFacetsManager.create(_switchYardProject.getProject());
      _ifpwc = SharedWorkingCopyManager.getWorkingCopy(_ifp);
      _configuredRuntimes = _ifpwc.getTargetedRuntimes();
    } catch (CoreException e) {
      Activator.getDefault().getLog().log(e.getStatus());
    }

    _settingsGroup.setProject(_ifpwc);

    initTargetRuntime();
    initRuntimeVersion();
    initComponentsTable();

    _useSwitchYardDependencyBOMCheckbox.setSelection(pomUsesSwitchYardBOM());

    String errmsg = null;
    if (!pomDefinesSwitchYardVersion()) {
      _settingsGroup.setRuntimeControlEnablement(false);
    } else if (pomUsesSwitchYardBOM()) {
      if (!isSelectedRuntimeVersion2OrHigher()) {
        // only valid versions with BOM dependency support are 2.0+
        errmsg = Messages.ProjectConfigurationWizardPage_errorMessage_bomRequiresVersion2;
      }
    } else if (!isSelectedConfigurationVersionOkForRuntime()) {
      String configVersion = getMajorMinorFromVersion(getRuntimeVersion().toString());
      errmsg =
          "The Configuration Version must be "
              + configVersion
              + " or lower to work with Library Version "
              + getRuntimeVersion().toString()
              + ".";
    }
    setErrorMessage(errmsg);
    getContainer().updateMessage();
  }
  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(""));
                    }
                  }
                }
              }
            });
  }