/** Get the Image for the SingleElementSymbol */ private Image getImageForSymbol(SingleElementSymbol seSymbol) { Image result = null; // If symbol is AliasSymbol, get underlying symbol if (seSymbol != null && seSymbol instanceof AliasSymbol) { seSymbol = ((AliasSymbol) seSymbol).getSymbol(); } // ElementSymbol if ((seSymbol instanceof ElementSymbol)) { result = UiPlugin.getDefault().getImage(SYMBOL_ICON); // AggregateSymbol } else if (seSymbol instanceof AggregateSymbol) { result = UiPlugin.getDefault().getImage(FUNCTION_ICON); // ExpressionSymbol } else if (seSymbol instanceof ExpressionSymbol) { Expression expression = ((ExpressionSymbol) seSymbol).getExpression(); if (expression != null && expression instanceof Constant) { result = UiPlugin.getDefault().getImage(CONSTANT_ICON); } else if (expression != null && expression instanceof Function) { result = UiPlugin.getDefault().getImage(FUNCTION_ICON); } } // Undefined if (result == null) { result = UiPlugin.getDefault().getImage(UNDEFINED_ICON); } return result; }
@Override public Image getImage(Object element) { Image image = null; Binding binding = (Binding) element; switch (this.columnNumber) { // | status icon | Source SQL Symbol | <-- | Matched Datatype | -> | Target Column case 0: { // Status Column if (!bindingListInput.isReconciled(binding)) { String warning = bindingListInput.getWarningText(binding); boolean hasWarning = warning.length() > 0; if (hasWarning) { image = UiPlugin.getDefault().getImage(PluginConstants.Images.WARNING_BUTTON_ICON); } } } break; case 1: // SOURCE SQL COLUMN break; case 2: { // CONVERT LEFT ARROW if (bindingListInput.isReconciled(binding) || !bindingListInput.canConvert(binding)) { image = UiPlugin.getDefault() .getImage(PluginConstants.Images.ARROW_LEFT_BUTTON_DISABLED_ICON); } else { image = UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_LEFT_BUTTON_ICON); } } break; case 3: { // MATCHED TYPE // image = UiPlugin.getDefault().getImage(PluginConstants.Images.ELIPSIS_ICON); } break; case 4: { // CHANGE RIGHT ARROW if (bindingListInput.isReconciled(binding)) { image = UiPlugin.getDefault() .getImage(PluginConstants.Images.ARROW_RIGHT_BUTTON_DISABLED_ICON); } else { image = UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_RIGHT_BUTTON_ICON); } } break; case 5: // SOURCE SQL COLUMN break; default: break; } return image; }
/** * @param info the import data (cannot be <code>null</code>) * @since 4.0 */ public TeiidMetadataImportFormatPage(TeiidMetadataImportInfo info) { super(TeiidMetadataImportFormatPage.class.getSimpleName(), TITLE); CoreArgCheck.isNotNull(info, "info"); // $NON-NLS-1$ this.info = info; setImageDescriptor(UiPlugin.getDefault().getImageDescriptor(Images.IMPORT_TEIID_METADATA)); }
@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(); } }
/** Create the tableViewer Panel */ @SuppressWarnings("unused") private void createTableViewerPanel(Composite theParent) { Composite tablePanel = new Composite(theParent, SWT.NONE); // Set the layout GridLayout gridLayout = new GridLayout(); tablePanel.setLayout(gridLayout); GridData gridData = new GridData(GridData.FILL_BOTH); tablePanel.setLayoutData(gridData); // Add header panel HEADER_PANEL: { Composite headerPanel = WidgetFactory.createPanel(tablePanel); // ------------------------------ // Set layout for the Composite // ------------------------------ headerPanel.setLayout(new GridLayout()); ((GridLayout) headerPanel.getLayout()).numColumns = 3; headerPanel.setLayoutData(new GridData(GridData.FILL_BOTH)); ((GridData) headerPanel.getLayoutData()).minimumHeight = 80; // ((GridData)headerPanel.getLayoutData()).grabExcessHorizontalSpace = true; // Add general info/instructions text box { helpText = new Text(headerPanel, SWT.WRAP | SWT.READ_ONLY); helpText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW)); helpText.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE)); helpText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); ((GridData) helpText.getLayoutData()).horizontalSpan = 3; ((GridData) helpText.getLayoutData()).heightHint = 40; ((GridData) helpText.getLayoutData()).widthHint = 360; helpText.setText(Messages.datatypeReconciler_helpText); } // Add button bar containing: // [CHANGE ALL COLUMN DATATYPES] - or - [CONVERT ALL SQL SYMBOLS] this.convertAllSqlSymbolsButton = WidgetFactory.createButton( headerPanel, Messages.datatypeReconciler_convertAllSqlSymbolsLabel); this.convertAllSqlSymbolsButton.setToolTipText( Messages.datatypeReconciler_convertAllSqlSymbolsTooltip); this.convertAllSqlSymbolsButton.setImage( UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_LEFT_ICON)); this.convertAllSqlSymbolsButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { changeAllColumnDatatypesButtonPressed(); } }); WidgetFactory.createLabel(headerPanel, " - or - "); // $NON-NLS-1$ this.changeAllColumnDatatypesButton = WidgetFactory.createButton( headerPanel, Messages.datatypeReconciler_convertAllColumnDatatypesLabel); this.changeAllColumnDatatypesButton.setToolTipText( Messages.datatypeReconciler_convertAllColumnDatatypesTooltip); this.changeAllColumnDatatypesButton.setImage( UiPlugin.getDefault().getImage(PluginConstants.Images.ARROW_RIGHT_ICON)); this.changeAllColumnDatatypesButton.setEnabled(false); this.changeAllColumnDatatypesButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { changeAllColumnDatatypesPressed(); } }); } BINDING_TABLE: { table = new Table(tablePanel, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); table.setHeaderVisible(true); table.setLinesVisible(true); table.setLayout(new TableLayout()); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.heightHint = 200; table.setLayoutData(gd); this.bindingTableViewer = new TableViewer(table); this.bindingTableViewer.getControl().setLayoutData(gd); this.bindingContentProvider = new BindingContentProvider(); // create columns // | status icon | Source SQL Symbol | <-- | Matched Datatype | -> | Target Column // COLUMN 0 : STATUS ICON Button TableViewerColumn column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT); column.setLabelProvider(new TheBindingColumnLabelProvider(0)); column.getColumn().setText(getSpaces(8)); column.getColumn().pack(); // COLUMN 1 : SOURCE SQL SYMBOL column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT); column.getColumn().setText(Messages.datatypeReconciler_sourceSqlSymbolLabel + getSpaces(100)); column.setLabelProvider(new TheBindingColumnLabelProvider(1)); column.getColumn().pack(); // COLUMN 2 : LEFT ARROW Button column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT); column.getColumn().setText(getSpaces(8)); column.setLabelProvider(new TheBindingColumnLabelProvider(2)); column.setEditingSupport(new ConvertSymbolEditingSupport(this.bindingTableViewer)); column.getColumn().pack(); column.getColumn().setToolTipText(Messages.datatypeReconciler_convertSourceDatatypeTooltip); // COLUMN 3 : Matched datatype column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT); column.getColumn().setText(Messages.datatypeReconciler_matchedTypeLabel + getSpaces(60)); column.setLabelProvider(new TheBindingColumnLabelProvider(3)); column.setEditingSupport(new ChangeProposedDatatypeEditingSupport(this.bindingTableViewer)); column.getColumn().pack(); column.getColumn().setToolTipText(Messages.datatypeReconciler_matchedDatatypeTooltip); // COLUMN 4 : RIGHT ARROW Button column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT); column.getColumn().setText(getSpaces(8)); column.setLabelProvider(new TheBindingColumnLabelProvider(4)); column.setEditingSupport(new ChangeDatatypeEditingSupport(this.bindingTableViewer)); column.getColumn().pack(); column.getColumn().setToolTipText(Messages.datatypeReconciler_changeTargetDatatypeTooltip); // COLUMN 5 : Target Column Definition column = new TableViewerColumn(this.bindingTableViewer, SWT.LEFT); column.getColumn().setText(Messages.datatypeReconciler_targetColumnLabel + getSpaces(25)); column.setLabelProvider(new TheBindingColumnLabelProvider(5)); column.getColumn().pack(); bindingTableViewer.setUseHashlookup(true); bindingTableViewer.setContentProvider(this.bindingContentProvider); bindingTableViewer.setInput(this.bindingListInput); updateRowColors(); } // Panel to display selection details SELECTION_STATUS_PANEL: { Composite selectionPanel = WidgetFactory.createGroup( tablePanel, Messages.datatypeReconciler_selectionPanelInfoLabel); // ------------------------------ // Set layout for the Composite // ------------------------------ selectionPanel.setLayout(new GridLayout()); ((GridLayout) selectionPanel.getLayout()).numColumns = 2; selectionPanel.setLayoutData(new GridData(GridData.FILL_BOTH)); ((GridData) selectionPanel.getLayoutData()).minimumHeight = 80; // Label selectedSymbolLabel = new Label(selectionPanel, SWT.NONE); // selectedSymbolLabel.setText("Selected Symbol: "); symbolConversionLabel = new Label(selectionPanel, SWT.NONE); symbolConversionLabel.setText(PluginConstants.EMPTY_STRING); symbolConversionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); symbolConversionLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE)); Label messageLabel = new Label(selectionPanel, SWT.NONE); // messageLabel.setText("Status: "); symbolWarningLabel = new Label(selectionPanel, SWT.NONE); symbolWarningLabel.setText(PluginConstants.EMPTY_STRING); symbolWarningLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); symbolWarningLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE)); } }