Search in sources :

Example 21 with VarNode

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

the class XmlMapConnectionBuilder method rebuildLink.

private void rebuildLink(int inputTreeIndex, List<TreeNode> children, XmlMapData mapData) {
    for (TreeNode treeNode : children) {
        if (XmlMapUtil.isDragable(treeNode)) {
            String expression = XmlMapUtil.convertToExpression(treeNode.getXpath());
            XmlMapExpressionManager expressionManager = new XmlMapExpressionManager();
            TableEntryLocation sourceLocation = expressionManager.parseTableEntryLocation(expression).get(0);
            // LOOKUP ,FILTER
            for (int i = inputTreeIndex; i < mapData.getInputTrees().size(); i++) {
                InputXmlTree treeTarget = mapData.getInputTrees().get(i);
                if (hasMaptchedLocation(expressionManager, sourceLocation, treeTarget, ExpressionType.EXPRESSION_FILTER)) {
                    createFilterConnection(treeNode, treeTarget, mapData);
                }
                checkTargetChildren(expressionManager, treeTarget.getNodes(), treeNode, sourceLocation, mapData);
            }
            // VAR
            for (VarNode varNode : mapData.getVarTables().get(0).getNodes()) {
                if (hasMaptchedLocation(expressionManager, sourceLocation, varNode, ExpressionType.EXPRESSION)) {
                    createConnection(treeNode, varNode, mapData);
                }
            }
            // OUTPUT,FILTER
            for (int i = 0; i < mapData.getOutputTrees().size(); i++) {
                OutputXmlTree outputTree = mapData.getOutputTrees().get(i);
                if (hasMaptchedLocation(expressionManager, sourceLocation, outputTree, ExpressionType.EXPRESSION_FILTER)) {
                    createFilterConnection(treeNode, outputTree, mapData);
                }
                checkTargetChildren(expressionManager, outputTree.getNodes(), treeNode, sourceLocation, mapData);
            }
        }
        if (!treeNode.getChildren().isEmpty()) {
            rebuildLink(inputTreeIndex, treeNode.getChildren(), mapData);
        }
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) XmlMapExpressionManager(org.talend.designer.xmlmap.ui.expressionutil.XmlMapExpressionManager) TableEntryLocation(org.talend.designer.xmlmap.ui.expressionutil.TableEntryLocation) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 22 with VarNode

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

the class XmlMapUtil method checkValidColumnName.

private static boolean checkValidColumnName(String newName, VarTable parentTable) {
    for (VarNode entry : parentTable.getNodes()) {
        if (entry.getName().equals(newName)) {
            return false;
        }
    }
    //$NON-NLS-1$
    Pattern regex = Pattern.compile("^[A-Za-z_][A-Za-z0-9_]*$", Pattern.CANON_EQ | Pattern.CASE_INSENSITIVE);
    Matcher regexMatcher = regex.matcher(newName);
    return regexMatcher.matches();
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher)

Example 23 with VarNode

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

the class XmlMapVarTablePart method activate.

@Override
public void activate() {
    super.activate();
    selectionListener = new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            List selectedEditParts = getViewer().getSelectedEditParts();
            boolean remove = false;
            boolean moveUp = false;
            boolean moveDown = false;
            boolean disableMoveUp = false;
            boolean disableMoveDown = false;
            for (Object obj : selectedEditParts) {
                if (obj instanceof VarNodeEditPart) {
                    remove = true;
                    VarNode selectedNode = (VarNode) ((VarNodeEditPart) obj).getModel();
                    EList<VarNode> nodes = ((VarTable) getModel()).getNodes();
                    int indexOf = nodes.indexOf(selectedNode);
                    if (!disableMoveUp) {
                        if (indexOf != -1 && indexOf > 0) {
                            moveUp = true;
                        } else {
                            moveUp = false;
                            disableMoveUp = true;
                        }
                    }
                    if (!disableMoveDown) {
                        if (indexOf != -1 && indexOf < nodes.size() - 1) {
                            moveDown = true;
                        } else {
                            moveDown = false;
                            disableMoveDown = true;
                        }
                    }
                }
            }
            VarToolBarFigure toolBarFigure = ((VarTableContainer) getFigure()).getToolBarFigure();
            toolBarFigure.setRemoveEnable(remove);
            toolBarFigure.setMoveUpEnable(moveUp);
            toolBarFigure.setMoveDownEnable(moveDown);
        }
    };
    getViewer().addSelectionChangedListener(selectionListener);
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) VarToolBarFigure(org.talend.designer.xmlmap.figures.treetools.VarToolBarFigure) EList(org.eclipse.emf.common.util.EList) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 24 with VarNode

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

the class DragAndDropEditPolicy method showTargetFeedback.

@Override
public void showTargetFeedback(Request request) {
    if (request instanceof CreateNodeConnectionRequest) {
        CreateNodeConnectionRequest rq = (CreateNodeConnectionRequest) request;
        AbstractGraphicalEditPart targetEditPart = (AbstractGraphicalEditPart) rq.getTargetEditPart();
        // show feedback when insert new column
        if (rq.getNewObjectType() != null && targetEditPart != null) {
            Object model = targetEditPart.getModel();
            switch(rq.getNewObjectType()) {
                case DROP_INSERT_OUTPUT:
                case DROP_INSERT_VAR:
                    if (model instanceof OutputTreeNode || model instanceof VarNode) {
                        IFigure targetFigure = targetEditPart.getFigure();
                        if (targetFigure != null) {
                            if (indicator == null) {
                                indicator = new InsertionIndicator();
                            }
                            Rectangle copy = targetFigure.getBounds().getCopy();
                            Rectangle bounds = new Rectangle();
                            bounds.x = copy.x - 5;
                            bounds.y = copy.y - 5;
                            bounds.width = copy.width + 10;
                            bounds.height = 10;
                            indicator.setBounds(bounds);
                            getFeedbackLayer().add(indicator);
                        }
                    } else {
                        if (indicator != null && getFeedbackLayer() != null && indicator.getParent() == getFeedbackLayer()) {
                            getFeedbackLayer().remove(indicator);
                        }
                    }
                    break;
            }
        }
    }
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CreateNodeConnectionRequest(org.talend.designer.xmlmap.dnd.CreateNodeConnectionRequest) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) IFigure(org.eclipse.draw2d.IFigure)

Example 25 with VarNode

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

the class VarToolBarFigure method removeVar.

@Override
protected void removeVar() {
    CommandStack commandStack = getTableManager().getGraphicalViewer().getEditDomain().getCommandStack();
    commandStack.execute(new Command() {

        @Override
        public void execute() {
            List selectedEditParts = getTableManager().getGraphicalViewer().getSelectedEditParts();
            final List<VarNode> toRemove = new ArrayList<VarNode>();
            int minIndex = parentTable.getNodes().size() - 1;
            for (Object obj : selectedEditParts) {
                if (obj instanceof VarNodeEditPart) {
                    VarNode model = (VarNode) ((VarNodeEditPart) obj).getModel();
                    toRemove.add(model);
                    XmlMapUtil.detachNodeConnections(model, (XmlMapData) parentTable.eContainer(), true);
                    int index = parentTable.getNodes().indexOf(model);
                    if (index < minIndex) {
                        minIndex = index;
                    }
                }
            }
            parentTable.getNodes().removeAll(toRemove);
            if (!tablePart.getChildren().isEmpty()) {
                if (minIndex > tablePart.getChildren().size() - 1) {
                    minIndex = tablePart.getChildren().size() - 1;
                }
                tablePart.getViewer().select((EditPart) tablePart.getChildren().get(minIndex));
            } else {
                remove.setEnabled(false);
            }
        }
    });
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) CommandStack(org.eclipse.gef.commands.CommandStack) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) Command(org.eclipse.gef.commands.Command) VarNodeEditPart(org.talend.designer.xmlmap.parts.VarNodeEditPart) EditPart(org.eclipse.gef.EditPart) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Aggregations

VarNode (org.talend.designer.xmlmap.model.emf.xmlmap.VarNode)28 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)19 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)17 VarTable (org.talend.designer.xmlmap.model.emf.xmlmap.VarTable)13 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)12 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)12 VarNodeEditPart (org.talend.designer.xmlmap.parts.VarNodeEditPart)11 AbstractNode (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractNode)9 XmlMapData (org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)8 ArrayList (java.util.ArrayList)7 List (java.util.List)7 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)7 TreeNodeEditPart (org.talend.designer.xmlmap.parts.TreeNodeEditPart)7 EList (org.eclipse.emf.common.util.EList)6 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)6 FilterConnection (org.talend.designer.xmlmap.model.emf.xmlmap.FilterConnection)6 EditPart (org.eclipse.gef.EditPart)4 Command (org.eclipse.gef.commands.Command)4 CommandStack (org.eclipse.gef.commands.CommandStack)4 Connection (org.talend.designer.xmlmap.model.emf.xmlmap.Connection)4