Search in sources :

Example 21 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class DesignerColorUtils method initPreferenceDefault.

/**
     * used for initialize preference.
     */
public static void initPreferenceDefault(IPreferenceStore store) {
    if (store == null) {
        // store must be the designer core preference store.
        return;
    }
    // background
    store.setDefault(DesignerColorUtils.JOBDESIGNER_EGITOR_BACKGROUND_COLOR_NAME, StringConverter.asString(DesignerColorUtils.DEFAULT_EDITOR_COLOR));
    store.setDefault(DesignerColorUtils.READONLY_BACKGROUND_COLOR_NAME, StringConverter.asString(DesignerColorUtils.DEFAULT_READONLY_COLOR));
    // subjob
    store.setDefault(DesignerColorUtils.SUBJOB_COLOR_NAME, StringConverter.asString(DesignerColorUtils.SUBJOB_COLOR));
    store.setDefault(DesignerColorUtils.SUBJOB_TITLE_COLOR_NAME, StringConverter.asString(DesignerColorUtils.SUBJOB_TITLE_COLOR));
    // mr
    store.setDefault(DesignerColorUtils.JOBLET_COLOR_NAME, StringConverter.asString(DesignerColorUtils.JOBLET_COLOR));
    // mr
    store.setDefault(DesignerColorUtils.MRGROUP_COLOR_NAME, StringConverter.asString(DesignerColorUtils.MR_COLOR));
    // connection
    for (EConnectionType connType : EConnectionType.values()) {
        store.setDefault(getPreferenceConnectionName(connType), StringConverter.asString(connType.getRGB()));
    }
}
Also used : EConnectionType(org.talend.core.model.process.EConnectionType)

Example 22 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class TalendEditorComponentCreationUtil method isTypeAllowed.

public static boolean isTypeAllowed(final EConnectionType connType, EList listConnType) {
    if (listConnType == null) {
        return false;
    }
    EConnectionType testedType;
    if (connType.hasConnectionCategory(IConnectionCategory.FLOW)) {
        testedType = EConnectionType.FLOW_MAIN;
    } else {
        testedType = connType;
    }
    CONNECTORType currentType;
    for (int i = 0; i < listConnType.size(); i++) {
        currentType = (CONNECTORType) listConnType.get(i);
        EConnectionType tempType = EConnectionType.getTypeFromName(currentType.getCTYPE());
        if (tempType == testedType) {
            int maxInput = currentType.getMAXINPUT();
            int minInput = currentType.getMININPUT();
            if (maxInput > 0 || minInput > 0) {
                return true;
            }
        }
    }
    return false;
}
Also used : CONNECTORType(org.talend.designer.core.model.utils.emf.component.CONNECTORType) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 23 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class TalendBorderItemRectilinearRouter method manualHorizontalScrolBarCase.

private boolean manualHorizontalScrolBarCase(Connection conn) {
    PointList points = conn.getPoints();
    Point start = getStartPoint(conn);
    Point end = getEndPoint(conn);
    boolean handle = false;
    boolean processHandle = false;
    if ((request != null) && (request instanceof CreateConnectionRequest)) {
        start = conn.getSourceAnchor().getReferencePoint();
        CreateConnectionRequest createRequest = (CreateConnectionRequest) request;
        if (createRequest.getTargetEditPart() != null && createRequest.getTargetEditPart() != createRequest.getSourceEditPart() && createRequest.getTargetEditPart().getModel() instanceof Node) {
            PointList pointList = new PointList();
            conn.translateToRelative(start);
            pointList.addPoint(start);
            Point targetPoint = conn.getTargetAnchor().getReferencePoint();
            conn.translateToRelative(targetPoint);
            pointList.addPoint(targetPoint);
            conn.setPoints(pointList);
            handle = true;
        } else if (createRequest.getTargetEditPart() != null && createRequest.getTargetEditPart() != createRequest.getSourceEditPart() && createRequest.getTargetEditPart() instanceof ProcessPart) {
            processHandle = true;
        }
    }
    if (conn instanceof ConnectionFigure) {
        IConnection connection = ((ConnectionFigure) conn).getConnection();
        EConnectionType lineStyle = connection.getLineStyle();
        EConnectionCategory category = lineStyle.getCategory();
        if (category == EConnectionCategory.OTHER && (lineStyle == EConnectionType.ON_COMPONENT_ERROR || lineStyle == EConnectionType.ON_COMPONENT_OK || lineStyle == EConnectionType.ON_SUBJOB_ERROR || lineStyle == EConnectionType.ON_SUBJOB_OK || lineStyle == EConnectionType.RUN_IF)) {
            return handle || processHandle;
        }
    }
    if (!handle) {
        conn.translateToRelative(start);
        points.setPoint(start, 0);
        conn.translateToRelative(end);
        points.setPoint(end, points.size() - 1);
        conn.setPoints(points);
    }
    return handle || processHandle;
}
Also used : PointList(org.eclipse.draw2d.geometry.PointList) Node(org.talend.designer.core.ui.editor.nodes.Node) IConnection(org.talend.core.model.process.IConnection) EConnectionCategory(org.talend.core.model.process.EConnectionCategory) Point(org.eclipse.draw2d.geometry.Point) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) CreateConnectionRequest(org.eclipse.gef.requests.CreateConnectionRequest) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 24 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class TalendBorderItemRectilinearRouter method manualPosition.

private boolean manualPosition(Connection conn, boolean horizontalHandle) {
    boolean isCreation = false;
    boolean isReconnect = false;
    boolean alreadyHandle = false;
    if (!(conn instanceof PolylineConnectionEx)) {
        return false;
    }
    if (this.request != null) {
        if (request instanceof CreateConnectionRequest) {
            isCreation = true;
        } else if (request instanceof ReconnectRequest) {
            isReconnect = true;
        }
    }
    IConnection connection = null;
    EConnectionCategory category = null;
    EConnectionType lineStyle = null;
    Rectangle sourceBounds = null;
    Rectangle targetBounds = null;
    if (conn instanceof ConnectionFigure) {
        connection = ((ConnectionFigure) conn).getConnection();
        if (!(connection.getSource() instanceof Node)) {
            return false;
        }
        lineStyle = connection.getLineStyle();
        category = lineStyle.getCategory();
        sourceBounds = new Rectangle(((Node) connection.getSource()).getLocation(), ((Node) connection.getSource()).getSize());
        targetBounds = new Rectangle(((Node) connection.getTarget()).getLocation(), ((Node) connection.getTarget()).getSize());
    }
    if (lineStyle == null) {
        lineStyle = ConnectionManager.getNewConnectionType();
        category = lineStyle.getCategory();
    }
    if (isCreation) {
        if (((CreateConnectionRequest) request).getSourceEditPart() == null) {
            return false;
        }
        if ((((CreateConnectionRequest) request).getTargetEditPart() == null) || horizontalHandle) {
            if (conn.getPoints().size() <= 2) {
                makeUpConnection(conn);
            }
            return false;
        }
    }
    if ((sourceBounds == null) && isCreation) {
        Node source = (Node) ((CreateConnectionRequest) request).getSourceEditPart().getModel();
        if (source != null) {
            sourceBounds = new Rectangle(source.getLocation(), source.getSize());
        }
    }
    if ((targetBounds == null) && isCreation) {
        Object obj = ((CreateConnectionRequest) request).getTargetEditPart().getModel();
        if (obj instanceof Node) {
            Node target = (Node) obj;
            if (target != null) {
                targetBounds = new Rectangle(target.getLocation(), target.getSize());
            }
        } else {
            Point lastPoint = conn.getPoints().getLastPoint();
            targetBounds = new Rectangle(lastPoint, new Dimension(2 * OFFSET, 2 * OFFSET));
        }
    }
    if (isReconnect) {
        if (((ReconnectRequest) request).getTarget() != null) {
            Object obj = ((ReconnectRequest) request).getTarget().getModel();
            if (obj instanceof Node) {
                Node target = (Node) obj;
                if (target != null) {
                    targetBounds = new Rectangle(target.getLocation(), target.getSize());
                }
            }
        } else {
            Point lastPoint = conn.getPoints().getLastPoint();
            targetBounds = new Rectangle(lastPoint, new Dimension(2 * OFFSET, 2 * OFFSET));
        }
    }
    if (targetBounds == null) {
        return false;
    }
    ((PolylineConnectionEx) conn).setRoundedBendpointsRadius(32);
    PointList points = conn.getPoints();
    PointList pointList = new PointList();
    Point firstpoint = points.getFirstPoint();
    Point lastpoint = points.getLastPoint();
    if (category == EConnectionCategory.MAIN && lineStyle != EConnectionType.FLOW_REF) {
        if ((sourceBounds.x > targetBounds.x) && (sourceBounds.y == targetBounds.y)) {
            pointList.addPoint(firstpoint);
            pointList.addPoint(firstpoint.x + OFFSET, firstpoint.y);
            pointList.addPoint(firstpoint.x + OFFSET, firstpoint.y + 2 * OFFSET);
            pointList.addPoint(lastpoint.x - OFFSET, lastpoint.y + 2 * OFFSET);
            pointList.addPoint(lastpoint.x - OFFSET, lastpoint.y);
            pointList.addPoint(lastpoint);
            alreadyHandle = true;
        } else if ((sourceBounds.x > targetBounds.x) || (sourceBounds.getTopRight().x == targetBounds.getTopLeft().x) || ((sourceBounds.getTopLeft().x == targetBounds.getTopRight().x) && (sourceBounds.getTopLeft().y != targetBounds.getTopRight().y))) {
            pointList.addPoint(firstpoint);
            pointList.addPoint(firstpoint.x + OFFSET, firstpoint.y);
            pointList.addPoint(firstpoint.x + OFFSET, (sourceBounds.getCenter().y + targetBounds.getCenter().y) / 2);
            pointList.addPoint(lastpoint.x - OFFSET, (sourceBounds.getCenter().y + targetBounds.getCenter().y) / 2);
            pointList.addPoint(lastpoint.x - OFFSET, lastpoint.y);
            pointList.addPoint(lastpoint);
            alreadyHandle = true;
        } else if (sourceBounds.x == targetBounds.x) {
            pointList.addPoint(firstpoint);
            pointList.addPoint(firstpoint.x + 2 * OFFSET, firstpoint.y);
            pointList.addPoint(firstpoint.x + 2 * OFFSET, (sourceBounds.getCenter().y + targetBounds.getCenter().y) / 2);
            pointList.addPoint(lastpoint.x - 2 * OFFSET, (sourceBounds.getCenter().y + targetBounds.getCenter().y) / 2);
            pointList.addPoint(lastpoint.x - 2 * OFFSET, lastpoint.y);
            pointList.addPoint(lastpoint);
            alreadyHandle = true;
        } else if (Math.abs(sourceBounds.getCenter().y - targetBounds.getCenter().y) == 4 * OFFSET) {
            if ((firstpoint.x + lastpoint.x) / 2 - OFFSET <= firstpoint.x) {
                return false;
            }
            ((PolylineConnectionEx) conn).setRoundedBendpointsRadius(16);
        }
    } else if (category == EConnectionCategory.OTHER && (lineStyle == EConnectionType.FLOW_REF || lineStyle == EConnectionType.TABLE_REF)) {
        if (targetBounds.y == sourceBounds.y) {
            pointList.addPoint(firstpoint);
            pointList.addPoint(firstpoint.x, firstpoint.y + OFFSET);
            pointList.addPoint(lastpoint.x, firstpoint.y + OFFSET);
            pointList.addPoint(lastpoint);
            alreadyHandle = true;
        } else if ((targetBounds.getTopRight().y == sourceBounds.getBottomLeft().y)) {
            pointList.addPoint(firstpoint);
            pointList.addPoint(firstpoint.x, firstpoint.y - OFFSET);
            pointList.addPoint(lastpoint.x, firstpoint.y - OFFSET);
            pointList.addPoint(lastpoint);
            alreadyHandle = true;
        } else if (targetBounds.getBottomLeft().y == sourceBounds.getTopRight().y) {
            pointList.addPoint(firstpoint);
            pointList.addPoint(firstpoint.x, firstpoint.y + OFFSET);
            pointList.addPoint(lastpoint.x, firstpoint.y + OFFSET);
            pointList.addPoint(lastpoint);
            alreadyHandle = true;
        } else if (Math.abs(sourceBounds.x - targetBounds.x) == 4 * OFFSET) {
            ((PolylineConnectionEx) conn).setRoundedBendpointsRadius(16);
        }
    }
    if (alreadyHandle && pointList.size() > 0) {
        conn.setPoints(pointList);
    }
    return alreadyHandle;
}
Also used : ReconnectRequest(org.eclipse.gef.requests.ReconnectRequest) PointList(org.eclipse.draw2d.geometry.PointList) Node(org.talend.designer.core.ui.editor.nodes.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IConnection(org.talend.core.model.process.IConnection) EConnectionCategory(org.talend.core.model.process.EConnectionCategory) PolylineConnectionEx(org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) CreateConnectionRequest(org.eclipse.gef.requests.CreateConnectionRequest) EConnectionType(org.talend.core.model.process.EConnectionType)

Example 25 with EConnectionType

use of org.talend.core.model.process.EConnectionType in project tdi-studio-se by Talend.

the class CreateComponentOnLinkHelper method isFlowConnection.

public static boolean isFlowConnection(Connection connection) {
    if (connection != null) {
        INode source = connection.getSource();
        INodeConnector connctor = connection.getSourceNodeConnector();
        EConnectionType connectionType = source.getConnectorFromName(connctor.getName()).getDefaultConnectionType();
        return connectionType.hasConnectionCategory(EConnectionType.FLOW);
    }
    return false;
}
Also used : INode(org.talend.core.model.process.INode) EConnectionType(org.talend.core.model.process.EConnectionType) INodeConnector(org.talend.core.model.process.INodeConnector)

Aggregations

EConnectionType (org.talend.core.model.process.EConnectionType)32 INode (org.talend.core.model.process.INode)9 INodeConnector (org.talend.core.model.process.INodeConnector)9 ArrayList (java.util.ArrayList)8 IConnection (org.talend.core.model.process.IConnection)7 Node (org.talend.designer.core.ui.editor.nodes.Node)7 Point (org.eclipse.draw2d.geometry.Point)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 List (java.util.List)4 EConnectionCategory (org.talend.core.model.process.EConnectionCategory)4 Dimension (org.eclipse.draw2d.geometry.Dimension)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)3 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)3 MalformedPatternException (org.apache.oro.text.regex.MalformedPatternException)2 PointList (org.eclipse.draw2d.geometry.PointList)2 CreateConnectionRequest (org.eclipse.gef.requests.CreateConnectionRequest)2 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)2 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)2 HL7FileNode (org.talend.core.model.metadata.builder.connection.HL7FileNode)2