/**
   * {@inheritDoc}
   *
   * @see org.teiid.designer.ui.preferences.IGeneralPreferencePageContributor#performOk()
   */
  @Override
  public boolean performOk() {
    // persist value
    String versionString = versionCombo.getText();
    ITeiidServerVersion version = new TeiidServerVersion(versionString);

    if (versionString.equals(getPreferenceStoreValue(false))) return true; // same value - no change

    if (ModelerCore.getTeiidServerManager().getDefaultServer() == null && hasOpenEditors()) {
      // No default teiid instance and open editors so modelling diagrams may close which could
      // surprise!
      boolean changeVersion =
          MessageDialog.openQuestion(
              shell,
              Util.getStringOrKey(PREFIX + "versionChangeQuestionTitle"), // $NON-NLS-1$
              Util.getStringOrKey(PREFIX + "versionChangeQuestionMessage")); // $NON-NLS-1$

      if (!changeVersion) return false;
    }

    try {
      for (ITeiidServerVersion regVersion :
          TeiidRuntimeRegistry.getInstance().getSupportedVersions()) {
        if (regVersion.compareTo(version)) {
          getPreferenceStore().setValue(PREF_ID, regVersion.toString());
          return true;
        }
      }
    } catch (Exception ex) {
      Util.log(ex);
    }

    boolean changeVersion =
        MessageDialog.openQuestion(
            shell,
            Util.getStringOrKey(PREFIX + "unsupportedVersionQuestionTitle"), // $NON-NLS-1$
            Util.getStringOrKey(PREFIX + "unsupportedVersionQuestionMesssage")); // $NON-NLS-1$
    if (changeVersion) {
      getPreferenceStore().setValue(PREF_ID, version.toString());
      return true;
    }

    // No runtime client to support default version
    return false;
  }
  /**
   * Updates the radio buttons selection states corresponding to the new value.
   *
   * @param value the new value
   */
  private void update(String value) {

    List<String> items = new ArrayList<String>();

    try {
      Collection<ITeiidServerVersion> registeredServerVersions =
          TeiidRuntimeRegistry.getInstance().getSupportedVersions();
      items = TeiidServerVersion.orderVersions(registeredServerVersions, true);
    } catch (Exception ex) {
      Util.log(ex);
      for (VersionID versionId : VersionID.values()) {
        items.add(versionId.toString());
      }
    }

    versionCombo.setItems(items.toArray(new String[0]));
    versionCombo.setText(value);
  }