Search in sources :

Example 31 with TreeNode

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

the class CreateNameSpaceAction method run.

@Override
public void run() {
    String prefix = null;
    String defaultValue = null;
    NameSpaceDialog nsDialog = new NameSpaceDialog(null);
    nsDialog.setParentNode(parent);
    int status = nsDialog.open();
    if (status == nsDialog.OK) {
        defaultValue = nsDialog.getNSValue();
        if (defaultValue != null) {
            defaultValue = defaultValue.trim();
        }
        prefix = nsDialog.getPrefix().trim();
    }
    if (status == nsDialog.CANCEL) {
        return;
    }
    TreeNode createdNode = null;
    if (input) {
        createdNode = XmlmapFactory.eINSTANCE.createTreeNode();
    } else {
        createdNode = XmlmapFactory.eINSTANCE.createOutputTreeNode();
    }
    createdNode.setName(prefix);
    createdNode.setNodeType(NodeType.NAME_SPACE);
    createdNode.setDefaultValue(defaultValue);
    createdNode.setType(XmlMapUtil.DEFAULT_DATA_TYPE);
    String label = createdNode.getName();
    if (prefix == null || "".equals(prefix)) {
        label = XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX;
        createdNode.setName(XmlMapUtil.DEFAULT_NAME_SPACE_PREFIX);
    }
    String parentXpath = parent.getXpath();
    if (parent.isChoice() || parent.isSubstitution()) {
        TreeNode realPrant = XmlMapUtil.getRealParentNode(parent);
        if (realPrant != null) {
            parentXpath = realPrant.getXpath();
        }
    }
    createdNode.setXpath(XmlMapUtil.getXPath(parentXpath, label, NodeType.NAME_SPACE));
    final EList<TreeNode> children = parent.getChildren();
    int index = 0;
    for (int i = 0; i < children.size(); i++) {
        final TreeNode treeNode = children.get(i);
        if (treeNode.getNodeType() == NodeType.NAME_SPACE) {
            if (i == children.size() - 1) {
                index = children.size();
            }
            continue;
        } else {
            index = i;
            break;
        }
    }
    children.add(index, createdNode);
    // children.add(createdNode);
    // if (input) {
    // mapperManager.inputTreeSchemaBeanListModified();
    // } else {
    // mapperManager.outputTreeSchemaBeanListModified();
    // }
    Object object = graphicViewer.getEditPartRegistry().get(createdNode);
    if (object instanceof TreeNodeEditPart) {
        graphicViewer.select((TreeNodeEditPart) object);
    }
}
Also used : NameSpaceDialog(org.talend.designer.xmlmap.ui.dialog.NameSpaceDialog) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart)

Example 32 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode 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 33 with TreeNode

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

the class ProblemsAnalyser method checkTreeNodesProblem.

private void checkTreeNodesProblem(AbstractInOutTree treeToCheck, List<? extends TreeNode> treeNodes) {
    for (TreeNode treeNode : treeNodes) {
        if (XmlMapUtil.DOCUMENT.equals(treeNode.getType())) {
            if (!hasDocumentLoop(treeNode)) {
                String message = ERROR_MESSAGE_START + treeNode.getXpath();
                addProblem(treeToCheck, new Problem(null, message, ProblemStatus.ERROR));
            }
            if (!isMultipleDocType) {
                isMultipleDocType = true;
            } else {
                String message = ERROR_MESSAGE_MULTIPLE_DOC_TYPE + treeNode.getXpath();
                addProblem(treeToCheck, new Problem(null, message, ProblemStatus.ERROR));
            }
        }
    }
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Problem(org.talend.core.model.process.Problem)

Example 34 with TreeNode

use of org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode 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 35 with TreeNode

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

the class XmlMapConnectionBuilder method rebuildLinks.

public void rebuildLinks(TreeNode docNode, XmlMapData mapData) {
    if (docNode == null || mapData == null) {
        return;
    }
    AbstractInOutTree inputTree = XmlMapUtil.getAbstractInOutTree(docNode);
    int index = mapData.getInputTrees().indexOf(inputTree);
    if (index == -1) {
        index = mapData.getInputTrees().size();
    }
    List<TreeNode> nodes = new ArrayList<TreeNode>();
    nodes.add(docNode);
    rebuildLink(index, nodes, mapData);
}
Also used : OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)

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