Search in sources :

Example 11 with TableViewerCreatorColumn

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.

the class AbstractHL7MetadataTableEditorView method configureDbTypeColumn.

/**
     * DOC amaumont Comment method "initDbTypeColumn".
     * 
     * @param tableViewerCreator
     */
private TableViewerCreatorColumn configureDbTypeColumn(final TableViewerCreator<B> tableViewerCreator) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MetadataTableEditorView.DBTypeTitle"));
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.DBTypeTitle"));
    column.setId(ID_COLUMN_DBTYPE);
    column.setBeanPropertyAccessors(getDbTypeAccessor());
    column.setModifiable(dbTypeColumnWritable && !isReadOnly());
    column.setWeight(10);
    column.setMinimumWidth(60);
    if (dbTypeColumnWritable) {
        CellEditorValueAdapter comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor();
        String[] arrayDbTypes = new String[0];
        //$NON-NLS-1$
        arrayDbTypes = MetadataTalendType.getDbTypes(getCurrentDbms());
        // System.out.println("currentDbms:" + getCurrentDbms() + "
        // dbTypes:" + arrayDbTypes);
        ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayDbTypes, SWT.READ_ONLY);
        CCombo typeCombo = (CCombo) typeComboEditor.getControl();
        typeCombo.setEditable(false);
        column.setCellEditor(typeComboEditor, comboValueAdapter);
    } else {
        column.setColorProvider(new IColumnColorProvider() {

            public Color getBackgroundColor(Object bean) {
                return READONLY_CELL_BG_COLOR;
            }

            public Color getForegroundColor(Object bean) {
                return null;
            }
        });
    }
    return column;
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) Color(org.eclipse.swt.graphics.Color) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) IColumnColorProvider(org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)

Example 12 with TableViewerCreatorColumn

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.

the class AbstractHL7MetadataTableEditorView method configureTalendTypeColumn.

/**
     * DOC amaumont Comment method "initTalendTypeColumn".
     * 
     * @param tableViewerCreator
     * @param comboValueAdapter
     * @param arrayTalendTypes
     */
private TableViewerCreatorColumn configureTalendTypeColumn(final TableViewerCreator<B> tableViewerCreator) {
    CellEditorValueAdapter comboValueAdapter = null;
    ECodeLanguage codeLanguage = LanguageManager.getCurrentLanguage();
    if (codeLanguage == ECodeLanguage.JAVA) {
        comboValueAdapter = new JavaTypeComboValueAdapter<B>(JavaTypesManager.getDefaultJavaType(), getNullableAccessor());
    } else if (codeLanguage == ECodeLanguage.PERL) {
        comboValueAdapter = CellEditorValueAdapterFactory.getComboAdapterForComboCellEditor();
    }
    String[] arrayTalendTypes = new String[0];
    try {
        arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
    } catch (NoClassDefFoundError e) {
        // shouln't be happend
        // e.printStackTrace();
        ExceptionHandler.process(e);
    } catch (ExceptionInInitializerError e) {
        // shouln't be happend
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("MetadataTableEditorView.TypleTitle"));
    //$NON-NLS-1$
    column.setToolTipHeader(Messages.getString("MetadataTableEditorView.TypleTitle"));
    column.setId(ID_COLUMN_TYPE);
    column.setBeanPropertyAccessors(getTalendTypeAccessor());
    column.setModifiable(!isReadOnly());
    column.setWeight(10);
    column.setMinimumWidth(30);
    ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayTalendTypes, SWT.READ_ONLY);
    CCombo typeCombo = (CCombo) typeComboEditor.getControl();
    typeCombo.setEditable(false);
    column.setCellEditor(typeComboEditor, comboValueAdapter);
    return column;
}
Also used : CCombo(org.eclipse.swt.custom.CCombo) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 13 with TableViewerCreatorColumn

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.

the class AutoConversionTypesEditorView method createTargetDataTypeColumn.

private TableViewerCreatorColumn createTargetDataTypeColumn(TableViewerCreator<AutoConversionType> tableViewerCreator) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("AutoConversionTypesEditor.table.column.targetDataType"));
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<AutoConversionType, String>() {

        @Override
        public String get(AutoConversionType bean) {
            return bean.getTargetDataType();
        }

        @Override
        public void set(AutoConversionType bean, String value) {
            bean.setTargetDataType(value);
        }
    });
    column.setModifiable(true);
    column.setWeight(30);
    column.setMinimumWidth(50);
    configureTypeColumn(tableViewerCreator, column);
    return column;
}
Also used : AutoConversionType(org.talend.core.model.metadata.types.AutoConversionType) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)

Example 14 with TableViewerCreatorColumn

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.

the class JsonTableView method createColumn.

@SuppressWarnings({ "rawtypes", "unchecked" })
private TableViewerCreatorColumn createColumn(TableViewerCreator<Map<String, Object>> tableViewerCreator, String title) {
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreator);
    column.setTitle(title);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<Map<String, Object>, String>() {

        @Override
        public String get(Map<String, Object> bean) {
            return (String) bean.get(title);
        }

        @Override
        public void set(Map<String, Object> bean, String value) {
            bean.put(title, value);
        }
    });
    column.setCellEditor(new TextCellEditor(tableViewerCreator.getTable()));
    column.setModifiable(!isReadOnly());
    column.setWeight(30);
    column.setMinimumWidth(50);
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    return column;
}
Also used : TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) Map(java.util.Map)

Example 15 with TableViewerCreatorColumn

use of org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn in project tdi-studio-se by Talend.

the class OutputDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    IOConnection connection = ((OutputTable) getDataMapTable()).getConnection();
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("OutputDataMapTableView.columnTitle.expression"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        public String get(OutputColumnTableEntry bean) {
            return bean.getExpression();
        }

        public void set(OutputColumnTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
            tableViewerCreatorForColumns.getTableViewer().refresh(bean);
        }
    });
    column.setModifiable(!mapperManager.componentIsReadOnly());
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    column.setTitle(DataMapTableView.COLUMN_NAME);
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

        public String get(OutputColumnTableEntry bean) {
            return bean.getMetadataColumn().getLabel();
        }

        public void set(OutputColumnTableEntry bean, String value) {
            bean.getMetadataColumn().setLabel(value);
        }
    });
    column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    if (PluginChecker.isTraceDebugPluginLoaded() && mapperManager.isTracesActive() && connection != null) {
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        column.setTitle("Preview");
        column.setId(DataMapTableView.PREVIEW_COLUMN);
        column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<OutputColumnTableEntry, String>() {

            public String get(OutputColumnTableEntry bean) {
                IMetadataColumn metadataColumn = bean.getMetadataColumn();
                if (metadataColumn != null) {
                    String label = metadataColumn.getLabel();
                    TraceData preview = bean.getPreviewValue();
                    if (preview != null && preview.getData() != null) {
                        return preview.getData().get(label);
                    }
                }
                return "";
            }

            public void set(OutputColumnTableEntry bean, String value) {
            // do nothing
            }
        });
    }
    configureCellModifier(tableViewerCreatorForColumns);
}
Also used : IOConnection(org.talend.designer.mapper.external.connection.IOConnection) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) TraceData(org.talend.core.model.process.TraceData) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Aggregations

TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)38 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)14 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)9 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)8 CCombo (org.eclipse.swt.custom.CCombo)6 Color (org.eclipse.swt.graphics.Color)6 IColumnColorProvider (org.talend.commons.ui.runtime.swt.tableviewer.behavior.IColumnColorProvider)6 TextCellEditorWithProposal (org.talend.commons.ui.swt.proposal.TextCellEditorWithProposal)6 CheckboxTableEditorContent (org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent)6 List (java.util.List)5 ColumnCellModifier (org.talend.commons.ui.runtime.swt.tableviewer.behavior.ColumnCellModifier)5 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)5 DialogErrorForCellEditorListener (org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener)5 CellEditor (org.eclipse.jface.viewers.CellEditor)4 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Image (org.eclipse.swt.graphics.Image)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3