Search in sources :

Example 6 with Type3Field

use of org.talend.designer.scd.model.Type3Field in project tdi-studio-se by Talend.

the class Type3Section method createContents.

@Override
protected void createContents(Composite composite) {
    inputColumns = scdManager.getInputColumnNames();
    outputColumns = scdManager.getOutputColumnNames();
    tableViewer = new TableViewer(composite, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    table = tableViewer.getTable();
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.grabExcessHorizontalSpace = true;
    gd.grabExcessVerticalSpace = true;
    table.setLayoutData(gd);
    TableViewerColumn currentColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    currentColumn.getColumn().setText(CURRENT_HEADER);
    currentColumn.getColumn().setWidth(200);
    // currentColumn.setEditingSupport(new Type3EditingSupport(tableViewer, 0));
    TableViewerColumn previousColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    previousColumn.getColumn().setText(PREVIOUS_HEADER);
    previousColumn.getColumn().setWidth(200);
    previousColumn.setEditingSupport(new Type3EditingSupport(tableViewer, 1));
    tableViewer.setLabelProvider(new TableLabelProvider());
    tableViewer.setContentProvider(new ContentProvider());
    table.addListener(SWT.EraseItem, new Listener() {

        public void handleEvent(Event event) {
            event.detail &= ~SWT.HOT;
            GC gc = event.gc;
            TableItem item = (TableItem) event.item;
            Color background = gc.getBackground();
            Type3Field field = (Type3Field) item.getData();
            if (StringUtils.isNotEmpty(field.getPreviousValue())) {
                gc.setBackground(table.getDisplay().getSystemColor(SWT.COLOR_WHITE));
            } else {
                gc.setBackground(ERROR_COLOR);
                event.detail &= ~SWT.SELECTED;
            }
            gc.fillRectangle(table.getClientArea());
            gc.setBackground(background);
            event.detail &= ~SWT.BACKGROUND;
        }
    });
}
Also used : Listener(org.eclipse.swt.widgets.Listener) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) TableItem(org.eclipse.swt.widgets.TableItem) Color(org.eclipse.swt.graphics.Color) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) GC(org.eclipse.swt.graphics.GC) Type3Field(org.talend.designer.scd.model.Type3Field) TableViewer(org.eclipse.jface.viewers.TableViewer) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Aggregations

Type3Field (org.talend.designer.scd.model.Type3Field)6 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)2 Map (java.util.Map)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 IElementParameter (org.talend.core.model.process.IElementParameter)2 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)1 ITableLabelProvider (org.eclipse.jface.viewers.ITableLabelProvider)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 Color (org.eclipse.swt.graphics.Color)1 GC (org.eclipse.swt.graphics.GC)1 Point (org.eclipse.swt.graphics.Point)1 GridData (org.eclipse.swt.layout.GridData)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 TableItem (org.eclipse.swt.widgets.TableItem)1 ECodeLanguage (org.talend.core.language.ECodeLanguage)1