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);
}
}
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);
}
}
}
}
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++) {
}
}
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);
}
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);
}
Aggregations