Search in sources :

Example 1 with OutputXmlTreeFigure

use of org.talend.designer.xmlmap.figures.OutputXmlTreeFigure in project tdi-studio-se by Talend.

the class SearchZoneMapper method search.

public void search(Map<Integer, Map<Integer, Figure>> searchMaps, String searchValue) {
    if (searchValue.equals("") || searchValue == null) {
        return;
    }
    List<InputXmlTree> inputTrees = mapperManager.getExternalData().getInputTrees();
    List<VarTable> varTables = mapperManager.getExternalData().getVarTables();
    List<OutputXmlTree> outputTrees = mapperManager.getExternalData().getOutputTrees();
    matcher.setPattern("*" + searchValue.trim() + "*");
    int index = -1;
    // for the InputTables
    for (InputXmlTree inputXmlTree : inputTrees) {
        // ExpressionFilter
        if (inputXmlTree.getExpressionFilter() != null && matcher.matches(inputXmlTree.getExpressionFilter())) {
            EList<Adapter> adapter = inputXmlTree.eAdapters();
            if (adapter.size() > 0) {
                if (adapter.get(0) instanceof InputXmlTreeEditPart) {
                    InputXmlTreeEditPart inputXmlTreeEditPart = (InputXmlTreeEditPart) adapter.get(0);
                    if (inputXmlTreeEditPart != null && inputXmlTreeEditPart.getFigure() != null && inputXmlTreeEditPart.getFigure() instanceof InputXmlTreeFigure) {
                        InputXmlTreeFigure inputXmlTreeFigure = (InputXmlTreeFigure) inputXmlTreeEditPart.getFigure();
                        Map<Integer, Figure> map = new HashMap<Integer, Figure>();
                        map.put(0, inputXmlTreeFigure.getFilterContainer());
                        index++;
                        searchMaps.put(index, map);
                    }
                }
            }
        }
        // TreeNode
        for (TreeNode node : inputXmlTree.getNodes()) {
            // id_Document type
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
                    if (getMatcherNodeFigure(nodeTemp).size() > 0) {
                        index++;
                        searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
                    }
                }
            }
            if (getMatcherNodeFigure(node).size() > 0) {
                index++;
                searchMaps.put(index, getMatcherNodeFigure(node));
            }
        }
    }
    // for the VarsTables
    for (VarTable varTable : varTables) {
        for (VarNode node : varTable.getNodes()) {
            if (getMatcherNodeFigure(node).size() > 0) {
                index++;
                searchMaps.put(index, getMatcherNodeFigure(node));
            }
        }
    }
    // for the OutputTables
    for (OutputXmlTree outputXmlTree : outputTrees) {
        // ExpressionFilter
        if (outputXmlTree.getExpressionFilter() != null && matcher.matches(outputXmlTree.getExpressionFilter())) {
            EList<Adapter> adapter = outputXmlTree.eAdapters();
            if (adapter.size() > 0) {
                if (adapter.get(0) instanceof OutputXmlTreeEditPart) {
                    OutputXmlTreeEditPart outputXmlTreeEditPart = (OutputXmlTreeEditPart) adapter.get(0);
                    if (outputXmlTreeEditPart != null && outputXmlTreeEditPart.getFigure() != null && outputXmlTreeEditPart.getFigure() instanceof OutputXmlTreeFigure) {
                        OutputXmlTreeFigure outputXmlTreeFigure = (OutputXmlTreeFigure) outputXmlTreeEditPart.getFigure();
                        Map<Integer, Figure> map = new HashMap<Integer, Figure>();
                        map.put(0, outputXmlTreeFigure.getFilterContainer());
                        index++;
                        searchMaps.put(index, map);
                    }
                }
            }
        }
        // OutputTreeNode
        for (OutputTreeNode node : outputXmlTree.getNodes()) {
            // id_Document type
            if (XmlMapUtil.DOCUMENT.equals(node.getType())) {
                for (TreeNode nodeTemp : XmlMapUtil.getFlatChildrenList(node)) {
                    if (getMatcherNodeFigure(nodeTemp).size() > 0) {
                        index++;
                        searchMaps.put(index, getMatcherNodeFigure(nodeTemp));
                    }
                }
            } else {
                if (getMatcherNodeFigure(node).size() > 0) {
                    index++;
                    searchMaps.put(index, getMatcherNodeFigure(node));
                }
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) HashMap(java.util.HashMap) Adapter(org.eclipse.emf.common.notify.Adapter) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) IFigure(org.eclipse.draw2d.IFigure) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) VarNodeFigure(org.talend.designer.xmlmap.figures.varnode.VarNodeFigure) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) Figure(org.eclipse.draw2d.Figure) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) 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) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure)

Example 2 with OutputXmlTreeFigure

use of org.talend.designer.xmlmap.figures.OutputXmlTreeFigure in project tdi-studio-se by Talend.

the class InputXmlTreeEditPart method notifyChanged.

@Override
public void notifyChanged(Notification notification) {
    int type = notification.getEventType();
    int featureId = notification.getFeatureID(XmlmapPackage.class);
    switch(type) {
        case Notification.ADD:
        case Notification.REMOVE:
        case Notification.REMOVE_MANY:
            switch(featureId) {
                case XmlmapPackage.INPUT_XML_TREE__NODES:
                case XmlmapPackage.INPUT_XML_TREE__GLOBAL_MAP_KEYS_VALUES:
                    refreshChildren();
                    break;
                case XmlmapPackage.ABSTRACT_IN_OUT_TREE__FILTER_INCOMING_CONNECTIONS:
                    refreshTargetConnections();
                    break;
            }
            break;
        case Notification.SET:
            switch(featureId) {
                case XmlmapPackage.INPUT_XML_TREE__NODES:
                case XmlmapPackage.INPUT_XML_TREE__GLOBAL_MAP_KEYS_VALUES:
                    refreshChildren();
                    break;
                case XmlmapPackage.INPUT_XML_TREE__ACTIVATE_CONDENSED_TOOL:
                    getFigure().validate();
                    break;
                case XmlmapPackage.INPUT_XML_TREE__LOOKUP_MODE:
                case XmlmapPackage.INPUT_XML_TREE__MATCHING_MODE:
                case XmlmapPackage.INPUT_XML_TREE__INNER_JOIN:
                case XmlmapPackage.INPUT_XML_TREE__PERSISTENT:
                case XmlmapPackage.INPUT_XML_TREE__MINIMIZED:
                case XmlmapPackage.INPUT_XML_TREE__EXPRESSION_FILTER:
                    ((InputXmlTreeFigure) getFigure()).update(featureId);
                    break;
                case XmlmapPackage.ABSTRACT_IN_OUT_TREE__MULTI_LOOPS:
                    if (getParent() instanceof XmlMapDataEditPart) {
                        List childPart = ((XmlMapDataEditPart) getParent()).getChildren();
                        for (Object o : childPart) {
                            if (o instanceof OutputXmlTreeEditPart) {
                                OutputXmlTreeEditPart outputPart = (OutputXmlTreeEditPart) o;
                                boolean hasDocument = XmlMapUtil.hasDocument((OutputXmlTree) outputPart.getModel());
                                if (!hasDocument) {
                                    OutputXmlTreeFigure outputTreeFigure = (OutputXmlTreeFigure) outputPart.getFigure();
                                    outputTreeFigure.update(XmlmapPackage.ABSTRACT_IN_OUT_TREE__MULTI_LOOPS);
                                } else {
                                    List nodeChild = outputPart.getChildren();
                                    for (Object nc : nodeChild) {
                                        if (nc instanceof OutputTreeNodeEditPart) {
                                            refreshOutputNodeLoopFunctionBtn((OutputTreeNodeEditPart) nc);
                                        }
                                    }
                                }
                            }
                        }
                        boolean changed = clearOutputAggregateIfNeeded();
                        if (changed) {
                            ((XmlMapDataEditPart) getParent()).refresh();
                        }
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().getProblemsAnalyser().checkProblems();
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().getMapperUI().updateStatusBar();
                    }
            }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) InputXmlTreeFigure(org.talend.designer.xmlmap.figures.InputXmlTreeFigure) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with OutputXmlTreeFigure

use of org.talend.designer.xmlmap.figures.OutputXmlTreeFigure in project tdi-studio-se by Talend.

the class OutputTreeNodeEditPart method notifyChanged.

@Override
public void notifyChanged(Notification notification) {
    super.notifyChanged(notification);
    int type = notification.getEventType();
    int featureId = notification.getFeatureID(XmlmapPackage.class);
    switch(type) {
        case Notification.SET:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__TYPE:
                    if (XmlMapUtil.DOCUMENT.equals(notification.getOldValue()) || !XmlMapUtil.DOCUMENT.equals(notification.getOldValue()) && XmlMapUtil.DOCUMENT.equals(notification.getNewValue())) {
                        MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(this);
                        if (mapperTablePart.getFigure() instanceof OutputXmlTreeFigure) {
                            ((OutputXmlTreeFigure) mapperTablePart.getFigure()).update(XmlmapPackage.TREE_NODE__TYPE);
                        }
                    }
                    break;
                case XmlmapPackage.TREE_NODE__LOOP:
                    ((XmlmapTreeNodeFigure) getFigure()).getBranchContent().updateLoopButtonFigure();
                    AbstractInOutTree abstractInOutTree = XmlMapUtil.getAbstractInOutTree((OutputTreeNode) getModel());
                    if (abstractInOutTree != null) {
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().getProblemsAnalyser().checkProblems(abstractInOutTree);
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().getMapperUI().updateStatusBar();
                    }
            }
            break;
        case Notification.REMOVE:
        case Notification.REMOVE_MANY:
            switch(featureId) {
            }
        // }
        case Notification.ADD:
        case Notification.ADD_MANY:
            switch(featureId) {
                case XmlmapPackage.INPUT_LOOP_NODES_TABLE__INPUTLOOPNODES:
                case XmlmapPackage.OUTPUT_TREE_NODE__INPUT_LOOP_NODES_TABLE:
                    XmlmapTreeNodeFigure outputFigure = (XmlmapTreeNodeFigure) getFigure();
                    if (outputFigure.getElement() != null) {
                        outputFigure.getBranchContent().updateLoopButtonFigure();
                    }
                    break;
                default:
                    break;
            }
    }
}
Also used : AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 4 with OutputXmlTreeFigure

use of org.talend.designer.xmlmap.figures.OutputXmlTreeFigure in project tdi-studio-se by Talend.

the class OutputXmlTreeEditPart method notifyChanged.

@Override
public void notifyChanged(Notification notification) {
    int type = notification.getEventType();
    int featureId = notification.getFeatureID(XmlmapPackage.class);
    switch(type) {
        case Notification.ADD:
        case Notification.REMOVE:
        case Notification.REMOVE_MANY:
            switch(featureId) {
                case XmlmapPackage.OUTPUT_XML_TREE__NODES:
                    refreshChildren();
                    break;
                case XmlmapPackage.ABSTRACT_IN_OUT_TREE__FILTER_INCOMING_CONNECTIONS:
                    refreshTargetConnections();
                    break;
            }
            break;
        case Notification.SET:
            switch(featureId) {
                case XmlmapPackage.OUTPUT_XML_TREE__NODES:
                    refreshChildren();
                case XmlmapPackage.OUTPUT_XML_TREE__REJECT:
                case XmlmapPackage.OUTPUT_XML_TREE__REJECT_INNER_JOIN:
                case XmlmapPackage.OUTPUT_XML_TREE__EXPRESSION_FILTER:
                case XmlmapPackage.OUTPUT_XML_TREE__MINIMIZED:
                case XmlmapPackage.OUTPUT_XML_TREE__ALL_IN_ONE:
                case XmlmapPackage.OUTPUT_XML_TREE__ENABLE_EMPTY_ELEMENT:
                    ((OutputXmlTreeFigure) getFigure()).update(featureId);
                    break;
                case XmlmapPackage.TREE_NODE__EXPRESSION:
                    ((OutputXmlTreeFigure) getFigure()).update(XmlmapPackage.TREE_NODE__TYPE);
                    break;
                case XmlmapPackage.ABSTRACT_IN_OUT_TREE__MULTI_LOOPS:
                    // fix for TDI-20808 , clean aggreage and groups if it's multiloops
                    OutputXmlTree model = (OutputXmlTree) getModel();
                    boolean changed = false;
                    if (model.isMultiLoops()) {
                        changed = XmlMapUtil.cleanGroup(model.getNodes());
                    }
                    if (model.isMultiLoops() && getParent() instanceof XmlMapDataEditPart) {
                        List childPart = ((XmlMapDataEditPart) getParent()).getChildren();
                        for (Object o : childPart) {
                            if (o instanceof InputXmlTreeEditPart) {
                                InputXmlTree inputTree = (InputXmlTree) ((InputXmlTreeEditPart) o).getModel();
                                if (inputTree.isMultiLoops() && !inputTree.isLookup()) {
                                    changed = XmlMapUtil.cleanAggregate(model.getNodes()) || changed;
                                    break;
                                }
                            }
                        }
                    }
                    if (changed) {
                        refreshChildren();
                    }
            }
    }
    // change icon for set loop function button
    if (type == Notification.ADD && featureId == XmlmapPackage.OUTPUT_XML_TREE__INPUT_LOOP_NODES_TABLES) {
        final InputLoopNodesTable loopNodeTable = (InputLoopNodesTable) notification.getNewValue();
        addListenerForInputLoopNodeTable(loopNodeTable);
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) InputLoopNodesTable(org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable) ArrayList(java.util.ArrayList) List(java.util.List) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree) OutputXmlTreeFigure(org.talend.designer.xmlmap.figures.OutputXmlTreeFigure) Point(org.eclipse.draw2d.geometry.Point)

Aggregations

OutputXmlTreeFigure (org.talend.designer.xmlmap.figures.OutputXmlTreeFigure)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Point (org.eclipse.draw2d.geometry.Point)2 XmlMapGraphicViewer (org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)2 InputXmlTreeFigure (org.talend.designer.xmlmap.figures.InputXmlTreeFigure)2 XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)2 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)2 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)2 HashMap (java.util.HashMap)1 Figure (org.eclipse.draw2d.Figure)1 IFigure (org.eclipse.draw2d.IFigure)1 Adapter (org.eclipse.emf.common.notify.Adapter)1 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)1 VarEntityFigure (org.talend.designer.gefabstractmap.figures.var.VarEntityFigure)1 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)1 VarNodeFigure (org.talend.designer.xmlmap.figures.varnode.VarNodeFigure)1 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)1 InputLoopNodesTable (org.talend.designer.xmlmap.model.emf.xmlmap.InputLoopNodesTable)1 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)1