Search in sources :

Example 11 with InputColumnTableEntry

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

the class LinkManager method registerLevelForNewLink.

/**
     * DOC amaumont Comment method "registerLevelForNewLink".
     * 
     * @param link
     * @param graphicalLinksFromTarget
     */
protected void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
    boolean hasAlreadyInputTarget = false;
    boolean hasAlreadyVarTarget = false;
    ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
    ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
    boolean hasSameZone = sourceEntry.getClass() == targetEntry.getClass();
    boolean isInput = targetEntry instanceof InputColumnTableEntry;
    boolean isOutput = targetEntry instanceof OutputColumnTableEntry;
    if (hasSameZone) {
        List<List<IMapperLink>> leveledLinks = null;
        if (isInput) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isOutput) {
            leveledLinks = getOutputLinksForLevels();
        }
        int lstSize = leveledLinks.size();
        for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
            List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
            if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
                IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
                ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
                ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
                if (targetEntry == targetTableEntry) {
                    if (sourceTableEntry instanceof InputColumnTableEntry && targetTableEntry instanceof InputColumnTableEntry) {
                        hasAlreadyInputTarget = true;
                    }
                    if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
                        hasAlreadyVarTarget = true;
                    }
                    if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
                        linksFromLevelsList.add(link);
                        link.setLevel(indexOfLeveledLink + 1);
                        break;
                    }
                }
            }
        }
        if (isInput && !hasAlreadyInputTarget) {
            ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
            int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
            link.setLevel(firstEmptyIndex + 1);
            list.add(link);
            if (firstEmptyIndex < leveledLinks.size()) {
                leveledLinks.set(firstEmptyIndex, list);
            } else {
                leveledLinks.add(list);
            }
        }
    }
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) ArrayList(java.util.ArrayList) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) OutputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry) List(java.util.List) ArrayList(java.util.ArrayList) VarTableEntry(org.talend.designer.dbmap.model.tableentry.VarTableEntry) InputColumnTableEntry(org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)

Aggregations

InputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)11 ArrayList (java.util.ArrayList)4 OutputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry)4 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)3 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)3 IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)3 List (java.util.List)2 Point (org.eclipse.swt.graphics.Point)2 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)2 IDbOperator (org.talend.designer.dbmap.language.operator.IDbOperator)2 IDbOperatorManager (org.talend.designer.dbmap.language.operator.IDbOperatorManager)2 InputTable (org.talend.designer.dbmap.model.table.InputTable)2 VarTableEntry (org.talend.designer.dbmap.model.tableentry.VarTableEntry)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 ICellEditorListener (org.eclipse.jface.viewers.ICellEditorListener)1 Color (org.eclipse.swt.graphics.Color)1 Combo (org.eclipse.swt.widgets.Combo)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1 ComboxCellEditorImproved (org.talend.commons.ui.runtime.swt.celleditor.ComboxCellEditorImproved)1