Search in sources :

Example 1 with JavaTypeComboValueAdapter

use of org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter in project tdi-studio-se by Talend.

the class VarsDataMapTableView method initColumnsOfTableColumns.

@Override
public void initColumnsOfTableColumns(final TableViewerCreator tableViewerCreatorForColumns) {
    ECodeLanguage codeLanguage = LanguageProvider.getCurrentLanguage().getCodeLanguage();
    TableViewerCreatorColumn column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.expression"));
    column.setId(DataMapTableView.ID_EXPRESSION_COLUMN);
    expressionCellEditor = createExpressionCellEditor(tableViewerCreatorForColumns, column, new Zone[] { Zone.INPUTS, Zone.VARS }, false);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {

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

        public void set(VarTableEntry bean, String value) {
            bean.setExpression(value);
            mapperManager.getProblemsManager().checkProblemsForTableEntry(bean, true);
        }
    });
    column.setModifiable(!mapperManager.componentIsReadOnly());
    //$NON-NLS-1$
    column.setDefaultInternalValue("");
    if (codeLanguage == ECodeLanguage.JAVA) {
        column.setWeight(40);
    } else {
        column.setWeight(COLUMN_EXPRESSION_SIZE_WEIGHT);
    }
    if (codeLanguage == ECodeLanguage.JAVA) {
        String[] arrayTalendTypes = new String[0];
        try {
            arrayTalendTypes = MetadataTalendType.getTalendTypesLabels();
            arrayTalendTypes = this.talendTypeFilter.filter(arrayTalendTypes);
        } catch (NoClassDefFoundError e) {
            // shouln't be happend
            // e.printStackTrace();
            ExceptionHandler.process(e);
        } catch (ExceptionInInitializerError e) {
            // shouln't be happend
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
        IBeanPropertyAccessors<VarTableEntry, Boolean> nullableAccessors = new IBeanPropertyAccessors<VarTableEntry, Boolean>() {

            public Boolean get(VarTableEntry bean) {
                return bean.isNullable() ? Boolean.TRUE : Boolean.FALSE;
            }

            public void set(VarTableEntry bean, Boolean value) {
                bean.setNullable(value.booleanValue());
            }
        };
        CellEditorValueAdapter comboValueAdapter = new JavaTypeComboValueAdapter(JavaTypesManager.getDefaultJavaType(), nullableAccessors, this.talendTypeFilter);
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.type"));
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {

            public String get(VarTableEntry bean) {
                return bean.getType();
            }

            public void set(VarTableEntry bean, String value) {
                bean.setType(value);
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        column.setWeight(18);
        column.setCellEditor(new ComboBoxCellEditor(tableViewerCreatorForColumns.getTable(), arrayTalendTypes), comboValueAdapter);
        column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
        //$NON-NLS-1$
        column.setTitle("Nullable");
        column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, Boolean>() {

            public Boolean get(VarTableEntry bean) {
                return bean.isNullable();
            }

            public void set(VarTableEntry bean, Boolean value) {
                bean.setNullable(value);
                mapperManager.getProblemsManager().checkProblemsForAllEntriesOfAllTables(true);
            }
        });
        column.setModifiable(!mapperManager.componentIsReadOnly());
        column.setWidth(WindowSystem.isWIN32() ? 12 : 20);
        //$NON-NLS-1$
        column.setDisplayedValue("");
        column.setResizable(false);
        CheckboxTableEditorContent checkboxTableEditorContent = new CheckboxTableEditorContent();
        //$NON-NLS-1$
        String nullable = Messages.getString("VarsDataMapTableView.nullable");
        checkboxTableEditorContent.setToolTipText(nullable);
        column.setTableEditorContent(checkboxTableEditorContent);
        column.setToolTipHeader(nullable);
    }
    column = new TableViewerCreatorColumn(tableViewerCreatorForColumns);
    //$NON-NLS-1$
    column.setTitle(Messages.getString("VarsDataMapTableView.columnTitle.variable"));
    column.setId(DataMapTableView.ID_NAME_COLUMN);
    column.setBeanPropertyAccessors(new IBeanPropertyAccessors<VarTableEntry, String>() {

        public String get(VarTableEntry bean) {
            return bean.getName();
        }

        public void set(VarTableEntry bean, String value) {
            bean.setName(value);
        }
    });
    column.setModifiable(!mapperManager.componentIsReadOnly());
    if (codeLanguage == ECodeLanguage.JAVA) {
        column.setWeight(25);
    } else {
        column.setWeight(COLUMN_NAME_SIZE_WEIGHT);
    }
    final TextCellEditor cellEditor = new TextCellEditor(tableViewerCreatorForColumns.getTable());
    cellEditor.addListener(new DialogErrorForCellEditorListener(cellEditor, column) {

        @Override
        public void newValidValueTyped(int itemIndex, Object previousValue, Object newValue, CELL_EDITOR_STATE state) {
            if (state == CELL_EDITOR_STATE.APPLYING) {
                ModifiedObjectInfo modifiedObjectInfo = tableViewerCreatorForColumns.getModifiedObjectInfo();
                String originalValue = (String) modifiedObjectInfo.getOriginalPropertyBeanValue();
                Object currentModifiedBean = modifiedObjectInfo.getCurrentModifiedBean();
                mapperManager.getUiManager().processColumnNameChanged(originalValue.toString(), newValue.toString(), VarsDataMapTableView.this, (ITableEntry) currentModifiedBean);
            }
        }

        @Override
        public String validateValue(String newValue, int beanPosition) {
            return ((VarsTable) getDataMapTable()).validateColumnName(newValue, beanPosition);
        }
    });
    column.setCellEditor(cellEditor);
}
Also used : CELL_EDITOR_STATE(org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE) Zone(org.talend.designer.mapper.ui.visualmap.zone.Zone) DialogErrorForCellEditorListener(org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) CheckboxTableEditorContent(org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent) JavaTypeComboValueAdapter(org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ExtendedTextCellEditor(org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor) ModifiedObjectInfo(org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo) TableViewerCreatorColumn(org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 2 with JavaTypeComboValueAdapter

use of org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter in project tdi-studio-se by Talend.

the class AutoConversionTypesEditorView method configureTypeColumn.

private void configureTypeColumn(TableViewerCreator<AutoConversionType> tableViewerCreator, TableViewerCreatorColumn column) {
    IBeanPropertyAccessors<AutoConversionType, Boolean> nullableAccessors = new IBeanPropertyAccessors<AutoConversionType, Boolean>() {

        @Override
        public Boolean get(AutoConversionType bean) {
            return Boolean.TRUE;
        }

        @Override
        public void set(AutoConversionType bean, Boolean value) {
            return;
        }
    };
    CellEditorValueAdapter comboValueAdapter = new JavaTypeComboValueAdapter(JavaTypesManager.getDefaultJavaType(), nullableAccessors);
    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);
    }
    ComboBoxCellEditor typeComboEditor = new ComboBoxCellEditor(tableViewerCreator.getTable(), arrayTalendTypes, SWT.READ_ONLY);
    CCombo typeCombo = (CCombo) typeComboEditor.getControl();
    typeCombo.setEditable(false);
    column.setCellEditor(typeComboEditor, comboValueAdapter);
}
Also used : AutoConversionType(org.talend.core.model.metadata.types.AutoConversionType) CCombo(org.eclipse.swt.custom.CCombo) JavaTypeComboValueAdapter(org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) IBeanPropertyAccessors(org.talend.commons.utils.data.bean.IBeanPropertyAccessors)

Aggregations

ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)2 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)2 IBeanPropertyAccessors (org.talend.commons.utils.data.bean.IBeanPropertyAccessors)2 JavaTypeComboValueAdapter (org.talend.core.ui.metadata.celleditor.JavaTypeComboValueAdapter)2 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 CCombo (org.eclipse.swt.custom.CCombo)1 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 ModifiedObjectInfo (org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo)1 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1 DialogErrorForCellEditorListener (org.talend.commons.ui.swt.tableviewer.celleditor.DialogErrorForCellEditorListener)1 CheckboxTableEditorContent (org.talend.commons.ui.swt.tableviewer.tableeditor.CheckboxTableEditorContent)1 ECodeLanguage (org.talend.core.language.ECodeLanguage)1 AutoConversionType (org.talend.core.model.metadata.types.AutoConversionType)1 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)1 VarTableEntry (org.talend.designer.mapper.model.tableentry.VarTableEntry)1 Zone (org.talend.designer.mapper.ui.visualmap.zone.Zone)1