use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class InputLoopTableUtil method removeSourceLoopFromInputLoopTable.
public static void removeSourceLoopFromInputLoopTable(List removedConnections, OutputTreeNode outputNode, InputXmlTree mainInputTree) {
if (mainInputTree == null || !mainInputTree.isMultiLoops()) {
return;
}
List<TreeNode> neededSource = new ArrayList<TreeNode>();
InputLoopNodesTable inputLoopNodesTable = null;
AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(outputNode);
List<InputLoopNodesTable> listInputLoopNodesTablesEntry = ((OutputXmlTree) abstractTree).getInputLoopNodesTables();
if (!XmlMapUtil.hasDocument(abstractTree)) {
if (listInputLoopNodesTablesEntry.size() == 0) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
} else if (listInputLoopNodesTablesEntry != null && listInputLoopNodesTablesEntry.size() == 1) {
inputLoopNodesTable = listInputLoopNodesTablesEntry.get(0);
}
OutputXmlTree outputTree = (OutputXmlTree) abstractTree;
getSourceLoop(neededSource, outputTree.getNodes(), mainInputTree);
} else {
OutputTreeNode loopParentOutputTreeNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode(outputNode);
if (loopParentOutputTreeNode != null) {
inputLoopNodesTable = loopParentOutputTreeNode.getInputLoopNodesTable();
if (inputLoopNodesTable == null) {
inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
loopParentOutputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
}
List<OutputTreeNode> nodes = new ArrayList<OutputTreeNode>();
nodes.add(loopParentOutputTreeNode);
getSourceLoop(neededSource, nodes, mainInputTree);
}
}
if (inputLoopNodesTable == null) {
return;
}
List<TreeNode> sourceLoopsToRemove = new ArrayList<TreeNode>();
for (Object object : removedConnections) {
if (object instanceof Connection) {
Connection connection = (Connection) object;
if (connection.getSource() instanceof TreeNode) {
getSourceLoopsFromConnectionSource((TreeNode) connection.getSource(), sourceLoopsToRemove, mainInputTree);
}
}
}
for (TreeNode sourceToRemove : sourceLoopsToRemove) {
if (!neededSource.contains(sourceToRemove)) {
inputLoopNodesTable.getInputloopnodes().remove(sourceToRemove);
}
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class InputLoopTableUtil method getSourceLoopsFromConnectionSource.
private static void getSourceLoopsFromConnectionSource(TreeNode connectionSource, List<TreeNode> soruceLoops, InputXmlTree mainInputTree) {
InputXmlTree inputTree = (InputXmlTree) XmlMapUtil.getAbstractInOutTree(connectionSource);
TreeNode loopParentTreeNode = null;
if (inputTree == mainInputTree) {
loopParentTreeNode = XmlMapUtil.getLoopParentNode(connectionSource);
if (loopParentTreeNode != null) {
soruceLoops.add(loopParentTreeNode);
}
} else {
getLoopSourceFromLookupNode(connectionSource, mainInputTree, soruceLoops);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class MapDataHelper method rebuildModelInputs.
public void rebuildModelInputs(List<? extends IConnection> inputConn, XmlMapData mapData) {
// remove no used input tree
if (mapData.getInputTrees().size() != inputConn.size()) {
List treesToRemove = new ArrayList();
for (InputXmlTree inputTree : mapData.getInputTrees()) {
boolean found = false;
for (IConnection connection : inputConn) {
if (inputTree.getName().equals(connection.getName())) {
found = true;
}
}
if (!found) {
for (TreeNode treeNode : inputTree.getNodes()) {
XmlMapUtil.detachNodeConnections(treeNode, mapData, true);
}
treesToRemove.add(inputTree);
XmlMapUtil.detachFilterSource(inputTree, mapData);
}
}
mapData.getInputTrees().removeAll(treesToRemove);
}
for (IConnection inData : inputConn) {
String name = inData.getName();
InputXmlTree inputTree = null;
for (InputXmlTree in : mapData.getInputTrees()) {
if (in.getName() != null && in.getName().equals(name)) {
inputTree = in;
break;
}
}
if (inputTree == null) {
inputTree = XmlmapFactory.eINSTANCE.createInputXmlTree();
inputTree.setName(name);
inputTree.setLookup(EConnectionType.FLOW_MAIN != inData.getLineStyle());
mapData.getInputTrees().add(inputTree.isLookup() ? mapData.getInputTrees().size() : 0, inputTree);
} else {
inputTree.setLookup(EConnectionType.FLOW_MAIN != inData.getLineStyle());
}
if (inputTree.getLookupMode() == null) {
inputTree.setLookupMode(XML_MAP_LOOKUP_MODE.LOAD_ONCE.toString());
}
if (inputTree.getMatchingMode() == null) {
inputTree.setMatchingMode(XML_MAP_MATCHING_MODE.ALL_ROWS.toString());
}
rebuildInputTree(inputTree, inData.getMetadataTable(), mapData);
}
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class XmlMapLabelProvider method getColumnText.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
String returnValue = null;
TableViewerCreatorColumnNotModifiable column = (TableViewerCreatorColumnNotModifiable) this.tableViewerCreator.getColumns().get(columnIndex);
if (column.getLabelProvider() != null) {
returnValue = column.getLabelProvider().getLabel(element);
}
if (returnValue == null) {
if (column.getDisplayedValue() != null || column.getDefaultDisplayedValue() != null || column.getBeanPropertyAccessors() == null) {
String defaultValue = column.getDefaultDisplayedValue();
String imposedDisplayedValue = column.getDisplayedValue();
if (imposedDisplayedValue != null) {
returnValue = imposedDisplayedValue;
} else if (defaultValue == null) {
//$NON-NLS-1$
returnValue = "";
} else {
returnValue = defaultValue;
}
} else {
Object value = AccessorUtils.get(element, column);
CellEditor cellEditor = column.getCellEditor();
CellEditorValueAdapter retrieverValue = column.getCellEditorValueAdapter();
// add for bug TDI-21505
if (value != null && column.getCellEditorValueAdapter() != null && column.getCellEditorValueAdapter() instanceof ComboEditorValueAdapter) {
Object returnObject = column.getCellEditorValueAdapter().getCellEditorTypedValue(column.getCellEditor(), value);
if ("-1".equals(returnObject + "")) {
return "";
}
}
if (cellEditor != null && retrieverValue != null && value != null) {
if (element instanceof TreeNode) {
if ((((TreeNode) element).getNodeType()).equals(NodeType.ELEMENT)) {
returnValue = retrieverValue.getColumnText(cellEditor, element, value);
}
}
} else if (value != null) {
returnValue = String.valueOf(value);
} else {
//$NON-NLS-1$
returnValue = "";
}
}
// return the type
if (columnIndex == 3) {
if (element instanceof TreeNode) {
TreeNode node = (TreeNode) element;
returnValue = TalendTypeConvert.convertToJavaType(node.getType());
}
}
}
return returnValue;
}
use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode in project tdi-studio-se by Talend.
the class MapperManager method refreshStyledTextEditor.
public void refreshStyledTextEditor(TableEntityPart nodePart) {
if (nodePart == null) {
mapperUI.getTabFolderEditors().getStyledTextHandler().setTextWithoutNotifyListeners("");
mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEnabled(false);
mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEditable(false);
return;
}
AbstractNode node = (AbstractNode) nodePart.getModel();
if (node instanceof TreeNode) {
if (!((TreeNode) node).getChildren().isEmpty()) {
mapperUI.getTabFolderEditors().getStyledTextHandler().setTextWithoutNotifyListeners("");
mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEnabled(false);
mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEditable(false);
return;
}
}
String expression = node.getExpression();
if (expression == null) {
expression = "";
}
mapperUI.getTabFolderEditors().getStyledTextHandler().setTextWithoutNotifyListeners(expression);
mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEnabled(true);
mapperUI.getTabFolderEditors().getStyledTextHandler().getStyledText().setEditable(true);
mapperUI.getTabFolderEditors().getStyledTextHandler().setSelectedNodePart(nodePart);
}
Aggregations