Search in sources :

Example 1 with IMapperLink

use of org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink in project tdi-studio-se by Talend.

the class LinkManager method addLink.

/**
     * DOC amaumont Comment method "addLink".
     * 
     * @param link
     */
public void addLink(IMapperLink link) {
    currentNumberLinks++;
    // System.out.println(currentNumberLinks + " links");
    links.add(link);
    ITableEntry sourceITableEntry = link.getPointLinkDescriptor1().getTableEntry();
    ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
    Set<ITableEntry> sourcesDataMapTableEntries = getSourcesCollection(targetITableEntry);
    sourcesDataMapTableEntries.add(sourceITableEntry);
    Set<IMapperLink> graphicalLinksFromTarget = getGraphicalLinksFromTarget(targetITableEntry);
    registerLevelForNewLink(link, graphicalLinksFromTarget);
    graphicalLinksFromTarget.add(link);
    Set<IMapperLink> graphicalLinksFromSources = getGraphicalLinksFromSource(sourceITableEntry);
    graphicalLinksFromSources.add(link);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)

Example 2 with IMapperLink

use of org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink in project tdi-studio-se by Talend.

the class LinkManager method removeLink.

/**
     * DOC amaumont Comment method "addLink".
     * 
     * @param link
     */
public void removeLink(IMapperLink link) {
    currentNumberLinks--;
    links.remove(link);
    ITableEntry sourceITableEntry = link.getPointLinkDescriptor1().getTableEntry();
    ITableEntry targetITableEntry = link.getPointLinkDescriptor2().getTableEntry();
    Set<ITableEntry> targetDataMapTableEntries = getSourcesCollection(targetITableEntry);
    targetDataMapTableEntries.remove(sourceITableEntry);
    Set<IMapperLink> sourceGraphicalLinks = getGraphicalLinksFromSource(sourceITableEntry);
    sourceGraphicalLinks.remove(link);
    getGraphicalLinksFromTarget(targetITableEntry).remove(link);
    unregisterLevelForRemovedLink(link, sourceGraphicalLinks);
}
Also used : ITableEntry(org.talend.designer.abstractmap.model.tableentry.ITableEntry) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)

Example 3 with IMapperLink

use of org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink in project tdi-studio-se by Talend.

the class MapperManager method changeDependentEntriesState.

/**
     * 
     * DOC amaumont Comment method "changeDependentEntriesState".
     * 
     * @param link
     * @param currentEntry
     * @param removedLink
     */
private void changeDependentEntriesState(IMapperLink link, ITableEntry currentEntry, boolean removedLink) {
    Set<IMapperLink> dependentLinks = linkManager.getLinksFromSource(currentEntry);
    dependentLinks.addAll(linkManager.getLinksFromTarget(currentEntry));
    boolean hasSelectedLink = false;
    for (IMapperLink dependentLink : dependentLinks) {
        if (dependentLink.getState() == LinkState.SELECTED && dependentLink != link) {
            hasSelectedLink = true;
            break;
        }
    }
    if (!hasSelectedLink && link.getState() == LinkState.UNSELECTED || removedLink) {
        uiManager.setEntryState(this, EntryState.NONE, currentEntry);
    } else {
        uiManager.setEntryState(this, EntryState.HIGHLIGHT, currentEntry);
    }
}
Also used : IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)

Example 4 with IMapperLink

use of org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink in project tdi-studio-se by Talend.

the class LinkManager method registerLevelForNewLink.

/**
     * DOC amaumont Comment method "registerLevelForNewLink".
     * 
     * @param link
     * @param graphicalLinksFromTarget
     */
public 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.getParent().getClass() == targetEntry.getParent().getClass();
    if (hasSameZone) {
        boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
        boolean isVarTarget = targetEntry instanceof VarTableEntry;
        List<List<IMapperLink>> leveledLinks = null;
        if (isInputTarget) {
            leveledLinks = getInputLinksForLevels();
        }
        if (isVarTarget) {
            leveledLinks = getVarLinksForLevels();
        }
        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 || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
                        hasAlreadyInputTarget = true;
                    }
                    if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
                        hasAlreadyVarTarget = true;
                    }
                    if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
                        linksFromLevelsList.add(link);
                        link.setLevel(indexOfLeveledLink + 1);
                        break;
                    }
                }
            }
        }
        if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
            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) VarTableEntry(org.talend.designer.mapper.model.tableentry.VarTableEntry) InputTable(org.talend.designer.mapper.model.table.InputTable) IMapperLink(org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink) List(java.util.List) ArrayList(java.util.ArrayList) InputColumnTableEntry(org.talend.designer.mapper.model.tableentry.InputColumnTableEntry) ExpressionFilterEntry(org.talend.designer.mapper.model.tableentry.ExpressionFilterEntry) GlobalMapEntry(org.talend.designer.mapper.model.tableentry.GlobalMapEntry)

Example 5 with IMapperLink

use of org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink 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)

Aggregations

IMapperLink (org.talend.designer.abstractmap.ui.visualmap.link.IMapperLink)17 ITableEntry (org.talend.designer.abstractmap.model.tableentry.ITableEntry)11 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)5 List (java.util.List)4 InputColumnTableEntry (org.talend.designer.mapper.model.tableentry.InputColumnTableEntry)4 InputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry)3 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)3 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)3 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)3 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)3 Color (org.eclipse.swt.graphics.Color)2 Point (org.eclipse.swt.graphics.Point)2 TableItem (org.eclipse.swt.widgets.TableItem)2 ECodeLanguage (org.talend.core.language.ECodeLanguage)2 AbstractUIManager (org.talend.designer.abstractmap.managers.AbstractUIManager)2 LinkState (org.talend.designer.abstractmap.ui.visualmap.link.LinkState)2 PointLinkDescriptor (org.talend.designer.abstractmap.ui.visualmap.link.PointLinkDescriptor)2 OutputColumnTableEntry (org.talend.designer.dbmap.model.tableentry.OutputColumnTableEntry)2 DataMapTableView (org.talend.designer.dbmap.ui.visualmap.table.DataMapTableView)2