Search in sources :

Example 11 with AbstractInOutTree

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

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

the class MapperManager method onEntitySelection.

private void onEntitySelection(IStructuredSelection selection, AbstractInOutTree selectedTree) {
    // do selection in metadata schema editor
    EList<? extends TreeNode> nodes = null;
    if (selectedTree instanceof InputXmlTree) {
        nodes = ((InputXmlTree) selectedTree).getNodes();
    } else {
        nodes = ((OutputXmlTree) selectedTree).getNodes();
    }
    List<Integer> selectionIndices = new ArrayList<Integer>();
    List<TreeNode> selectedDocChild = new ArrayList<TreeNode>();
    Iterator iterator = selection.iterator();
    while (iterator.hasNext()) {
        Object obj = iterator.next();
        if (obj instanceof TreeNodeEditPart) {
            TreeNode model = (TreeNode) ((TreeNodeEditPart) obj).getModel();
            if (model.eContainer() == selectedTree) {
                selectionIndices.add(nodes.indexOf(model));
            } else {
                AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree(model);
                if (abstractInOutTree == selectedTree) {
                    selectedDocChild.add(model);
                }
            }
        }
    }
    int[] selections = new int[selectionIndices.size()];
    for (int i = 0; i < selectionIndices.size(); i++) {
        selections[i] = selectionIndices.get(i);
    }
    MetadataTableEditorView metaEditorView = null;
    XmlTreeSchemaTableView treeEditorView = null;
    if (selectedTree instanceof InputXmlTree) {
        metaEditorView = mapperUI.getTabFolderEditors().getInputMetaEditorView();
        treeEditorView = mapperUI.getTabFolderEditors().getInputTreeSchemaEditor();
    } else {
        metaEditorView = mapperUI.getTabFolderEditors().getOutputMetaEditorView();
        treeEditorView = mapperUI.getTabFolderEditors().getOutputTreeSchemaEditor();
    }
    metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
    metaEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
    metaEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
    metaEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    // if no, change page
    if (!selectedDocChild.isEmpty()) {
        treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(false);
        TreeNode firstSelection = null;
        if (selectedDocChild.size() > 1) {
            selectionIndices = new ArrayList<Integer>();
            List<TreeNode> allList = new ArrayList<TreeNode>();
            for (TreeNode schemaNodes : nodes) {
                if (XmlMapUtil.DOCUMENT.equals(schemaNodes.getType())) {
                    allList.addAll(SchemaTableUtils.getTreeSchemaEnties(schemaNodes));
                }
            }
            int minIndex = allList.size();
            for (TreeNode selected : selectedDocChild) {
                int indexOf = allList.indexOf(selected);
                if (indexOf != -1 && indexOf < minIndex) {
                    firstSelection = selected;
                }
            }
        } else {
            firstSelection = selectedDocChild.get(0);
        }
        treeEditorView.getExtendedTableModel().changePageIfNeeded(firstSelection);
        // update selection
        selectionIndices = new ArrayList<Integer>();
        for (TreeNode selected : selectedDocChild) {
            int indexOf = treeEditorView.getExtendedTableModel().getBeansList().indexOf(selected);
            if (indexOf != -1) {
                selectionIndices.add(indexOf);
            }
        }
        selections = new int[selectionIndices.size()];
        for (int i = 0; i < selectionIndices.size(); i++) {
            selections[i] = selectionIndices.get(i);
        }
        treeEditorView.getExtendedTableViewer().getTableViewerCreator().getSelectionHelper().setSelection(selections);
        treeEditorView.getTableViewerCreator().getSelectionHelper().setActiveFireSelectionChanged(true);
        treeEditorView.getExtendedToolbar().updateEnabledStateOfButtons();
    }
}
Also used : ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) XmlTreeSchemaTableView(org.talend.designer.xmlmap.ui.tabs.table.XmlTreeSchemaTableView) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Iterator(java.util.Iterator) MetadataTableEditorView(org.talend.core.ui.metadata.editor.MetadataTableEditorView) AbstractMetadataTableEditorView(org.talend.core.ui.metadata.editor.AbstractMetadataTableEditorView)

Example 13 with AbstractInOutTree

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

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

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

the class InputLoopTableUtil method getInputLoopNodesTable.

private static InputLoopNodesTable getInputLoopNodesTable(OutputTreeNode outputNode) {
    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);
        }
    } 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);
            }
        }
    }
    return inputLoopNodesTable;
}
Also used : InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) 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

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