コード例 #1
0
 /**
  * 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 < bindingList.size(); i++) {
     Binding originalBinding = originalBindingList.get(i);
     Binding binding = bindingList.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());
     }
   }
 }
コード例 #2
0
 /** 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 = bindingList.get(i);
     if (!binding.isBound() || binding.hasTypeConflict()) {
       item.setBackground(colorManager.getColor(ColorManager.UNBOUND_BACKGROUND));
     } else {
       item.setBackground(colorManager.getColor(ColorManager.BOUND_BACKGROUND));
     }
   }
 }
コード例 #3
0
 /**
  * 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 < bindingList.size(); i++) {
     Binding binding = bindingList.get(i);
     if (binding.hasAttrTypeModification()) {
       result = true;
       break;
     }
   }
   return result;
 }
コード例 #4
0
 /**
  * Check whether there are any modifications to the SQL Symbols
  *
  * @return true if there are pending modifications, false if not.
  */
 public boolean hasSqlSymbolModifications() {
   boolean result = false;
   // If any of the newSymbols is non-null, there are type modifications
   for (int i = 0; i < bindingList.size(); i++) {
     Binding binding = bindingList.get(i);
     if (binding.sqlSymbolWasConverted()) {
       result = true;
       break;
     }
   }
   return result;
 }
コード例 #5
0
  /**
   * Create the Datatype BindingList from the supplied BindingList
   *
   * @param bindings the bindingList from which to init the arrays
   */
  private BindingList createBindingList(BindingList bindings) {
    BindingList newBindingList = new BindingList();

    if (bindings != null && bindings.size() > 0) {
      // Set the array values from the supplied bindingList
      for (int i = 0; i < bindings.size(); i++) {
        Binding binding = bindings.get(i);
        newBindingList.add(binding);
      }
    }

    return newBindingList;
  }
コード例 #6
0
  /** handler for convertAll Attributes Button pressed */
  void convertAllAttrsPressed() {
    for (int i = 0; i < bindingList.size(); i++) {
      Binding binding = bindingList.get(i);
      if (binding.hasTypeConflict() && binding.hasAttributeConversion()) {
        // accept the default attribute type
        binding.acceptAttributeConversion();
      }
    }

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

    selectFirstBinding();
  }
コード例 #7
0
  /** handler for convertAll Sql Button pressed */
  void convertAllSqlPressed() {
    for (int i = 0; i < bindingList.size(); i++) {
      Binding binding = bindingList.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();
      }
    }

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

    selectFirstBinding();
  }
コード例 #8
0
 /** Select the first Binding in the binding list */
 private void selectFirstBinding() {
   if (bindingList.size() > 0) {
     Binding binding = bindingList.get(0);
     tableViewer.setSelection(new StructuredSelection(binding), true);
   }
 }
コード例 #9
0
  /** Create the Panel for resolving sql symbols */
  private void createResolveSqlPanel(Composite parent) {
    Group newGroup = WidgetFactory.createGroup(parent, RESOLVE_SQL_GROUP_NAME);
    GridLayout gridLayout = new GridLayout();
    newGroup.setLayout(gridLayout);
    gridLayout.numColumns = 3;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 5;
    gridLayout.marginBottom = 5;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    newGroup.setLayoutData(gridData);
    newGroup.setText(SQL_SYMBOL_TXT);
    // SQL Symbol Label
    // --------------------------------------
    sqlSymbolLabel =
        WidgetFactory.createLabel(newGroup, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // $NON-NLS-1$
    GridData gdSSL =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 3, 1);
    sqlSymbolLabel.setLayoutData(gdSSL);
    sqlSymbolLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));

    // Symbol RuntimeType Label
    // --------------------------------------
    Label rtTypeLabel = WidgetFactory.createLabel(newGroup, RUNTIME_TYPE_TXT);
    GridData gdRT =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 2, 1);
    rtTypeLabel.setLayoutData(gdRT);
    // WidgetFactory.createLabel(newGroup, "");

    Binding binding = bindingList.get(0);
    Object symbol = binding.getCurrentSymbol();
    String text = getLabelText(symbol);
    symbolRuntimeTypeLabel =
        WidgetFactory.createLabel(
            newGroup, text, GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);

    // Available Conversion Title Label
    // --------------------------------------
    Label cvLabel =
        WidgetFactory.createLabel(
            newGroup, GridData.HORIZONTAL_ALIGN_BEGINNING, CONVERTED_SYMBOL_TXT);
    GridData gdCV =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 2, 1);
    cvLabel.setLayoutData(gdCV);

    // Available Sql Conversion Text
    // --------------------------------------

    String convertedSymbol = binding.getSqlConversionText();
    int lossOfPrecIndex = convertedSymbol.indexOf('\n');
    String warningText = CoreStringUtil.Constants.EMPTY_STRING;
    if (lossOfPrecIndex > -1) {
      warningText = convertedSymbol.substring(lossOfPrecIndex + 1, convertedSymbol.length());
      convertedSymbol = convertedSymbol.substring(0, lossOfPrecIndex);
    }

    symbolConversionLabel =
        WidgetFactory.createLabel(newGroup, convertedSymbol, GridData.FILL_BOTH);

    symbolWarningLabel = WidgetFactory.createLabel(newGroup, warningText, GridData.FILL_BOTH);
    GridData gdWarning =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 3, 1);
    symbolWarningLabel.setLayoutData(gdWarning);

    // Conversion Buttons Panel
    // --------------------------------------

    // Create the changeSelectedSql Button
    this.convertSelectedSqlButton =
        WidgetFactory.createButton(
            newGroup, CONVERT_SELECTED_SQL_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertSelectedSqlButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertSelectedSqlPressed();
          }
        });

    // Create the changeAllSql Button
    this.convertAllSqlButton =
        WidgetFactory.createButton(
            newGroup, CONVERT_ALL_SQL_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertAllSqlButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertAllSqlPressed();
          }
        });
    sqlGroup = newGroup;
  }
コード例 #10
0
  private void createResolveAttributePanel(Composite parent) {
    if (this.targetLocked) {
      attrGroup = WidgetFactory.createGroup(parent, RESOLVE_ATTR_GROUP_LOCKED_NAME);
    } else {
      attrGroup = WidgetFactory.createGroup(parent, RESOLVE_ATTR_GROUP_NAME);
    }
    GridLayout gridLayout = new GridLayout();
    attrGroup.setLayout(gridLayout);
    gridLayout.numColumns = 4;
    gridLayout.marginHeight = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginLeft = 5;
    gridLayout.marginBottom = 5;
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    attrGroup.setLayoutData(gridData);

    Binding binding = bindingList.get(0);
    Object attr = binding.getAttribute();
    // Attribute Datatype Label
    EObject datatype = null;
    attr = binding.getAttribute();
    if (TransformationHelper.isSqlColumn(attr)) {
      datatype = TransformationHelper.getSqlColumnDatatype((EObject) attr);
    }
    String datatypeText = getDatatypeText(datatype);
    Image datatypeImage = getDatatypeImage(datatype);

    attrGroup.setText(VIRTUAL_TARGET_ATTRIBUTE_TXT);

    // --------------------------------------
    // SQL Symbol Label
    // --------------------------------------
    attributeLabel =
        WidgetFactory.createLabel(attrGroup, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"); // $NON-NLS-1$
    GridData attrGD =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_FILL, false, false, 4, 1);
    attributeLabel.setLayoutData(attrGD);
    attributeLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));

    Label rtTypeLabel = WidgetFactory.createLabel(attrGroup, RUNTIME_TYPE_TXT);
    GridData gdRT =
        new GridData(
            GridData.HORIZONTAL_ALIGN_BEGINNING,
            GridData.VERTICAL_ALIGN_BEGINNING,
            false,
            false,
            2,
            1);
    rtTypeLabel.setLayoutData(gdRT);
    WidgetFactory.createLabel(attrGroup, CoreStringUtil.Constants.EMPTY_STRING);

    // --------------------------------------
    // Attribute RuntimeType Label
    // --------------------------------------
    attrRuntimeTypeLabel =
        WidgetFactory.createLabel(
            attrGroup,
            datatypeText,
            datatypeImage,
            GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);

    // --------------------------------------
    // Attribute Type Chooser Panel
    // --------------------------------------
    // Create the changeSelectedAttribute Button
    this.convertSelectedAttrButton =
        WidgetFactory.createButton(
            attrGroup, CONVERT_SELECTED_ATTR_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertSelectedAttrButton.setEnabled(false);
    this.convertSelectedAttrButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertSelectedAttrPressed();
          }
        });

    // Create the changeAllAttributes Button
    this.convertAllAttrsButton =
        WidgetFactory.createButton(
            attrGroup, CONVERT_ALL_ATTR_BUTTON, GridData.HORIZONTAL_ALIGN_BEGINNING);
    this.convertAllAttrsButton.setEnabled(false);
    this.convertAllAttrsButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            convertAllAttrsPressed();
          }
        });

    // Create the showDatatypeDialog Button
    this.showDatatypeDialogButton =
        WidgetFactory.createButton(
            attrGroup, "Change", GridData.HORIZONTAL_ALIGN_END); // $NON-NLS-1$
    this.showDatatypeDialogButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(final SelectionEvent event) {
            showDatatypeDialogPressed();
          }
        });

    attrDatatypeLabel =
        WidgetFactory.createLabel(
            attrGroup,
            "xxxxxxxxxxxxxxxxxxxxxxx",
            datatypeImage, //$NON-NLS-1$
            GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.GRAB_HORIZONTAL);
    if (this.targetLocked) {
      this.showDatatypeDialogButton.setEnabled(false);
    } else {
      this.showDatatypeDialogButton.setEnabled(true);
    }
  }