Search in sources :

Example 6 with TableTreeEntityFigure

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

the class VarColumnAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    Point ref = null;
    final VarTablePart varTablePart = (VarTablePart) MapperUtils.getMapperTablePart(entityManager.getEditPart());
    if (entityManager.isTableMinimized()) {
        if (isSource) {
            ref = varTablePart.getFigure().getBounds().getRight();
        } else {
            ref = varTablePart.getFigure().getBounds().getLeft();
        }
    } else if (getOwner() instanceof TableTreeEntityFigure) {
        TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
        // normal column
        if (nodeFigure.getTreeBranch() == null) {
            if (isSource) {
                ref = getOwner().getBounds().getRight();
            } else {
                if (nodeFigure.getElement() != null) {
                    ref = nodeFigure.getElement().getBounds().getLeft();
                } else {
                    ref = getOwner().getBounds().getLeft();
                }
            }
            getOwner().translateToAbsolute(ref);
        }
    } else if (getOwner() instanceof VarEntityFigure) {
        VarEntityFigure varNodeFigure = (VarEntityFigure) getOwner();
        if (isSource) {
            ref = getOwner().getBounds().getRight();
            ref.x = varTablePart.getFigure().getBounds().getRight().x;
        } else {
            if (varNodeFigure.getExpression() != null) {
                ref = varNodeFigure.getExpression().getBounds().getLeft();
            } else {
                ref = getOwner().getBounds().getLeft();
            }
        }
        getOwner().translateToAbsolute(ref);
    } else {
        ref = getOwner().getBounds().getCenter();
        getOwner().translateToAbsolute(ref);
    }
    return ref;
}
Also used : VarEntityFigure(org.talend.designer.gefabstractmap.figures.var.VarEntityFigure) TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) VarTablePart(org.talend.designer.gefabstractmap.part.VarTablePart) Point(org.eclipse.draw2d.geometry.Point)

Example 7 with TableTreeEntityFigure

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

the class ConnectionColumnAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    if (connectionPart == null) {
        return getOwner().getBounds().getLeft();
    }
    MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
    boolean loctionRight = false;
    if (mapperTablePart instanceof InputTablePart) {
        loctionRight = true;
    }
    Point ref = null;
    if (mapperTablePart != null && entityManager.isTableMinimized()) {
        if (loctionRight) {
            ref = mapperTablePart.getFigure().getBounds().getRight();
        } else {
            ref = mapperTablePart.getFigure().getBounds().getLeft();
        }
    } else {
        if (getOwner() == null) {
            return null;
        } else if (getOwner() instanceof TableTreeEntityFigure) {
            TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
            if (nodeFigure.getElement() != null) {
                if (loctionRight) {
                    ref = nodeFigure.getElement().getBounds().getRight();
                } else {
                    ref = nodeFigure.getElement().getBounds().getLeft();
                }
                getOwner().translateToAbsolute(ref);
            }
        } else {
            ref = getOwner().getBounds().getCenter();
            getOwner().translateToAbsolute(ref);
        }
    }
    if (mapperTablePart != null && ref != null) {
        IFigure treeFigure = mapperTablePart.getFigure();
        if (loctionRight) {
            int avialableX = treeFigure.getBounds().getRight().x;
            if (ref.x > avialableX) {
                ref.x = avialableX;
            }
        } else {
            int avialableX = treeFigure.getBounds().x;
            if (ref.x < avialableX) {
                ref.x = avialableX;
            }
        }
    }
    if (connectionPart instanceof BaseConnectionEditPart && connectionPart.getFigure() instanceof PolylineConnection) {
        BaseConnectionEditPart baseConnectionPart = (BaseConnectionEditPart) connectionPart;
        PolylineConnection connFigure = (PolylineConnection) connectionPart.getFigure();
        org.eclipse.swt.graphics.Point avilableSize = entityManager.getGraphicalViewer().getControl().getSize();
        if (forceDarshDot) {
            connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
        } else if (ref != null) {
            if (ref.y < 0) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = 0;
                }
                if (loctionRight) {
                    baseConnectionPart.setSourceConcained(false);
                } else {
                    baseConnectionPart.setTargetContained(false);
                }
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else if (ref.y > avilableSize.y) {
                if (!(baseConnectionPart instanceof LookupConnectionPart)) {
                    ref.y = avilableSize.y;
                }
                if (loctionRight) {
                    baseConnectionPart.setSourceConcained(false);
                } else {
                    baseConnectionPart.setTargetContained(false);
                }
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else {
                if (loctionRight) {
                    baseConnectionPart.setSourceConcained(true);
                } else {
                    baseConnectionPart.setTargetContained(true);
                }
                if (!baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            }
        }
    }
    return ref;
}
Also used : TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) Point(org.eclipse.draw2d.geometry.Point) PolylineConnection(org.eclipse.draw2d.PolylineConnection) LookupConnectionPart(org.talend.designer.gefabstractmap.part.LookupConnectionPart) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)

Example 8 with TableTreeEntityFigure

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

the class FilterColumnAnchor method getReferencePoint.

@Override
public Point getReferencePoint() {
    if (connectionPart == null) {
        return getOwner().getBounds().getLeft();
    }
    MapperTablePart mapperTablePart = MapperUtils.getMapperTablePart(entityManager.getEditPart());
    boolean loctionRight = true;
    if (connectionPart.getTarget() instanceof InputTablePart) {
        loctionRight = false;
    }
    Point ref = null;
    if (mapperTablePart != null && entityManager.isTableMinimized()) {
        if (loctionRight) {
            ref = mapperTablePart.getFigure().getBounds().getRight();
        } else {
            ref = mapperTablePart.getFigure().getBounds().getLeft();
        }
    } else {
        if (getOwner() == null) {
            return null;
        } else if (getOwner() instanceof TableTreeEntityFigure) {
            TableTreeEntityFigure nodeFigure = (TableTreeEntityFigure) getOwner();
            if (nodeFigure.getElement() != null) {
                if (loctionRight) {
                    ref = nodeFigure.getElement().getBounds().getRight();
                } else {
                    ref = nodeFigure.getElement().getBounds().getLeft();
                }
                getOwner().translateToAbsolute(ref);
            }
        } else {
            ref = getOwner().getBounds().getCenter();
            getOwner().translateToAbsolute(ref);
        }
    }
    if (mapperTablePart != null && ref != null) {
        IFigure treeFigure = mapperTablePart.getFigure();
        if (loctionRight) {
            int avialableX = treeFigure.getBounds().getRight().x;
            if (ref.x > avialableX) {
                ref.x = avialableX;
            }
        } else {
            int avialableX = treeFigure.getBounds().x;
            if (ref.x < avialableX) {
                ref.x = avialableX;
            }
        }
    }
    if (connectionPart instanceof BaseConnectionEditPart && connectionPart.getFigure() instanceof PolylineConnection) {
        BaseConnectionEditPart baseConnectionPart = (BaseConnectionEditPart) connectionPart;
        PolylineConnection connFigure = (PolylineConnection) connectionPart.getFigure();
        org.eclipse.swt.graphics.Point avilableSize = entityManager.getGraphicalViewer().getControl().getSize();
        if (ref != null) {
            if (ref.y < 0) {
                ref.y = 0;
                baseConnectionPart.setSourceConcained(false);
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else if (ref.y > avilableSize.y) {
                ref.y = avilableSize.y;
                baseConnectionPart.setSourceConcained(false);
                if (baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                } else {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            } else {
                baseConnectionPart.setSourceConcained(true);
                if (!baseConnectionPart.isDOTStyle()) {
                    connFigure.setLineStyle(SWT.LINE_SOLID);
                }
            }
        }
    }
    return ref;
}
Also used : TableTreeEntityFigure(org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure) Point(org.eclipse.draw2d.geometry.Point) MapperTablePart(org.talend.designer.gefabstractmap.part.MapperTablePart) InputTablePart(org.talend.designer.gefabstractmap.part.InputTablePart) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure) BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Example 9 with TableTreeEntityFigure

use of org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure 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)

Aggregations

TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)9 Point (org.eclipse.draw2d.geometry.Point)7 IFigure (org.eclipse.draw2d.IFigure)4 PolylineConnection (org.eclipse.draw2d.PolylineConnection)2 ExpressionFigure (org.talend.designer.gefabstractmap.figures.ExpressionFigure)2 ExpandCollapseFigure (org.talend.designer.gefabstractmap.figures.table.entity.ExpandCollapseFigure)2 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)2 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)2 MapperTablePart (org.talend.designer.gefabstractmap.part.MapperTablePart)2 TableEntityPart (org.talend.designer.gefabstractmap.part.TableEntityPart)2 XmlmapTreeNodeFigure (org.talend.designer.xmlmap.figures.treeNode.XmlmapTreeNodeFigure)2 OutputTreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode)2 TreeNode (org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Figure (org.eclipse.draw2d.Figure)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)1 IWidgetCell (org.talend.designer.gefabstractmap.figures.cells.IWidgetCell)1 TableEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableEntityFigure)1