Search in sources :

Example 16 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class DropContextAnalyzer method checkDropIsValid.

private boolean checkDropIsValid() {
    if (objects == null || objects.getToTransfer().isEmpty() || targetEditPart == null) {
        return false;
    }
    Object targetModel = targetEditPart.getModel();
    targetFigure = targetEditPart.getFigure().findFigureAt(dropLocation.x, dropLocation.y);
    boolean isTragetOutputNode = targetModel instanceof OutputTreeNode;
    boolean isTragetInputNode = targetModel instanceof TreeNode && !(targetModel instanceof OutputTreeNode);
    boolean isVar = targetModel instanceof VarNode;
    boolean isDropInputTree = targetModel instanceof InputXmlTree;
    boolean isDropOutputTree = targetModel instanceof OutputXmlTree;
    boolean isDropVarTable = targetModel instanceof VarTable;
    // drop expression
    if (targetFigure instanceof ExpressionFigure) {
        dropType = DropType.DROP_EXPRESSION;
        if (isTragetOutputNode) {
            // INPUT => OUTPUT
            return XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
        } else if (isTragetInputNode) {
            // INPUT => INPUT ,can't dnd in the same tree
            boolean isValid = checkDropInputValid(targetModel);
            if (isValid) {
                isValid = XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
            }
            return isValid;
        }
        return true;
    } else // drop tree filter
    if (targetFigure instanceof FilterTextArea) {
        dropType = DropType.DROP_FILTER;
        return true;
    } else {
        if (objects.getType() == TransferdType.INPUT) {
            if (isTragetOutputNode) {
                return checkDropOutputDocChildValid(targetModel);
            } else if (isVar || isDropVarTable) {
                dropType = DropType.DROP_INSERT_VAR;
                return true;
            } else if (isDropInputTree) {
                dropType = DropType.DROP_INSERT_INPUT;
                return checkDropInputValid(targetModel);
            } else if (isDropOutputTree) {
                dropType = DropType.DROP_INSERT_OUTPUT;
                return true;
            }
        } else if (objects.getType() == TransferdType.VAR) {
            if (isTragetOutputNode) {
                return checkDropOutputDocChildValid(targetModel);
            } else if (isDropOutputTree) {
                dropType = DropType.DROP_INSERT_OUTPUT;
                return true;
            }
        }
    }
    return false;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) FilterTextArea(org.talend.designer.gefabstractmap.figures.treesettings.FilterTextArea) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 17 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class ProblemsAnalyser method checkInputLoopTablesProblem.

private void checkInputLoopTablesProblem(OutputXmlTree outputTree, InputXmlTree mainInputTree) {
    if (mainInputTree == null) {
        return;
    }
    if (mainInputTree.isMultiLoops()) {
        if (!XmlMapUtil.hasDocument(outputTree)) {
            if (outputTree.getInputLoopNodesTables().isEmpty() || outputTree.getInputLoopNodesTables().get(0).getInputloopnodes().isEmpty()) {
                String message = outputTree.getName() + " have no source loop";
                addProblem(outputTree, new Problem(null, message, ProblemStatus.ERROR));
            }
        } else {
            List<TreeNode> loopNodes = new ArrayList<TreeNode>();
            XmlMapUtil.getChildLoops(loopNodes, outputTree.getNodes());
            if (!loopNodes.isEmpty()) {
                for (TreeNode node : loopNodes) {
                    InputLoopNodesTable inutLoopTable = ((OutputTreeNode) node).getInputLoopNodesTable();
                    if (inutLoopTable == null || inutLoopTable.getInputloopnodes().isEmpty()) {
                        String message = node.getXpath() + " have no source loop";
                        addProblem(outputTree, new Problem(null, message, ProblemStatus.ERROR));
                    }
                }
            }
        }
    }
}
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) Problem(org.talend.core.model.process.Problem) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 18 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method detachConnectionsSouce.

public static void detachConnectionsSouce(AbstractNode treeNode, XmlMapData mapData, boolean detachChildren) {
    for (Connection connection : treeNode.getIncomingConnections()) {
        AbstractNode source = connection.getSource();
        if (source.getOutgoingConnections().contains(connection)) {
            source.getOutgoingConnections().remove(connection);
            mapData.getConnections().remove(connection);
        }
    }
    treeNode.getIncomingConnections().clear();
    if (treeNode instanceof OutputTreeNode) {
        OutputTreeNode outputTreeNode = (OutputTreeNode) treeNode;
        if (!XmlMapUtil.isExpressionEditable(outputTreeNode) && outputTreeNode.isAggregate()) {
            outputTreeNode.setAggregate(false);
        }
        if (detachChildren && !outputTreeNode.getChildren().isEmpty()) {
            for (int i = 0; i < outputTreeNode.getChildren().size(); i++) {
                TreeNode child = outputTreeNode.getChildren().get(i);
                detachConnectionsSouce(child, mapData);
            }
        }
    }
    treeNode.setExpression("");
}
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) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) INodeConnection(org.talend.designer.xmlmap.model.emf.xmlmap.INodeConnection) IConnection(org.talend.designer.xmlmap.model.emf.xmlmap.IConnection) Connection(org.talend.designer.xmlmap.model.emf.xmlmap.Connection) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 19 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method cleanGroup.

public static boolean cleanGroup(List<? extends TreeNode> nodes) {
    boolean changed = false;
    for (TreeNode obj : nodes) {
        OutputTreeNode outputNode = (OutputTreeNode) obj;
        if (outputNode.isGroup()) {
            outputNode.setGroup(false);
            changed = true;
        }
        if (!outputNode.getChildren().isEmpty()) {
            changed = cleanGroup(outputNode.getChildren()) || changed;
        }
    }
    return changed;
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 20 with OutputTreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode in project tdi-studio-se by Talend.

the class XmlMapUtil method removeLoopTableForOutput.

public static void removeLoopTableForOutput(OutputXmlTree outputTable2Check, List<TreeNode> reomvedOutputLoops, boolean isMainMultiloops) {
    for (TreeNode reomved : reomvedOutputLoops) {
        OutputTreeNode outputNode = (OutputTreeNode) reomved;
        if (outputNode.getInputLoopNodesTable() != null) {
            outputTable2Check.getInputLoopNodesTables().remove(outputNode.getInputLoopNodesTable());
            outputNode.setInputLoopNodesTable(null);
        }
    }
    // incase there are no used InputLoopNodesTables from previous version
    if (!isMainMultiloops) {
        outputTable2Check.getInputLoopNodesTables().clear();
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Aggregations

OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)57 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)42 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)27 ArrayList (java.util.ArrayList)16 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)16 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)15 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)15 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)11 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)11 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)10 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)9 List (java.util.List)8 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)8 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)8 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)8 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)7 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)7 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5