/**
   * Update the Symbol Conversion Panel with the provided binding info
   *
   * @param binding the selected Binding
   */
  private void updateSymbolConversionPanel(Binding binding) {
    boolean canConvert = bindingListInput.canConvert(binding);

    if (canConvert) {
      symbolConversionLabel.setText(bindingListInput.getConvertedSymbol(binding));
    } else {
      symbolConversionLabel.setText(PluginConstants.EMPTY_STRING);
    }
    symbolWarningLabel.setText(bindingListInput.getWarningText(binding));

    updateSymbolConversionPanelButtons(binding);
  }
 /**
  * Accept all of the binding type modifications. This will go thru the Binding modifications and
  * make them permanent.
  */
 public void applyBindingTypeModifications() {
   // If any of the newSymbols is non-null, there are type modifications
   for (int i = 0; i < bindingListInput.getBindingList().size(); i++) {
     Binding originalBinding = originalBindingList.get(i);
     Binding binding = bindingListInput.getBindingList().get(i);
     // Change the Attribute Types if required
     if (binding.hasAttrTypeModification()) {
       originalBinding.setNewAttrDatatype(binding.getCurrentAttrDatatype());
     }
     // Set the SqlSymbol on the original Binding if required
     if (binding.sqlSymbolWasConverted()) {
       originalBinding.setNewSymbol(binding.getCurrentSymbol());
     }
   }
 }
  /** Initialize the panel. */
  private void init() {
    // ------------------------------
    // Set layout for the SashForm
    // ------------------------------
    GridLayout gridLayout = new GridLayout();
    this.setLayout(gridLayout);
    gridLayout.numColumns = 1;
    gridLayout.marginLeft = 20;
    GridData gridData = new GridData(GridData.FILL_BOTH);
    this.setLayoutData(gridData);

    // Init the symbol arrays from bindings
    this.bindingListInput = new BindingTableInput(createBindingList(originalBindingList));

    // ----------------------------------
    // Create the Table Viewer Panel
    // ----------------------------------
    createTableViewerPanel(this);

    // Initialize the message area at the top of the dialog
    datatypeReconcilerDialog.setTitle(Messages.datatypeReconciler_statusTitle);
    updateMessageArea();

    // Listen for TableSelection from the Tables
    bindingTableViewer.addSelectionChangedListener(this);
    selectFirstTypeConflict();
    bindingListInput.datatypeChanged();
  }
 /** Select the first Binding in the binding list which has a type conflict */
 private void selectFirstTypeConflict() {
   Binding nextSelection = bindingListInput.getBindingList().getFirstTypeConflict();
   if (nextSelection != null) {
     bindingTableViewer.setSelection(new StructuredSelection(nextSelection), true);
   } else {
     selectFirstBinding();
   }
 }
  /** handler for convert Selected Attribute Button pressed */
  void convertSelectedAttrPressed() {
    // Get the selected binding - table only allows single select
    Binding binding = getSelectedBinding();
    // Set datatype on the binding
    binding.setNewAttrDatatype(bindingListInput.getTargetDatatype(binding));

    // Update the AttrConversion Panel
    updateAttributeConversionPanel(binding);

    bindingListInput.datatypeChanged();

    // Refresh
    bindingTableViewer.refresh(true);
    updateRowColors();
    updateMessageArea();

    selectBinding(binding);
  }
  /** handler for convertAll Attributes Button pressed */
  void changeAllColumnDatatypesPressed() {
    for (int i = 0; i < bindingListInput.getBindingList().size(); i++) {
      Binding binding = bindingListInput.getBindingList().get(i);
      if (binding.hasTypeConflict() && binding.hasAttributeConversion()) {
        // accept the default attribute type
        binding.acceptAttributeConversion();
      }
    }

    bindingListInput.datatypeChanged();

    // Refresh
    bindingTableViewer.refresh(true);
    updateRowColors();
    updateMessageArea();

    selectFirstBinding();
  }
  /** Update the Symbol Conversion Panel button enabled states. */
  private void updateSymbolConversionPanelButtons(Binding binding) {
    // ------------------------------------------
    // Set the ConvertAll Button Enabled State
    // ------------------------------------------
    // If any binding has conflict and can convert then enable

    // Set ConvertAll Enabled State
    convertAllSqlSymbolsButton.setEnabled(bindingListInput.hasConflictsAndCanConvert());
  }
  /** handler for convertAll Sql Button pressed */
  void changeAllColumnDatatypesButtonPressed() {
    for (int i = 0; i < bindingListInput.getBindingList().size(); i++) {
      Binding binding = bindingListInput.getBindingList().get(i);
      // If there is a type conflict, and available conversion, use it
      if (binding.hasTypeConflict() && binding.canConvertSqlSymbol()) {
        // accept the available Sql Conversion
        binding.acceptSqlConversion();
      }
    }

    bindingListInput.datatypeChanged();

    // Refresh
    bindingTableViewer.refresh(true);
    updateRowColors();
    updateMessageArea();

    selectFirstBinding();
  }
 /**
  * Check whether there are any modifications to the target attribute types
  *
  * @return true if there are pending modifications, false if not.
  */
 public boolean hasAttributeTypeModifications() {
   boolean result = false;
   // If any of the newSymbols is non-null, there are type modifications
   for (int i = 0; i < bindingListInput.getBindingList().size(); i++) {
     Binding binding = bindingListInput.getBindingList().get(i);
     if (binding.hasAttrTypeModification()) {
       result = true;
       break;
     }
   }
   return result;
 }
 /** update Row background colors, based on binding and type conflict status. */
 public void updateRowColors() {
   int rows = table.getItemCount();
   for (int i = 0; i < rows; i++) {
     TableItem item = table.getItem(i);
     Binding binding = bindingListInput.getBindingList().get(i);
     if (!binding.isBound() || binding.hasTypeConflict()) {
       item.setBackground(colorManager.getColor(ColorManager.UNBOUND_BACKGROUND));
     } else {
       item.setBackground(colorManager.getColor(ColorManager.BOUND_BACKGROUND));
     }
   }
 }
  /** Update the Attribute Conversion Panel button enabled states. */
  private void updateAttributeConversionPanelButtons(Binding binding) {
    // ------------------------------------------
    // Set the ConvertAll Button Enabled State
    // ------------------------------------------
    // Enable ConvertAll Button if any Binding has Conflict and target group not locked
    boolean enableConvertAll = false;

    // Enable ConvertAll Button if any Binding has Conflict
    boolean hasTypeConflict = bindingListInput.getBindingList().hasTypeConflict();
    if (hasTypeConflict && !this.targetLocked) {
      enableConvertAll = true;
    }

    changeAllColumnDatatypesButton.setEnabled(enableConvertAll);
  }
  /** handler for convert Selected Sql Button pressed */
  void convertSelectedSqlPressed() {
    // Get the selected binding
    Binding binding = getSelectedBinding();
    // accept the available Sql Conversion
    if (binding.canConvertSqlSymbol()) {
      binding.acceptSqlConversion();
    }
    // Update the SqlConversion Panel
    updateSymbolConversionPanel(binding);

    bindingListInput.datatypeChanged();
    // Refresh table and message area
    bindingTableViewer.refresh(true);
    updateRowColors();
    updateMessageArea();

    selectBinding(binding);
  }
 /** Select the first Binding in the binding list */
 private void selectFirstBinding() {
   if (bindingListInput.getBindingList().size() > 0) {
     Binding binding = bindingListInput.getBindingList().get(0);
     bindingTableViewer.setSelection(new StructuredSelection(binding), true);
   }
 }