Search in sources :

Example 16 with InputXmlTree

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

the class XMLMapperHelper method hasDocumentInMainInput.

private static boolean hasDocumentInMainInput(final INode xmlMapperNode) {
    boolean hasDocumentInMainInput = false;
    List<? extends IConnection> inConnections = (List<? extends IConnection>) xmlMapperNode.getIncomingConnections();
    XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
    if (xmlMapData != null && inConnections != null && inConnections.size() > 0) {
        List<InputXmlTree> inputTables = xmlMapData.getInputTrees();
        HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
        for (IConnection connection : inConnections) {
            hNameToConnection.put(connection.getName(), connection);
        }
        for (InputXmlTree inputTable : inputTables) {
            String tableName = inputTable.getName();
            IConnection connection = hNameToConnection.get(tableName);
            if (connection == null) {
                continue;
            }
            if (!(inputTable.isLookup())) {
                for (TreeNode node : inputTable.getNodes()) {
                    if ("id_Document".equals(node.getType())) {
                        hasDocumentInMainInput = true;
                        break;
                    }
                }
            }
        }
    }
    return hasDocumentInMainInput;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) HashMap(java.util.HashMap) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 17 with InputXmlTree

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

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

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

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

InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)52 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)34 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)28 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)26 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)18 ArrayList (java.util.ArrayList)17 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)12 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)12 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)9 List (java.util.List)5 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)5 IConnection (org.talend.designer.xmlmap.model.emf.xmlmap.IConnection)5 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)5 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)4 HashMap (java.util.HashMap)3 Point (org.eclipse.draw2d.geometry.Point)3 EList (org.eclipse.emf.common.util.EList)3 ExpressionFigure (org.talend.designer.gefabstractmap.figures.ExpressionFigure)3 LookupConnection (org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection)3 Iterator (java.util.Iterator)2