/** * Update the Symbol Conversion Panel with the provided binding info * * @param binding the selected Binding */ private void updateSymbolConversionPanel(Binding binding) { if (binding != null) { // Update the runtimeType label text and image Object symbol = binding.getCurrentSymbol(); if (symbol != null) { symbolRuntimeTypeLabel.setText(getTypeText(symbol)); sqlSymbolLabel.setImage(getLabelImage(symbol)); sqlSymbolLabel.setText(symbol.toString()); } // Update the available conversion label 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.setText(convertedSymbol); symbolWarningLabel.setText(warningText); } updateSymbolConversionPanelButtons(binding); sqlGroup.layout(); }
public void datatypeChanged() { for (Object obj : bindingList.getAll().toArray()) { Binding binding = (Binding) obj; reconciledList.put(binding, Boolean.valueOf(!binding.hasTypeConflict())); } }
/** * {@inheritDoc} * * @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object) */ @Override public String getText(Object element) { String result = PluginConstants.EMPTY_STRING; Binding binding = (Binding) element; switch (this.columnNumber) { // | status icon | Source SQL Symbol | <-- | Matched Datatype | -> | Target Column case 0: break; case 1: result = binding.getSqlSymbolText(true); break; case 2: break; case 3: Object attr = binding.getAttribute(); // Attribute Datatype Label EObject datatype = null; attr = binding.getAttribute(); if (TransformationHelper.isSqlColumn(attr)) { datatype = bindingListInput.getTargetDatatype(binding); } result = getDatatypeText(datatype); break; case 4: break; case 5: result = binding.getAttributeText(true); break; default: break; } return result; }
/** * Update the Attribute Conversion Panel with the provided binding info * * @param binding the selected Binding */ private void updateAttributeConversionPanel(Binding binding) { if (binding != null) { // get the attribute from the binding Object attr = binding.getAttribute(); // Update the runtimeType label text and image attrRuntimeTypeLabel.setText(getTypeText(binding)); attributeLabel.setImage(getLabelImage(attr)); String nameStr = getLabelText(attr); String labelStr = nameStr; attributeLabel.setText(labelStr); // Update Datatype Chooser EObject dtype = binding.getCurrentAttrDatatype(); if (dtype != null) { setChooserDatatype(dtype); } } updateAttributeConversionPanelButtons(binding); // chooserPanel.layout(); attrGroup.layout(); }
/** 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)); } } }
/** * 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; }
/** * 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; }
/** * Clear all of the binding type modifications. This will go thru the Binding modifications and * make them permanent. */ public void clearBindingTypeModifications() { // 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); // Change the Attribute Types if required if (binding.hasAttrTypeModification()) { binding.setNewAttrDatatype(null); } // Set the SqlSymbol on the original Binding if required if (binding.sqlSymbolWasConverted()) { binding.undoSqlConversion(); } } }
/** Update the Attribute Conversion Panel button enabled states. */ private void updateAttributeConversionPanelButtons(Binding binding) { // ------------------------------------------ // Set the Apply Button Enabled State // ------------------------------------------ boolean enableApply = false; if (binding != null && !this.targetLocked) { // Set the Apply button enabled state. Enable if the datatypes are different. EObject chooserDatatype = getChooserDatatype(); EObject bindingDatatype = binding.getCurrentAttrDatatype(); if (chooserDatatype != null && bindingDatatype != null) { if (!chooserDatatype.equals(bindingDatatype)) { enableApply = true; } } } // Set Apply Button enabled state convertSelectedAttrButton.setEnabled(enableApply); // ------------------------------------------ // 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 = bindingList.hasTypeConflict(); if (hasTypeConflict && !this.targetLocked) { enableConvertAll = true; } convertAllAttrsButton.setEnabled(enableConvertAll); }
/** 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(); }
/** 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(getChooserDatatype()); // Update the AttrConversion Panel updateAttributeConversionPanel(binding); // Refresh tableViewer.refresh(true); updateRowColors(); updateMessageArea(); selectBinding(binding); }
public BindingTableInput(BindingList bindingList) { super(); this.bindingList = bindingList; for (Object obj : bindingList.getAll().toArray()) { Binding binding = (Binding) obj; String runtimeType = binding.getCurrentSymbolRuntimeType(); // Get default datatype for it EObject datatype = TransformationMappingHelper.getDefaultDatatypeForRuntimeTypeName(runtimeType); targetDatatypeMap.put(binding, datatype); } datatypeChanged(); }
/** 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(); }
/** 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); // Refresh table and message area tableViewer.refresh(true); updateRowColors(); updateMessageArea(); selectBinding(binding); }
public String getConvertedSymbol(Binding binding) { String convertedSymbol = binding.getSqlConversionText(); int lossOfPrecIndex = convertedSymbol.indexOf('\n'); if (lossOfPrecIndex > -1) { convertedSymbol = convertedSymbol.substring(0, lossOfPrecIndex); } return convertedSymbol; }
/** 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(); }
public String getWarningText(Binding binding) { 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()); } return warningText; }
@Override protected void setElementValue(Object element, Object newValue) { if (element instanceof Binding && newValue instanceof Boolean) { Binding binding = (Binding) element; Object attr = binding.getAttribute(); if (TransformationHelper.isSqlColumn(attr)) { Shell shell = UiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(); DatatypeSelectionDialog dialog = new DatatypeSelectionDialog(shell, (EObject) attr, "string"); // $NON-NLS-1$ Object originalValue = bindingListInput.getTargetDatatype(binding); Object[] selection = new Object[] {originalValue}; selection[0] = originalValue; dialog.setInitialSelections(selection); int status = dialog.open(); EObject newDatatype = (EObject) originalValue; if (status == Window.OK) { Object[] result = dialog.getResult(); if (result.length == 0) { // null out the value newDatatype = null; } else { // return the selected value newDatatype = (EObject) result[0]; } } // If different datatype was chosen, set it on the binding if (newDatatype != null && !newDatatype.equals(originalValue)) { bindingListInput.setTargetDatatype(binding, newDatatype); updateAttributeConversionPanelButtons(binding); } } // chooserPanel.layout(); bindingTableViewer.refresh(true); updateRowColors(); updateMessageArea(); } }
public boolean canConvert(Binding binding) { String convertedSymbol = binding.getSqlConversionText(); int lossOfPrecIndex = convertedSymbol.indexOf('\n'); if (lossOfPrecIndex > -1) { convertedSymbol = convertedSymbol.substring(0, lossOfPrecIndex); } if (convertedSymbol.toUpperCase().startsWith("CONVERT SQL SYMBOL")) { // $NON-NLS-1$ return false; } return true; }
/** * 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()); } } }
/** handler for Datatype chooser dialog */ void showDatatypeDialogPressed() { Binding binding = getSelectedBinding(); if (binding != null) { Object attr = binding.getAttribute(); if (TransformationHelper.isSqlColumn(attr)) { Shell shell = UiPlugin.getDefault().getCurrentWorkbenchWindow().getShell(); DatatypeSelectionDialog dialog = new DatatypeSelectionDialog(shell, (EObject) attr, "string"); // $NON-NLS-1$ Object originalValue = this.chooserDatatype; Object[] selection = new Object[] {originalValue}; selection[0] = originalValue; dialog.setInitialSelections(selection); int status = dialog.open(); EObject newDatatype = (EObject) originalValue; if (status == Window.OK) { Object[] result = dialog.getResult(); if (result.length == 0) { // null out the value newDatatype = null; } else { // return the selected value newDatatype = (EObject) result[0]; } } // If different datatype was chosen, set it on the binding if (!newDatatype.equals(originalValue)) { setChooserDatatype(newDatatype); updateAttributeConversionPanelButtons(binding); } } attrGroup.layout(); // chooserPanel.layout(); tableViewer.refresh(true); updateRowColors(); updateMessageArea(); } }
/** Update the Symbol Conversion Panel button enabled states. */ private void updateSymbolConversionPanelButtons(Binding binding) { // ------------------------------------------ // Set the Apply Button Enabled State // ------------------------------------------ boolean enableApply = false; if (binding != null) { // Enable Apply Button if current Binding has Conflict enableApply = binding.canConvertSqlSymbol(); } // Set Apply Button enabled state convertSelectedSqlButton.setEnabled(enableApply); // ------------------------------------------ // Set the ConvertAll Button Enabled State // ------------------------------------------ // If any binding has conflict, enable boolean enableConvertAll = false; if (bindingList.hasTypeConflict()) { enableConvertAll = true; } // Set ConvertAll Enabled State convertAllSqlButton.setEnabled(enableConvertAll); }
public void setDatatypeOnBinding(Binding binding) { binding.setNewAttrDatatype(getTargetDatatype(binding)); datatypeChanged(); }
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); } }
/** 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; }