Search in sources :

Example 6 with VarTableEntry

use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.

the class LinkManager method unregisterLevelForRemovedLink.

/**
     * DOC amaumont Comment method "unregisterLevelForRemovedLink".
     * 
     * @param link
     * @param sourceGraphicalLinks
     */
public void unregisterLevelForRemovedLink(IMapperLink link, Set<IMapperLink> sourceGraphicalLinks) {
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = link.getPointLinkDescriptor1().getTableEntry().getClass() == targetEntry.getClass();
    if (hasSameZone) {
        boolean isInput = targetEntry instanceof InputColumnTableEntry;
        boolean isVar = targetEntry instanceof VarTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInput) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isVar) {
            leveledLinks = getVarLinksForLevels();
        }
        boolean breakAll = false;
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                int lstSizeInternal = linksFromLevelsList.size();
                for (int i = 0; i < lstSizeInternal; i++) {
                    IMapperLink currentLink = linksFromLevelsList.get(i);
                    if (currentLink == link) {
                        linksFromLevelsList.remove(i);
                        if (linksFromLevelsList.size() == 0) {
                            leveledLinks.set(indexOfLeveledLink, null);
                        }
                        breakAll = true;
                        break;
                    }
                }
                // for (int i = 0; i < lstSizeInternal; i++) {
                if (breakAll) {
                    break;
                }
            }
        }
    // for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) List(java.util.List) ArrayList(java.util.ArrayList) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Example 7 with VarTableEntry

use of org.talend.designer.mapper.model.tableentry.VarTableEntry 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 8 with VarTableEntry

use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.

the class MapperManager method addNewVarEntry.

/**
     * This method is called when "addMetadataTableEditorEntry" is called (event on list of MetadataEditor) , so if you
     * want keep synchronisation between inputs/outputs DataMaps and MetadataEditors don't call this method.
     * 
     * For other uses such as add an entry to VarsTable or add entries to inputs or outputs DataMaps when
     * MetadataEditors are not active, call it.
     * 
     * @param dataMapTableView
     * @param index
     * @param type TODO
     * @param metadataColumn, can be null if added in VarsTable
     */
public VarTableEntry addNewVarEntry(DataMapTableView dataMapTableView, String name, Integer index, String type) {
    IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
    VarTableEntry dataMapTableEntry = null;
    if (dataMapTableView.getZone() == Zone.VARS) {
        dataMapTableEntry = new VarTableEntry(abstractDataMapTable, name, null, type);
    } else {
        //$NON-NLS-1$
        throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
    }
    AddVarEntryCommand varEntryCommand = new AddVarEntryCommand(tableEntriesManager, dataMapTableEntry, index);
    executeCommand(varEntryCommand);
    return dataMapTableEntry;
}
Also used : AddVarEntryCommand(org.talend.designer.mapper.ui.commands.AddVarEntryCommand) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry)

Example 9 with VarTableEntry

use of org.talend.designer.mapper.model.tableentry.VarTableEntry in project tdi-studio-se by Talend.

the class CompleteDropTargetTableListener method insertNewVarEntry.

private int insertNewVarEntry(ILanguage currentLanguage, DataMapTableView dataMapTableViewTarget, int currentIndex, ITableEntry tableEntrySource, String columnName) {
    ITableEntry dataMapTableEntry;
    String type = null;
    if (tableEntrySource.getParent() instanceof InputTable) {
        type = ((InputColumnTableEntry) tableEntrySource).getMetadataColumn().getTalendType();
    } else if (tableEntrySource.getParent() instanceof VarsTable) {
        type = ((VarTableEntry) tableEntrySource).getType();
    }
    dataMapTableEntry = getMapperManager().addNewVarEntry(dataMapTableViewTarget, columnName, currentIndex++, type);
    String location = currentLanguage.getLocation(tableEntrySource.getParentName(), tableEntrySource.getName());
    //$NON-NLS-1$
    dataMapTableEntry.setExpression(location + " ");
    return currentIndex;
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) VarsTable(org.talend.designer.mapper.model.table.VarsTable) ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)

Aggregations

VarTableEntry (org.talend.designer.mapper.model.tableentry.VarTableEntry)9 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)4 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)2 InputTable (org.talend.designer.mapper.model.table.InputTable)2 VarsTable (org.talend.designer.mapper.model.table.VarsTable)2 AbstractInOutTableEntry (org.talend.designer.mapper.model.tableentry.AbstractInOutTableEntry)2 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)2 ComboBoxCellEditor (org.eclipse.jface.viewers.ComboBoxCellEditor)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 Variable (org.talend.commons.runtime.model.expressionbuilder.Variable)1 CellEditorValueAdapter (org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)1 ExtendedTextCellEditor (org.talend.commons.ui.runtime.swt.tableviewer.celleditor.ExtendedTextCellEditor)1 ModifiedObjectInfo (org.talend.commons.ui.runtime.swt.tableviewer.data.ModifiedObjectInfo)1 TableViewerCreator (org.talend.commons.ui.swt.tableviewer.TableViewerCreator)1 CELL_EDITOR_STATE (org.talend.commons.ui.swt.tableviewer.TableViewerCreator.CELL_EDITOR_STATE)1 TableViewerCreatorColumn (org.talend.commons.ui.swt.tableviewer.TableViewerCreatorColumn)1