/** * {@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; }
@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(); } }
/** 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(); } }
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); } }