Search in sources :

Example 26 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project tdi-studio-se by Talend.

the class ConnectionResumingEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    ConnectionPart connectionPart;
    connectionPart = (ConnectionPart) getParent();
    Connection conn = (Connection) connectionPart.getModel();
    ConnectionResumingFigure checkPointFigure = (ConnectionResumingFigure) getFigure();
    ConnectionResuming connectionResuming = (ConnectionResuming) getModel();
    String resum = connectionResuming.getResuming();
    if (resum == null) {
        Point offset = conn.getConnectionLabel().getOffset();
        connectionResuming.getOffset().x = offset.x;
        connectionResuming.getOffset().y = offset.y;
        this.removeEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE);
    } else {
        this.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ConnTextMovePolicy());
    }
    if (conn.getPropertyValue(EParameterName.RESUMING_CHECKPOINT.getName()) == null)
        checkPointFigure.setResumingCheckPoint(false);
    else
        checkPointFigure.setResumingCheckPoint(conn.getPropertyValue(EParameterName.RESUMING_CHECKPOINT.getName()).toString().equals("true") ? true : false);
    Dimension size = checkPointFigure.getPreferredSize();
    connectionResuming.setSize(size);
    String connectionName = ((Connection) connectionPart.getModel()).getConnectionLabel().getLabelText();
    Point offset = ((ConnectionResuming) getModel()).getOffset();
    ConnectionResumingConstraint constraint = new //$NON-NLS-1$
    ConnectionResumingConstraint(//$NON-NLS-1$
    connectionName, //$NON-NLS-1$
    size, //$NON-NLS-1$
    "center", //$NON-NLS-1$
    offset, (PolylineConnection) connectionPart.getFigure());
    connectionPart.setLayoutConstraint(this, getFigure(), constraint);
    // add resum tooltip
    Label toolTipLabel = new Label();
    String toolTipText;
    if (conn.getPropertyValue(EParameterName.RESUMLABEL.getName()) == null)
        toolTipText = "";
    else
        toolTipText = conn.getPropertyValue(EParameterName.RESUMLABEL.getName()).toString();
    toolTipLabel.setText(toolTipText);
    checkPointFigure.setToolTip(toolTipLabel);
}
Also used : PolylineConnection(org.eclipse.draw2d.PolylineConnection) Label(org.eclipse.draw2d.Label) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 27 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project tdi-studio-se by Talend.

the class ConnectionTraceEditPart method refreshVisuals.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
     */
@Override
protected void refreshVisuals() {
    ConnectionPart connectionPart;
    connectionPart = (ConnectionPart) getParent();
    Connection conn = (Connection) connectionPart.getModel();
    IElementParameter element = conn.getElementParameter(EParameterName.TRACES_CONNECTION_ENABLE.getName());
    Boolean flag = false;
    if (element != null) {
        flag = (Boolean) element.getValue();
    }
    ConnectionTraceFigure htmlFigure = (ConnectionTraceFigure) getFigure();
    ConnectionTrace connectionTrace = (ConnectionTrace) getModel();
    TraceData trace = connectionTrace.getTrace();
    if (trace == null) {
        Point offset = conn.getConnectionLabel().getOffset();
        connectionTrace.getOffset().x = offset.x;
        connectionTrace.getOffset().y = offset.y;
        this.removeEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE);
    } else {
        this.installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ConnTextMovePolicy());
    }
    htmlFigure.setTraceData(trace, flag, conn.checkTraceShowEnable());
    Dimension size = htmlFigure.getPreferredSize();
    connectionTrace.setSize(size);
    String connectionName = ((Connection) connectionPart.getModel()).getConnectionLabel().getLabelText();
    Point offset = ((ConnectionTrace) getModel()).getOffset();
    ConnectionTraceConstraint constraint = new //$NON-NLS-1$
    ConnectionTraceConstraint(//$NON-NLS-1$
    connectionName, //$NON-NLS-1$
    size, //$NON-NLS-1$
    "center", //$NON-NLS-1$
    offset, (PolylineConnection) connectionPart.getFigure());
    connectionPart.setLayoutConstraint(this, getFigure(), constraint);
}
Also used : PolylineConnection(org.eclipse.draw2d.PolylineConnection) IElementParameter(org.talend.core.model.process.IElementParameter) TraceData(org.talend.core.model.process.TraceData) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 28 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection 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 29 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection 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 30 with PolylineConnection

use of org.eclipse.draw2d.PolylineConnection in project tdi-studio-se by Talend.

the class TreeNodeEditPart method refreshChildrenSourceConnections.

public void refreshChildrenSourceConnections(TreeNodeEditPart rootPart, boolean expanded) {
    for (Object obj : getChildren()) {
        if (obj instanceof TreeNodeEditPart) {
            TreeNodeEditPart part = (TreeNodeEditPart) obj;
            if (expanded) {
                // do collapse
                part.setRootAnchor(rootPart.getFigure());
            } else {
                part.setRootAnchor(null);
            }
            if (part.getSourceConnections() != null) {
                for (Object conn : part.getSourceConnections()) {
                    if (conn instanceof BaseConnectionEditPart) {
                        BaseConnectionEditPart connectionEditPart = (BaseConnectionEditPart) conn;
                        if (connectionEditPart.getFigure() instanceof PolylineConnection) {
                            PolylineConnection connFigure = (PolylineConnection) connectionEditPart.getFigure();
                            if (expanded) {
                                connectionEditPart.setNodeCollapsed(true);
                                connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                            } else {
                                connectionEditPart.setNodeCollapsed(false);
                                if (!connectionEditPart.isDOTStyle()) {
                                    connFigure.setLineStyle(SWT.LINE_SOLID);
                                } else {
                                    connFigure.setLineStyle(SWT.LINE_DASHDOTDOT);
                                }
                            }
                        }
                        connectionEditPart.refresh();
                    }
                }
            }
            part.refreshChildrenSourceConnections(rootPart, expanded);
        }
    }
}
Also used : BaseConnectionEditPart(org.talend.designer.gefabstractmap.part.BaseConnectionEditPart) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

Aggregations

PolylineConnection (org.eclipse.draw2d.PolylineConnection)43 Point (org.eclipse.draw2d.geometry.Point)11 PolygonDecoration (org.eclipse.draw2d.PolygonDecoration)10 IFigure (org.eclipse.draw2d.IFigure)8 BendpointConnectionRouter (org.eclipse.draw2d.BendpointConnectionRouter)6 Label (org.eclipse.draw2d.Label)6 BaseConnectionEditPart (org.talend.designer.gefabstractmap.part.BaseConnectionEditPart)5 Edge (org.eclipse.draw2d.graph.Edge)3 ArrayList (java.util.ArrayList)2 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)2 ManhattanConnectionRouter (org.eclipse.draw2d.ManhattanConnectionRouter)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 Node (org.eclipse.draw2d.graph.Node)2 NodeList (org.eclipse.draw2d.graph.NodeList)2 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)2 CurveConnectionRouter (org.talend.designer.gefabstractmap.figures.routers.CurveConnectionRouter)2 TableTreeEntityFigure (org.talend.designer.gefabstractmap.figures.table.entity.TableTreeEntityFigure)2 InputTablePart (org.talend.designer.gefabstractmap.part.InputTablePart)2 LookupConnectionPart (org.talend.designer.gefabstractmap.part.LookupConnectionPart)2