Search in sources :

Example 31 with AbstractInOutTree

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

the class DropContextAnalyzer method checkDropInputValid.

private boolean checkDropInputValid(Object target) {
    if (objects.getType() == TransferdType.INPUT) {
        for (Object obj : objects.getToTransfer()) {
            TreeNodeEditPart part = (TreeNodeEditPart) obj;
            AbstractInOutTree srouceTree = XmlMapUtil.getAbstractInOutTree((TreeNode) part.getModel());
            AbstractInOutTree targetTree = null;
            if (target instanceof InputXmlTree) {
                targetTree = (InputXmlTree) target;
            } else {
                targetTree = XmlMapUtil.getAbstractInOutTree((TreeNode) target);
            }
            if (srouceTree == targetTree) {
                return false;
            }
            if (srouceTree.eContainer() instanceof XmlMapData) {
                XmlMapData mapdata = ((XmlMapData) srouceTree.eContainer());
                int indexSource = mapdata.getInputTrees().indexOf(srouceTree);
                int indexTarget = mapdata.getInputTrees().indexOf(targetTree);
                if (indexTarget < indexSource) {
                    return false;
                }
            }
        }
    }
    return true;
}
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) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData) Point(org.eclipse.draw2d.geometry.Point)

Example 32 with AbstractInOutTree

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

the class CreateNodeAndConnectionCommand method doUpdate.

// private void createInputLoopTable(TreeNode sourceNode, OutputTreeNode targetOutputNode) {
// EditPartViewer viewer = targetEditPart.getViewer();
// if (viewer instanceof XmlMapGraphicViewer) {
// InputLoopTableUtil.addSourceLoopToInputLoopTable(sourceNode, targetOutputNode, ((XmlMapGraphicViewer) viewer)
// .getMapperManager().getMainInputTree());
// }
// }
private void doUpdate(AbstractNode sourceNode) {
    if (targetEditPart instanceof OutputTreeNodeEditPart) {
        OutputTreeNode targetOutputNode = (OutputTreeNode) ((OutputTreeNodeEditPart) targetEditPart).getModel();
        String expression = targetOutputNode.getExpression();
        if (sourceNode instanceof TreeNode) {
            if (expression == null) {
                expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            } else {
                expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            }
        } else if (sourceNode instanceof VarNode) {
            String tableName = "Var";
            if (sourceNode.eContainer() instanceof VarTable) {
                tableName = ((VarTable) sourceNode.eContainer()).getName();
            }
            if (expression == null) {
                expression = tableName + "." + sourceNode.getName();
            } else {
                expression = expression + " " + tableName + "." + sourceNode.getName();
            }
        }
        // if (sourceNode instanceof TreeNode) {
        // createInputLoopTable((TreeNode) sourceNode, targetOutputNode);
        // }
        targetOutputNode.setExpression(expression);
        Connection conn = XmlmapFactory.eINSTANCE.createConnection();
        conn.setSource(sourceNode);
        conn.setTarget(targetOutputNode);
        targetOutputNode.getIncomingConnections().add(conn);
        sourceNode.getOutgoingConnections().add(conn);
        if (xmlMapData != null) {
            xmlMapData.getConnections().add(conn);
        }
    } else if (targetEditPart instanceof TreeNodeEditPart) {
        /* for lookup connections */
        if (sourceNode instanceof TreeNode) {
            TreeNode targetTreeNode = (TreeNode) targetEditPart.getModel();
            String expression = targetTreeNode.getExpression();
            if (expression == null) {
                expression = "";
            }
            expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            targetTreeNode.setExpression(expression);
            LookupConnection conn = XmlmapFactory.eINSTANCE.createLookupConnection();
            conn.setSource(sourceNode);
            conn.setTarget(targetTreeNode);
            targetTreeNode.getLookupIncomingConnections().add(conn);
            ((TreeNode) sourceNode).getLookupOutgoingConnections().add(conn);
            if (xmlMapData != null) {
                xmlMapData.getConnections().add(conn);
            }
        }
    } else if (targetEditPart instanceof VarNodeEditPart) {
        /* for varTable drag drop */
        if (sourceNode instanceof TreeNode) {
            VarNodeEditPart targetPart = (VarNodeEditPart) targetEditPart;
            VarNode targetNode = (VarNode) targetPart.getModel();
            String expression = targetNode.getExpression();
            if (expression == null) {
                expression = "";
            }
            expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            if (targetNode.getName() == null || "".equals(targetNode.getName())) {
                String findUniqueVarColumnName = XmlMapUtil.findUniqueVarColumnName(sourceNode.getName(), xmlMapData.getVarTables().get(0));
                targetNode.setName(findUniqueVarColumnName);
            }
            targetNode.setExpression(expression.trim());
            targetNode.setType(sourceNode.getType());
            Connection conn = XmlmapFactory.eINSTANCE.createConnection();
            conn.setSource(sourceNode);
            conn.setTarget(targetNode);
            targetNode.getIncomingConnections().add(conn);
            sourceNode.getOutgoingConnections().add(conn);
            if (xmlMapData != null) {
                xmlMapData.getConnections().add(conn);
            }
        }
    } else if (targetEditPart instanceof InputXmlTreeEditPart || targetEditPart instanceof OutputXmlTreeEditPart) {
        AbstractInOutTree treeModel = (AbstractInOutTree) targetEditPart.getModel();
        String expression = treeModel.getExpressionFilter();
        if (sourceNode instanceof TreeNode) {
            if (expression == null) {
                expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            } else {
                expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            }
        } else if (sourceNode instanceof VarNode) {
            String tableName = "Var";
            if (sourceNode.eContainer() instanceof VarTable) {
                tableName = ((VarTable) sourceNode.eContainer()).getName();
            }
            if (expression == null) {
                expression = tableName + "." + sourceNode.getName();
            } else {
                expression = expression + " " + tableName + "." + sourceNode.getName();
            }
        }
        treeModel.setExpressionFilter(expression);
        FilterConnection connection = XmlmapFactory.eINSTANCE.createFilterConnection();
        connection.setSource(sourceNode);
        connection.setTarget(treeModel);
        treeModel.getFilterIncomingConnections().add(connection);
        sourceNode.getFilterOutGoingConnections().add(connection);
        xmlMapData.getConnections().add(connection);
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) 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) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) InputXmlTreeEditPart(org.talend.designer.xmlmap.parts.InputXmlTreeEditPart) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)

Aggregations

AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)32 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)25 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)23 ArrayList (java.util.ArrayList)15 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)13 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)12 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)8 List (java.util.List)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)6 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)6 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)5 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)4 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)4 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)4 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)3 XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)3 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)3 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)3 OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)3 Iterator (java.util.Iterator)2