Search in sources :

Example 11 with OutputXmlTree

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

the class ProblemsAnalyser method checkProblems.

public List<Problem> checkProblems() {
    treeAndProblems.clear();
    final XmlMapData copyOfMapData = mapperManager.getExternalData();
    if (copyOfMapData != null) {
        // check problems for InputLoopTable in output
        InputXmlTree mainInputTree = mapperManager.getMainInputTree();
        for (OutputXmlTree outputTree : copyOfMapData.getOutputTrees()) {
            checkInputLoopTablesProblem(outputTree, mainInputTree);
        }
        for (InputXmlTree inputTree : copyOfMapData.getInputTrees()) {
            isMultipleDocType = false;
            checkTreeNodesProblem(inputTree, inputTree.getNodes());
        }
        for (OutputXmlTree outputTree : copyOfMapData.getOutputTrees()) {
            isMultipleDocType = false;
            checkTreeNodesProblem(outputTree, outputTree.getNodes());
        }
    }
    return getProblems();
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 12 with OutputXmlTree

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

the class ExpressionProposalProvider method init.

public void init(Object source) {
    XmlMapData mapData = mapperManager.getExternalData();
    int index = 0;
    boolean needVar = false;
    if (source instanceof OutputTreeNode || source instanceof OutputXmlTree) {
        needVar = true;
        index = mapData.getInputTrees().size();
    } else if (source instanceof TreeNode) {
        AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree((TreeNode) source);
        index = mapData.getInputTrees().indexOf(abstractTree);
        if (index == -1) {
            index = 0;
        }
    } else if (source instanceof VarNode) {
        index = mapData.getInputTrees().size();
    } else if (source instanceof InputXmlTree) {
        index = mapData.getInputTrees().indexOf(source) + 1;
    }
    for (int i = 0; i < index; i++) {
        InputXmlTree inputTree = mapData.getInputTrees().get(i);
        getProposalsInside(inputTree.getNodes(), proposalsInside);
    }
    if (needVar) {
        getProposalsInside(mapData.getVarTables().get(0).getNodes(), proposalsInside);
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) 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) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 13 with OutputXmlTree

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

the class MapperManager method selectionChanged.

@Override
public void selectionChanged(SelectionChangedEvent event) {
    if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
        Iterator iterator = ((IStructuredSelection) event.getSelection()).iterator();
        while (iterator.hasNext()) {
            Object firstElement = iterator.next();
            if (firstElement instanceof TableEntityPart) {
                AbstractNode model = (AbstractNode) ((TableEntityPart) firstElement).getModel();
                boolean isInputMain = false;
                if (model instanceof OutputTreeNode) {
                    OutputTreeNode outputTreeNodeRoot = (OutputTreeNode) XmlMapUtil.getTreeNodeRoot((OutputTreeNode) model);
                    if (outputTreeNodeRoot != null && outputTreeNodeRoot.eContainer() instanceof OutputXmlTree) {
                        selectOutputXmlTree((OutputXmlTree) outputTreeNodeRoot.eContainer());
                        onEntitySelection((IStructuredSelection) event.getSelection(), selectedOutputTree);
                    }
                } else if (model instanceof TreeNode) {
                    TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot((TreeNode) model);
                    if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
                        selectInputXmlTree((InputXmlTree) inputTreeNodeRoot.eContainer());
                        isInputMain = !((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
                        onEntitySelection((IStructuredSelection) event.getSelection(), selectedInputTree);
                    }
                }
                if (!isInputMain) {
                    refreshStyledTextEditor((TableEntityPart) firstElement);
                } else {
                    refreshStyledTextEditor(null);
                }
                selectedFigure = ((TableEntityPart) firstElement).getFigure();
            } else if (firstElement instanceof InputXmlTreeEditPart) {
                selectInputXmlTree((InputXmlTree) ((InputXmlTreeEditPart) firstElement).getModel());
                refreshStyledTextEditor(null);
            } else if (firstElement instanceof OutputXmlTreeEditPart) {
                selectOutputXmlTree((OutputXmlTree) ((OutputXmlTreeEditPart) firstElement).getModel());
                refreshStyledTextEditor(null);
            }
        }
    }
// else {
// ExtendedTableModel<TreeSchemaTableEntry> oldModel = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor()
// .getExtendedTableModel();
// if (oldModel != null && oldModel.getBeanCount() != 0) {
// List<TreeSchemaTableEntry> treeSchemaEntrys = new ArrayList<TreeSchemaTableEntry>();
// mapperUI.getTabFolderEditors().getInputTreeSchemaEditor()
// .setExtendedControlModel(new ExtendedTableModel<TreeSchemaTableEntry>("Tree Schema", treeSchemaEntrys));
// mapperUI.getTabFolderEditors().getInputTreeSchemaEditor().getTableViewerCreator().refresh();
// }
// refreshStyledTextEditor(null);
// }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) AbstractNode(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode) 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) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)

Example 14 with OutputXmlTree

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

the class InputLoopTableUtil method addSourceLoopToInputLoopTable.

public static void addSourceLoopToInputLoopTable(TreeNode connectionSource, OutputTreeNode targetOutputNode, InputXmlTree mainInputTree) {
    // create InputLoopTable nodes only when main table is multiloops
    if (mainInputTree == null || !mainInputTree.isMultiLoops()) {
        return;
    }
    InputLoopNodesTable inputLoopNodesTable = null;
    AbstractInOutTree abstractTree = XmlMapUtil.getAbstractInOutTree(targetOutputNode);
    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);
        }
    } else {
        OutputTreeNode loopParentOutputTreeNode = (OutputTreeNode) XmlMapUtil.getLoopParentNode(targetOutputNode);
        if (loopParentOutputTreeNode != null) {
            inputLoopNodesTable = loopParentOutputTreeNode.getInputLoopNodesTable();
            if (inputLoopNodesTable == null) {
                inputLoopNodesTable = XmlmapFactory.eINSTANCE.createInputLoopNodesTable();
                loopParentOutputTreeNode.setInputLoopNodesTable(inputLoopNodesTable);
                listInputLoopNodesTablesEntry.add(inputLoopNodesTable);
            }
        }
    }
    if (inputLoopNodesTable == null) {
        return;
    }
    List<TreeNode> soruceLoops = new ArrayList<TreeNode>();
    getSourceLoopsFromConnectionSource(connectionSource, soruceLoops, mainInputTree);
    for (TreeNode sourceLoop : soruceLoops) {
        if (!inputLoopNodesTable.getInputloopnodes().contains(sourceLoop)) {
            inputLoopNodesTable.getInputloopnodes().add(sourceLoop);
        }
    }
}
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) 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 15 with OutputXmlTree

use of org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree 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)

Aggregations

OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)49 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)30 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)26 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)26 ArrayList (java.util.ArrayList)17 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)15 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)13 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)12 List (java.util.List)11 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)9 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)9 OutputXmlTreeEditPart (org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart)7 EList (org.eclipse.emf.common.util.EList)6 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)6 HashMap (java.util.HashMap)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)4 EditPart (org.eclipse.gef.EditPart)3 Command (org.eclipse.gef.commands.Command)3