Search in sources :

Example 51 with TreeNode

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);
        }
    }
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 52 with TreeNode

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);
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)

Example 53 with TreeNode

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);
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection)

Example 54 with TreeNode

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;
}
Also used : CellEditor(org.eclipse.jface.viewers.CellEditor) ComboEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.ComboEditorValueAdapter) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TableViewerCreatorColumnNotModifiable(org.talend.commons.ui.runtime.swt.tableviewer.TableViewerCreatorColumnNotModifiable) CellEditorValueAdapter(org.talend.commons.ui.runtime.swt.tableviewer.behavior.CellEditorValueAdapter)

Example 55 with TreeNode

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);
}
Also used : AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)

Aggregations

TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)119 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)88 ArrayList (java.util.ArrayList)39 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)34 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)25 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)22 List (java.util.List)21 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)19 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)17 EList (org.eclipse.emf.common.util.EList)15 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)14 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)13 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)12 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)11 FOXTreeNode (org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode)10 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)9 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)9 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)8