Search in sources :

Example 46 with TreeNode

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

Example 47 with TreeNode

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

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

the class SetLoopFunctionDialog method okPressed.

@Override
protected void okPressed() {
    List<TreeNode> usedLoops = new ArrayList<TreeNode>();
    for (TreeSchemaTableEntry entry : tableModel.getBeansList()) {
        usedLoops.add(entry.getTreeNode());
    }
    inputLoopNodesTable.getInputloopnodes().clear();
    inputLoopNodesTable.getInputloopnodes().addAll(usedLoops);
    super.okPressed();
}
Also used : TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) ArrayList(java.util.ArrayList) TreeSchemaTableEntry(org.talend.designer.xmlmap.ui.tabs.table.TreeSchemaTableEntry)

Example 49 with TreeNode

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

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

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