Search in sources :

Example 1 with Adapter

use of org.eclipse.emf.common.notify.Adapter 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 Adapter

use of org.eclipse.emf.common.notify.Adapter in project tdi-studio-se by Talend.

the class SearchZoneMapper method getMatcherNodeFigure.

private Map<Integer, Figure> getMatcherNodeFigure(AbstractNode node) {
    Map<Integer, Figure> map = new HashMap<Integer, Figure>();
    int i = -1;
    TableEntityFigure figure = null;
    if (node != null) {
        EList<Adapter> adapter = node.eAdapters();
        if (adapter.size() > 0) {
            if (adapter.get(0) instanceof TableEntityPart) {
                TableEntityPart tableEntityPart = (TableEntityPart) adapter.get(0);
                if (tableEntityPart != null && tableEntityPart.getFigure() != null && tableEntityPart.getFigure() instanceof TableEntityFigure) {
                    figure = (TableEntityFigure) tableEntityPart.getFigure();
                }
            }
        }
        if (node.getExpression() != null && matcher.matches(node.getExpression())) {
            i++;
            map.put(i, figure);
        } else if (node.getName() != null && matcher.matches(node.getName())) {
            i++;
            map.put(i, figure);
        }
    }
    return map;
}
Also used : TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) HashMap(java.util.HashMap) Adapter(org.eclipse.emf.common.notify.Adapter) TableEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure) 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)

Example 3 with Adapter

use of org.eclipse.emf.common.notify.Adapter in project tdi-studio-se by Talend.

the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.

public void moveScrollBarZoneAtSelectedTableItem(Figure entry) {
    if (entry != null) {
        Rectangle bounds = entry.getBounds();
        int selection = bounds.y - 100;
        if (entry instanceof XmlmapTreeNodeFigure) {
            XmlmapTreeNodeFigure xmlMapTreeNodeFigure = (XmlmapTreeNodeFigure) entry;
            TreeNode treeNode = xmlMapTreeNodeFigure.getTreeNode();
            if (treeNode != null) {
                for (Adapter adapter : treeNode.eAdapters()) {
                    TreeNodeEditPart part = (TreeNodeEditPart) adapter;
                    XmlMapDataEditPart xmlMapDataEditPart = part.getMapDataEditPart();
                    if (adapter instanceof OutputTreeNodeEditPart) {
                        Viewport viewport = xmlMapDataEditPart.getOutputScroll().getViewport();
                        viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
                    } else if (adapter instanceof TreeNodeEditPart) {
                        Viewport viewport = xmlMapDataEditPart.getInputScroll().getViewport();
                        viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
                    }
                }
            }
        } else if (entry instanceof VarNodeFigure) {
            VarNodeFigure varNodeFigure = (VarNodeFigure) entry;
            VarNode varNode = varNodeFigure.getVarNode();
            if (varNode != null) {
                for (Adapter adapter : varNode.eAdapters()) {
                    VarNodeEditPart part = (VarNodeEditPart) adapter;
                    XmlMapDataEditPart xmlMapDataEditPart = part.getMapDataEditPart();
                    Viewport viewport = xmlMapDataEditPart.getVarScroll().getViewport();
                    viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
                }
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) VarNodeFigure(org.talend.designer.xmlmap.figures.varnode.VarNodeFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Viewport(org.eclipse.draw2d.Viewport) Adapter(org.eclipse.emf.common.notify.Adapter) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) XmlMapDataEditPart(org.talend.designer.xmlmap.parts.XmlMapDataEditPart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)

Aggregations

Adapter (org.eclipse.emf.common.notify.Adapter)3 XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)3 VarNodeFigure (org.talend.designer.xmlmap.figures.varnode.VarNodeFigure)3 HashMap (java.util.HashMap)2 Figure (org.eclipse.draw2d.Figure)2 IFigure (org.eclipse.draw2d.IFigure)2 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)2 VarEntityFigure (org.talend.designer.gefabstractmap.figures.var.VarEntityFigure)2 InputXmlTreeFigure (org.talend.designer.xmlmap.figures.InputXmlTreeFigure)2 OutputXmlTreeFigure (org.talend.designer.xmlmap.figures.OutputXmlTreeFigure)2 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)2 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)2 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)2 Viewport (org.eclipse.draw2d.Viewport)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)1 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)1 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)1 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)1 InputXmlTreeEditPart (org.talend.designer.xmlmap.parts.InputXmlTreeEditPart)1