Search in sources :

Example 6 with OutputTreeNodeEditPart

use of org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart in project tdi-studio-se by Talend.

the class XmlDragSourceListener method getTemplate.

/**
     * 
     * DOC talend Comment method "getTemplate".
     * 
     * @param event
     * @return the validate drag able node list
     */
@Override
protected Object getTemplate(DragSourceEvent event) {
    final RootEditPart rootEditPart = getViewer().getRootEditPart();
    if (rootEditPart instanceof AbstractGraphicalEditPart) {
        AbstractGraphicalEditPart graphicPart = (AbstractGraphicalEditPart) rootEditPart;
        final IFigure figure = graphicPart.getFigure();
        final IFigure findFigureAt = figure.findFigureAt(new Point(event.x, event.y));
        if (findFigureAt instanceof ISash) {
            return findFigureAt;
        }
    }
    List<EditPart> filtedSelection = new ArrayList<EditPart>();
    for (Object part : getViewer().getSelectedEditParts()) {
        if (part instanceof TreeNodeEditPart || part instanceof VarNodeEditPart) {
            filtedSelection.add((EditPart) part);
        }
    }
    if (filtedSelection == null || filtedSelection.isEmpty()) {
        return null;
    }
    List toTransfer = new ArrayList();
    TransferdType type = null;
    List<TableEntityPart> partList = new ArrayList<TableEntityPart>();
    EditPart lastSelection = filtedSelection.get(filtedSelection.size() - 1);
    if (lastSelection instanceof TreeNodeEditPart && !(lastSelection instanceof OutputTreeNodeEditPart)) {
        type = TransferdType.INPUT;
    } else if (lastSelection instanceof VarNodeEditPart) {
        type = TransferdType.VAR;
    }
    if (type != null) {
        if (filtedSelection.size() > 1) {
            partList.addAll(lastSelection.getParent().getChildren());
            Map<EditPart, Integer> partAndIndex = new HashMap<EditPart, Integer>();
            if (type == TransferdType.INPUT) {
                for (EditPart treePart : filtedSelection) {
                    if (!XmlMapUtil.isDragable((TreeNode) treePart.getModel())) {
                        return null;
                    }
                }
                MapperTablePart abstractInOutTreePart = MapperUtils.getMapperTablePart((TableEntityPart) lastSelection);
                if (abstractInOutTreePart != null) {
                    partList = MapperUtils.getFlatChildrenPartList(abstractInOutTreePart);
                }
            } else {
                partList.addAll(lastSelection.getParent().getChildren());
            }
            for (EditPart selected : filtedSelection) {
                int indexOf = partList.indexOf(selected);
                if (indexOf != -1) {
                    partAndIndex.put(selected, indexOf);
                    int index = 0;
                    for (int i = 0; i < toTransfer.size(); i++) {
                        if (indexOf > partAndIndex.get(toTransfer.get(i))) {
                            index = i + 1;
                        }
                    }
                    toTransfer.add(index, selected);
                }
            }
        } else {
            if (lastSelection.getModel() instanceof TreeNode && !XmlMapUtil.isDragable((TreeNode) lastSelection.getModel())) {
                return null;
            }
            toTransfer.add(lastSelection);
        }
        return new TransferedObject(toTransfer, type);
    }
    return null;
}
Also used : VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) TableEntityPart(org.talend.designer.gefabstractmap.part.TableEntityPart) HashMap(java.util.HashMap) ISash(org.talend.designer.gefabstractmap.figures.sash.ISash) ArrayList(java.util.ArrayList) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) RootEditPart(org.eclipse.gef.RootEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) Point(org.eclipse.draw2d.geometry.Point) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) ArrayList(java.util.ArrayList) List(java.util.List) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) RootEditPart(org.eclipse.gef.RootEditPart) IFigure(org.eclipse.draw2d.IFigure) TransferdType(org.talend.designer.gefabstractmap.dnd.TransferdType)

Example 7 with OutputTreeNodeEditPart

use of org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart in project tdi-studio-se by Talend.

the class XmlDropTargetListener method handleDrop.

@Override
protected void handleDrop() {
    final Object object = TemplateTransfer.getInstance().getObject();
    if (object == null || !(object instanceof TransferedObject)) {
        return;
    }
    updateTargetRequest();
    updateTargetEditPart();
    DropContextAnalyzer analyzer = new DropContextAnalyzer((TransferedObject) object, (AbstractGraphicalEditPart) getTargetEditPart(), getDropLocation());
    if (analyzer.isDropValid()) {
        NodeType selectedNodeType = NodeType.ELEMENT;
        DropType dropType = analyzer.getDropType();
        if (dropType == DropType.DROP_OUTPUT_DOC_CHILD && getTargetEditPart() instanceof OutputTreeNodeEditPart) {
            OutputTreeNode targetOutputNode = (OutputTreeNode) ((OutputTreeNodeEditPart) getTargetEditPart()).getModel();
            Shell shell = getViewer().getControl().getShell();
            // if allNamespace , create output as namespace , if allsubTree , create output subtree , no need prompt
            boolean needPrompt = false;
            boolean hasSubTree = false;
            for (Object o : ((TransferedObject) object).getToTransfer()) {
                if (o instanceof VarNodeEditPart) {
                    needPrompt = true;
                } else if (o instanceof TreeNodeEditPart) {
                    TreeNode treeNode = (TreeNode) ((TreeNodeEditPart) o).getModel();
                    if (NodeType.ATTRIBUT.equals(treeNode.getNodeType())) {
                        needPrompt = true;
                    }
                    if (NodeType.ELEMENT.equals(treeNode.getNodeType())) {
                        if (treeNode.getChildren().isEmpty()) {
                            needPrompt = true;
                        } else {
                            hasSubTree = true;
                        }
                    }
                }
            }
            if (needPrompt) {
                DragAndDrogDialog selectDialog = new DragAndDrogDialog(shell, !targetOutputNode.getChildren().isEmpty());
                int open = selectDialog.open();
                if (open == Window.OK) {
                    if (DragAndDrogDialog.CREATE_AS_SUBELEMENT.equals(selectDialog.getSelectValue())) {
                        selectedNodeType = NodeType.ELEMENT;
                    } else if (DragAndDrogDialog.CREATE_AS_ATTRIBUTE.equals(selectDialog.getSelectValue())) {
                        selectedNodeType = NodeType.ATTRIBUT;
                    } else if (DragAndDrogDialog.CREATE_AS_SUBELEMENT.equals(selectDialog.getSelectValue())) {
                        selectedNodeType = NodeType.NAME_SPACE;
                    } else if (DragAndDrogDialog.CREATE_AS_TEXT.equals(selectDialog.getSelectValue())) {
                        dropType = DropType.DROP_EXPRESSION;
                    }
                } else {
                    return;
                }
            }
            if (dropType != DropType.DROP_EXPRESSION) {
                if (!targetOutputNode.getIncomingConnections().isEmpty() && ((selectedNodeType != NodeType.ATTRIBUT && selectedNodeType != NodeType.NAME_SPACE) || hasSubTree)) {
                    boolean canContinue = MessageDialog.openConfirm(null, "Warning", "Do you want to disconnect the existing linker and then add an sub element for the selected element ?");
                    if (canContinue) {
                        MapperManager mapperManager = ((XmlMapGraphicViewer) getViewer()).getMapperManager();
                        if (mapperManager != null && mapperManager.getExternalData() != null) {
                            XmlMapUtil.detachNodeConnections(targetOutputNode, mapperManager.getExternalData(), false);
                        }
                    } else {
                        return;
                    }
                }
            }
        }
        NewNodeCreationFactory factory = new NewNodeCreationFactory(dropType, selectedNodeType);
        getCreateRequest().setFactory(factory);
    }
    if (getTargetEditPart() != null) {
        Command command = getCommand();
        if (command != null && command.canExecute()) {
            getViewer().getEditDomain().getCommandStack().execute(command);
        } else {
            getCurrentEvent().detail = DND.DROP_NONE;
        }
    } else {
        getCurrentEvent().detail = DND.DROP_NONE;
    }
    selectAddedObject();
}
Also used : VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) MapperManager(org.talend.designer.xmlmap.ui.tabs.MapperManager) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) Point(org.eclipse.draw2d.geometry.Point) Shell(org.eclipse.swt.widgets.Shell) Command(org.eclipse.gef.commands.Command) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) NodeType(org.talend.designer.xmlmap.model.emf.xmlmap.NodeType) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) XmlMapGraphicViewer(org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)

Example 8 with OutputTreeNodeEditPart

use of org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart in project tdi-studio-se by Talend.

the class XmlMapEditor method buildContextMenu.

@Override
public void buildContextMenu(IMenuManager menu) {
    // context menu should only display in the document tree
    List selectedEditParts = getGraphicalViewer().getSelectedEditParts();
    if (selectedEditParts != null && !selectedEditParts.isEmpty()) {
        List output = new ArrayList();
        List input = new ArrayList();
        for (Object selected : selectedEditParts) {
            if (selected instanceof OutputTreeNodeEditPart) {
                output.add(selected);
            } else if (selected instanceof TreeNodeEditPart) {
                input.add(selected);
            }
        }
        if (!output.isEmpty() && !input.isEmpty()) {
            return;
        }
        boolean isInput = !input.isEmpty();
        ImportTreeFromXml importAction = (ImportTreeFromXml) getActionRegistry().getAction(ImportTreeFromXml.ID);
        importAction.update(selectedEditParts);
        importAction.setInput(isInput);
        if (importAction.isEnabled()) {
            menu.add(importAction);
        }
        CreateElementAction createElement = (CreateElementAction) getActionRegistry().getAction(CreateElementAction.ID);
        createElement.update(selectedEditParts);
        createElement.setInput(isInput);
        if (createElement.isEnabled()) {
            menu.add(createElement);
        }
        CreateAttributeAction createAttribute = (CreateAttributeAction) getActionRegistry().getAction(CreateAttributeAction.ID);
        createAttribute.update(selectedEditParts);
        createAttribute.setInput(isInput);
        if (createAttribute.isEnabled()) {
            menu.add(createAttribute);
        }
        CreateNameSpaceAction createNameSpace = (CreateNameSpaceAction) getActionRegistry().getAction(CreateNameSpaceAction.ID);
        createNameSpace.update(selectedEditParts);
        createNameSpace.setInput(isInput);
        if (createNameSpace.isEnabled()) {
            menu.add(createNameSpace);
        }
        FixValueAction fixValueAction = (FixValueAction) getActionRegistry().getAction(FixValueAction.ID);
        fixValueAction.update(selectedEditParts);
        if (fixValueAction.isEnabled()) {
            menu.add(fixValueAction);
        }
        AddChoiceAction addChoice = (AddChoiceAction) getActionRegistry().getAction(AddChoiceAction.ID);
        addChoice.update(selectedEditParts);
        addChoice.setInput(isInput);
        if (addChoice.isEnabled()) {
            menu.add(addChoice);
        }
        SetSubstitutionAction setSubs = (SetSubstitutionAction) getActionRegistry().getAction(SetSubstitutionAction.ID);
        setSubs.update(selectedEditParts);
        setSubs.setInput(isInput);
        if (setSubs.isEnabled()) {
            menu.add(setSubs);
        }
        SetLoopAction loopAction = (SetLoopAction) getActionRegistry().getAction(SetLoopAction.ID);
        loopAction.update(selectedEditParts);
        loopAction.setInput(isInput);
        if (loopAction.isEnabled()) {
            menu.add(loopAction);
        }
        SetLoopOptional loopOptinalAction = (SetLoopOptional) getActionRegistry().getAction(SetLoopOptional.ID);
        loopOptinalAction.update(selectedEditParts);
        if (loopOptinalAction.isEnabled()) {
            menu.add(loopOptinalAction);
        }
        SetGroupAction grouptAction = (SetGroupAction) getActionRegistry().getAction(SetGroupAction.ID);
        grouptAction.update(selectedEditParts);
        if (grouptAction.isEnabled()) {
            menu.add(grouptAction);
        }
        ImportTreeFromRepository importFromRepository = (ImportTreeFromRepository) getActionRegistry().getAction(ImportTreeFromRepository.ID);
        importFromRepository.update(selectedEditParts);
        importFromRepository.setInput(isInput);
        if (importFromRepository.isEnabled()) {
            menu.add(importFromRepository);
        }
        SetAggregateAction aggreateAction = (SetAggregateAction) getActionRegistry().getAction(SetAggregateAction.ID);
        aggreateAction.update(selectedEditParts);
        if (aggreateAction.isEnabled()) {
            menu.add(aggreateAction);
        }
        RenameTreeNodeAction renameTreeNodeAction = (RenameTreeNodeAction) getActionRegistry().getAction(RenameTreeNodeAction.ID);
        renameTreeNodeAction.update(selectedEditParts);
        if (renameTreeNodeAction.isEnabled()) {
            menu.add(renameTreeNodeAction);
        }
        DeleteTreeNodeAction action = (DeleteTreeNodeAction) getActionRegistry().getAction(DeleteTreeNodeAction.ID);
        action.update(selectedEditParts);
        action.setInput(isInput);
        if (action.isEnabled()) {
            menu.add(action);
        }
    }
}
Also used : CreateNameSpaceAction(org.talend.designer.xmlmap.editor.actions.CreateNameSpaceAction) SetLoopAction(org.talend.designer.xmlmap.editor.actions.SetLoopAction) SetAggregateAction(org.talend.designer.xmlmap.editor.actions.SetAggregateAction) ImportTreeFromXml(org.talend.designer.xmlmap.editor.actions.ImportTreeFromXml) CreateAttributeAction(org.talend.designer.xmlmap.editor.actions.CreateAttributeAction) ArrayList(java.util.ArrayList) DeleteTreeNodeAction(org.talend.designer.xmlmap.editor.actions.DeleteTreeNodeAction) AddChoiceAction(org.talend.designer.xmlmap.editor.actions.AddChoiceAction) SetGroupAction(org.talend.designer.xmlmap.editor.actions.SetGroupAction) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) SetSubstitutionAction(org.talend.designer.xmlmap.editor.actions.SetSubstitutionAction) FixValueAction(org.talend.designer.xmlmap.editor.actions.FixValueAction) SetLoopOptional(org.talend.designer.xmlmap.editor.actions.SetLoopOptional) ImportTreeFromRepository(org.talend.designer.xmlmap.editor.actions.ImportTreeFromRepository) RenameTreeNodeAction(org.talend.designer.xmlmap.editor.actions.RenameTreeNodeAction) CreateElementAction(org.talend.designer.xmlmap.editor.actions.CreateElementAction) ArrayList(java.util.ArrayList) List(java.util.List) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)

Example 9 with OutputTreeNodeEditPart

use of org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart 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)

Example 10 with OutputTreeNodeEditPart

use of org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart in project tdi-studio-se by Talend.

the class CreateNodeAndConnectionCommand method doUpdate.

// private void createInputLoopTable(TreeNode sourceNode, OutputTreeNode targetOutputNode) {
// EditPartViewer viewer = targetEditPart.getViewer();
// if (viewer instanceof XmlMapGraphicViewer) {
// InputLoopTableUtil.addSourceLoopToInputLoopTable(sourceNode, targetOutputNode, ((XmlMapGraphicViewer) viewer)
// .getMapperManager().getMainInputTree());
// }
// }
private void doUpdate(AbstractNode sourceNode) {
    if (targetEditPart instanceof OutputTreeNodeEditPart) {
        OutputTreeNode targetOutputNode = (OutputTreeNode) ((OutputTreeNodeEditPart) targetEditPart).getModel();
        String expression = targetOutputNode.getExpression();
        if (sourceNode instanceof TreeNode) {
            if (expression == null) {
                expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            } else {
                expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            }
        } else if (sourceNode instanceof VarNode) {
            String tableName = "Var";
            if (sourceNode.eContainer() instanceof VarTable) {
                tableName = ((VarTable) sourceNode.eContainer()).getName();
            }
            if (expression == null) {
                expression = tableName + "." + sourceNode.getName();
            } else {
                expression = expression + " " + tableName + "." + sourceNode.getName();
            }
        }
        // if (sourceNode instanceof TreeNode) {
        // createInputLoopTable((TreeNode) sourceNode, targetOutputNode);
        // }
        targetOutputNode.setExpression(expression);
        Connection conn = XmlmapFactory.eINSTANCE.createConnection();
        conn.setSource(sourceNode);
        conn.setTarget(targetOutputNode);
        targetOutputNode.getIncomingConnections().add(conn);
        sourceNode.getOutgoingConnections().add(conn);
        if (xmlMapData != null) {
            xmlMapData.getConnections().add(conn);
        }
    } else if (targetEditPart instanceof TreeNodeEditPart) {
        /* for lookup connections */
        if (sourceNode instanceof TreeNode) {
            TreeNode targetTreeNode = (TreeNode) targetEditPart.getModel();
            String expression = targetTreeNode.getExpression();
            if (expression == null) {
                expression = "";
            }
            expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            targetTreeNode.setExpression(expression);
            LookupConnection conn = XmlmapFactory.eINSTANCE.createLookupConnection();
            conn.setSource(sourceNode);
            conn.setTarget(targetTreeNode);
            targetTreeNode.getLookupIncomingConnections().add(conn);
            ((TreeNode) sourceNode).getLookupOutgoingConnections().add(conn);
            if (xmlMapData != null) {
                xmlMapData.getConnections().add(conn);
            }
        }
    } else if (targetEditPart instanceof VarNodeEditPart) {
        /* for varTable drag drop */
        if (sourceNode instanceof TreeNode) {
            VarNodeEditPart targetPart = (VarNodeEditPart) targetEditPart;
            VarNode targetNode = (VarNode) targetPart.getModel();
            String expression = targetNode.getExpression();
            if (expression == null) {
                expression = "";
            }
            expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            if (targetNode.getName() == null || "".equals(targetNode.getName())) {
                String findUniqueVarColumnName = XmlMapUtil.findUniqueVarColumnName(sourceNode.getName(), xmlMapData.getVarTables().get(0));
                targetNode.setName(findUniqueVarColumnName);
            }
            targetNode.setExpression(expression.trim());
            targetNode.setType(sourceNode.getType());
            Connection conn = XmlmapFactory.eINSTANCE.createConnection();
            conn.setSource(sourceNode);
            conn.setTarget(targetNode);
            targetNode.getIncomingConnections().add(conn);
            sourceNode.getOutgoingConnections().add(conn);
            if (xmlMapData != null) {
                xmlMapData.getConnections().add(conn);
            }
        }
    } else if (targetEditPart instanceof InputXmlTreeEditPart || targetEditPart instanceof OutputXmlTreeEditPart) {
        AbstractInOutTree treeModel = (AbstractInOutTree) targetEditPart.getModel();
        String expression = treeModel.getExpressionFilter();
        if (sourceNode instanceof TreeNode) {
            if (expression == null) {
                expression = XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            } else {
                expression = expression + " " + XmlMapUtil.convertToExpression(((TreeNode) sourceNode).getXpath());
            }
        } else if (sourceNode instanceof VarNode) {
            String tableName = "Var";
            if (sourceNode.eContainer() instanceof VarTable) {
                tableName = ((VarTable) sourceNode.eContainer()).getName();
            }
            if (expression == null) {
                expression = tableName + "." + sourceNode.getName();
            } else {
                expression = expression + " " + tableName + "." + sourceNode.getName();
            }
        }
        treeModel.setExpressionFilter(expression);
        FilterConnection connection = XmlmapFactory.eINSTANCE.createFilterConnection();
        connection.setSource(sourceNode);
        connection.setTarget(treeModel);
        treeModel.getFilterIncomingConnections().add(connection);
        sourceNode.getFilterOutGoingConnections().add(connection);
        xmlMapData.getConnections().add(connection);
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) FilterConnection(org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection) 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) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) LookupConnection(org.talend.designer.xmlmap.model.emf.xmlmap.LookupConnection) TreeNodeEditPart(org.talend.designer.xmlmap.parts.TreeNodeEditPart) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart) OutputXmlTreeEditPart(org.talend.designer.xmlmap.parts.OutputXmlTreeEditPart) 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) OutputTreeNodeEditPart(org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)

Aggregations

OutputTreeNodeEditPart (org.talend.designer.xmlmap.parts.OutputTreeNodeEditPart)10 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)8 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)7 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)6 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)5 List (java.util.List)4 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)4 ArrayList (java.util.ArrayList)3 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)3 VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)3 Point (org.eclipse.draw2d.geometry.Point)2 EditPart (org.eclipse.gef.EditPart)2 Command (org.eclipse.gef.commands.Command)2 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)2 Shell (org.eclipse.swt.widgets.Shell)2 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)2 XmlMapGraphicViewer (org.talend.designer.xmlmap.editor.XmlMapGraphicViewer)2 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)2 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)2 HashMap (java.util.HashMap)1