Search in sources :

Example 1 with ExpressionFigure

use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.

the class XmlmapTreeNodeFigure method createEntityItems.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.newabstractmap.figures.table.entity.TableEntityFigure#createEntityItems()
     */
@Override
protected void createEntityItems(TableEntityElement entityElement) {
    this.treeNode = getEntityManager().getModel();
    boolean isLookup = false;
    if (treeNode instanceof OutputTreeNode) {
        isLookup = true;
    } else {
        TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot(treeNode);
        if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
            isLookup = ((InputXmlTree) inputTreeNodeRoot.eContainer()).isLookup();
        }
    }
    if (isLookup) {
        expression = new ExpressionFigure();
        expression.setText(treeNode.getExpression());
        if (!XmlMapUtil.isExpressionEditable(treeNode)) {
            expression.setOpaque(true);
            expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
        } else {
            expression.setOpaque(false);
        }
        entityElement.add(expression);
    }
    branchContent = new XmlmapBranchContent(getEntityManager());
    TreeBranch treeBranch = new TreeBranch(branchContent, !isRoot());
    entityElement.add(treeBranch);
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) TreeBranch(org.talend.designer.gefabstractmap.figures.table.entity.TreeBranch) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)

Example 2 with ExpressionFigure

use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.

the class DropContextAnalyzer method checkDropIsValid.

private boolean checkDropIsValid() {
    if (objects == null || objects.getToTransfer().isEmpty() || targetEditPart == null) {
        return false;
    }
    Object targetModel = targetEditPart.getModel();
    targetFigure = targetEditPart.getFigure().findFigureAt(dropLocation.x, dropLocation.y);
    boolean isTragetOutputNode = targetModel instanceof OutputTreeNode;
    boolean isTragetInputNode = targetModel instanceof TreeNode && !(targetModel instanceof OutputTreeNode);
    boolean isVar = targetModel instanceof VarNode;
    boolean isDropInputTree = targetModel instanceof InputXmlTree;
    boolean isDropOutputTree = targetModel instanceof OutputXmlTree;
    boolean isDropVarTable = targetModel instanceof VarTable;
    // drop expression
    if (targetFigure instanceof ExpressionFigure) {
        dropType = DropType.DROP_EXPRESSION;
        if (isTragetOutputNode) {
            // INPUT => OUTPUT
            return XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
        } else if (isTragetInputNode) {
            // INPUT => INPUT ,can't dnd in the same tree
            boolean isValid = checkDropInputValid(targetModel);
            if (isValid) {
                isValid = XmlMapUtil.isExpressionEditable((TreeNode) targetModel);
            }
            return isValid;
        }
        return true;
    } else // drop tree filter
    if (targetFigure instanceof FilterTextArea) {
        dropType = DropType.DROP_FILTER;
        return true;
    } else {
        if (objects.getType() == TransferdType.INPUT) {
            if (isTragetOutputNode) {
                return checkDropOutputDocChildValid(targetModel);
            } else if (isVar || isDropVarTable) {
                dropType = DropType.DROP_INSERT_VAR;
                return true;
            } else if (isDropInputTree) {
                dropType = DropType.DROP_INSERT_INPUT;
                return checkDropInputValid(targetModel);
            } else if (isDropOutputTree) {
                dropType = DropType.DROP_INSERT_OUTPUT;
                return true;
            }
        } else if (objects.getType() == TransferdType.VAR) {
            if (isTragetOutputNode) {
                return checkDropOutputDocChildValid(targetModel);
            } else if (isDropOutputTree) {
                dropType = DropType.DROP_INSERT_OUTPUT;
                return true;
            }
        }
    }
    return false;
}
Also used : VarNode(org.talend.designer.xmlmap.model.emf.xmlmap.VarNode) InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) VarTable(org.talend.designer.xmlmap.model.emf.xmlmap.VarTable) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TransferedObject(org.talend.designer.gefabstractmap.dnd.TransferedObject) FilterTextArea(org.talend.designer.gefabstractmap.figures.treesettings.FilterTextArea) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) OutputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)

Example 3 with ExpressionFigure

use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.

the class TreeNodeEditPart method performRequest.

@Override
public void performRequest(Request req) {
    if (RequestConstants.REQ_DIRECT_EDIT.equals(req.getType())) {
        Figure figure = null;
        DirectEditRequest drequest = (DirectEditRequest) req;
        Point figureLocation = drequest.getLocation();
        if (getFigure() instanceof TableTreeEntityFigure) {
            XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
            ArrayList collection = new ArrayList();
            collection.add(treeNodeFigure.getExpressionFigure());
            collection.add(treeNodeFigure.getBranchContent());
            figure = (Figure) treeNodeFigure.findFigureAt(figureLocation.x, figureLocation.y, new FigureSearch(collection));
        }
        if (figure instanceof IWidgetCell) {
            directEditManager = new XmlMapNodeDirectEditManager(this, new XmlMapNodeCellEditorLocator(figure, this));
        }
        if (directEditManager != null) {
            TreeNode outputTreeNode = (TreeNode) getModel();
            if (figure instanceof ExpressionFigure) {
                if (XmlMapUtil.isExpressionEditable(outputTreeNode)) {
                    Point location = drequest.getLocation();
                    if (figure.containsPoint(location)) {
                        directEditManager.show();
                        ((XmlMapGraphicViewer) getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
                    }
                }
            } else if (!(((TreeNode) getModel()).eContainer() instanceof AbstractInOutTree)) {
            // disable for RC2
            // directEditManager.show();
            // ((XmlMapGraphicViewer)
            // getViewer()).getMapperManager().setCurrentDirectEditManager(directEditManager);
            }
        }
    }
    super.performRequest(req);
}
Also used : XmlMapNodeDirectEditManager(org.talend.designer.xmlmap.parts.directedit.XmlMapNodeDirectEditManager) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) ArrayList(java.util.ArrayList) AbstractInOutTree(org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree) Point(org.eclipse.draw2d.geometry.Point) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) IFigure(org.eclipse.draw2d.IFigure) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Figure(org.eclipse.draw2d.Figure) XmlMapNodeCellEditorLocator(org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) IWidgetCell(org.talend.designer.gefabstractmap.figures.cells.IWidgetCell)

Example 4 with ExpressionFigure

use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.

the class TreeNodeEditPart method notifyChanged.

@Override
public void notifyChanged(Notification notification) {
    int type = notification.getEventType();
    int featureId = notification.getFeatureID(XmlmapPackage.class);
    XmlmapTreeNodeFigure treeNodeFigure = (XmlmapTreeNodeFigure) getFigure();
    switch(type) {
        case Notification.SET:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__LOOP:
                case XmlmapPackage.OUTPUT_TREE_NODE__GROUP:
                case XmlmapPackage.OUTPUT_TREE_NODE__AGGREGATE:
                case XmlmapPackage.TREE_NODE__OPTIONAL:
                    treeNodeFigure.getBranchContent().updateStatus();
                    break;
                case XmlmapPackage.TREE_NODE__NAME:
                    treeNodeFigure.getBranchContent().updataNameFigure();
                    break;
                case XmlmapPackage.TREE_NODE__DEFAULT_VALUE:
                    treeNodeFigure.getBranchContent().updateDefaultValueFigure();
                    break;
                case XmlmapPackage.TREE_NODE__TYPE:
                    refreshChildren();
                    break;
                case XmlmapPackage.TREE_NODE__EXPRESSION:
                    if (getModel() instanceof TreeNode && !(getModel() instanceof OutputTreeNode)) {
                        TreeNode inputTreeNodeRoot = XmlMapUtil.getTreeNodeRoot((TreeNode) getModel());
                        if (inputTreeNodeRoot != null && inputTreeNodeRoot.eContainer() instanceof InputXmlTree) {
                            InputXmlTree inputTree = (InputXmlTree) inputTreeNodeRoot.eContainer();
                            if (inputTree.isLookup()) {
                                if (((TreeNode) getModel()).getExpression() != null && !((TreeNode) getModel()).getExpression().trim().equals("")) {
                                    if (MATCHING_MODE.ALL_ROWS.toString().equals(inputTree.getMatchingMode())) {
                                        inputTree.setMatchingMode(MATCHING_MODE.UNIQUE_MATCH.toString());
                                    }
                                } else {
                                    boolean hasAtLeastOneHashKey = XmlMapUtil.hasAtLeastOneHashKey(inputTree);
                                    if (!hasAtLeastOneHashKey) {
                                        if (!MATCHING_MODE.ALL_ROWS.toString().equals(inputTree.getMatchingMode())) {
                                            inputTree.setMatchingMode(MATCHING_MODE.ALL_ROWS.toString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (getFigure() instanceof TableTreeEntityFigure) {
                        XmlmapTreeNodeFigure outputFigure = (XmlmapTreeNodeFigure) getFigure();
                        outputFigure.updateExpression();
                    }
                    break;
                case XmlmapPackage.INPUT_XML_TREE__MINIMIZED:
                    refreshSourceConnections();
                    refreshTargetConnections();
                    break;
                case XmlmapPackage.ABSTRACT_IN_OUT_TREE__MULTI_LOOPS:
                    break;
            }
            break;
        case Notification.ADD:
        case Notification.ADD_MANY:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__CHILDREN:
                    refreshChildren();
                    boolean expressionEditable = XmlMapUtil.isExpressionEditable((TreeNode) getModel());
                    if (!expressionEditable) {
                        ExpressionFigure expression = treeNodeFigure.getExpressionFigure();
                        if (expression != null) {
                            expression.setOpaque(true);
                            expression.setBackgroundColor(ColorProviderMapper.getColor(ColorInfo.COLOR_EXPREESION_DISABLE));
                        }
                    }
                    break;
                case XmlmapPackage.TREE_NODE__OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__FILTER_OUT_GOING_CONNECTIONS:
                    refreshSourceConnections();
                    break;
                case XmlmapPackage.OUTPUT_TREE_NODE__INCOMING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_INCOMING_CONNECTIONS:
                    refreshTargetConnections();
                    break;
            }
            break;
        case Notification.REMOVE:
        case Notification.REMOVE_MANY:
            switch(featureId) {
                case XmlmapPackage.TREE_NODE__CHILDREN:
                    refreshChildren();
                    ExpressionFigure expression = treeNodeFigure.getExpressionFigure();
                    if (expression != null) {
                        if (XmlMapUtil.isExpressionEditable((TreeNode) getModel())) {
                            expression.setOpaque(false);
                        }
                    }
                case XmlmapPackage.TREE_NODE__OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_OUTGOING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__FILTER_OUT_GOING_CONNECTIONS:
                    refreshSourceConnections();
                    break;
                case XmlmapPackage.OUTPUT_TREE_NODE__INCOMING_CONNECTIONS:
                case XmlmapPackage.TREE_NODE__LOOKUP_INCOMING_CONNECTIONS:
                    refreshTargetConnections();
            }
            break;
    }
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) XmlmapTreeNodeFigure(org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) Point(org.eclipse.draw2d.geometry.Point)

Example 5 with ExpressionFigure

use of org.talend.designer.gefabstractmap.figures.ExpressionFigure in project tdi-studio-se by Talend.

the class GlobalMapKeysEntityFigure method createEntityItems.

@Override
protected void createEntityItems(TableEntityElement entityElement) {
    this.globalMapNode = getEntityManager().getModel();
    expression = new ExpressionFigure();
    expression.setText(globalMapNode.getExpression());
    globalMapKey = new TextCellLabel();
    globalMapKey.setDirectEditType(DirectEditType.NODE_NAME);
    globalMapKey.setText(globalMapNode.getName());
    globalMapKey.setLabelAlignment(PositionConstants.LEFT);
    deleteImage = new ImageFigure(ImageProviderMapper.getImage(ImageInfo.DELETE));
    entityElement.add(expression);
    entityElement.add(globalMapKey);
    entityElement.add(deleteImage);
    addCheckListener();
}
Also used : ExpressionFigure(org.talend.designer.gefabstractmap.figures.ExpressionFigure) ImageFigure(org.eclipse.draw2d.ImageFigure) TextCellLabel(org.talend.designer.gefabstractmap.figures.TextCellLabel)

Aggregations

ExpressionFigure (org.talend.designer.gefabstractmap.figures.ExpressionFigure)5 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)4 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)4 InputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree)3 Point (org.eclipse.draw2d.geometry.Point)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)2 ArrayList (java.util.ArrayList)1 Figure (org.eclipse.draw2d.Figure)1 IFigure (org.eclipse.draw2d.IFigure)1 ImageFigure (org.eclipse.draw2d.ImageFigure)1 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)1 TransferedObject (org.talend.designer.gefabstractmap.dnd.TransferedObject)1 TextCellLabel (org.talend.designer.gefabstractmap.figures.TextCellLabel)1 IWidgetCell (org.talend.designer.gefabstractmap.figures.cells.IWidgetCell)1 TreeBranch (org.talend.designer.gefabstractmap.figures.table.entity.TreeBranch)1 FilterTextArea (org.talend.designer.gefabstractmap.figures.treesettings.FilterTextArea)1 XmlMapNodeCellEditorLocator (org.talend.designer.gefabstractmap.part.directedit.XmlMapNodeCellEditorLocator)1 AbstractInOutTree (org.talend.designer.xmlmap.model.emf.xmlmap.AbstractInOutTree)1 OutputXmlTree (org.talend.designer.xmlmap.model.emf.xmlmap.OutputXmlTree)1