Search in sources :

Example 1 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class ModifyMergeOrderAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    INode node = null;
    if (o instanceof ConnectionPart) {
        ConnectionPart part = (ConnectionPart) o;
        IConnection connection = (IConnection) part.getModel();
        node = connection.getTarget();
    } else if (o instanceof ConnLabelEditPart) {
        ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
        Connection connection = (Connection) part.getModel();
        node = connection.getTarget();
    } else if (o instanceof NodePart) {
        node = (Node) ((NodePart) o).getModel();
    }
    if ((node == null) || (!node.getComponent().useMerge())) {
        return false;
    }
    mergeComponent = node;
    setText(TEXT_MERGE_ORDER);
    return true;
}
Also used : INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 2 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class ModifyOutputOrderAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    if (getSelectedObjects().isEmpty()) {
        return false;
    }
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object o = parts.get(0);
    EConnectionType tmpConnType = null;
    INode node = null;
    if (o instanceof ConnectionPart) {
        ConnectionPart part = (ConnectionPart) o;
        Connection connection = (Connection) part.getModel();
        node = connection.getSource();
        tmpConnType = connection.getLineStyle();
    } else if (o instanceof ConnLabelEditPart) {
        ConnectionPart part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
        Connection connection = (Connection) part.getModel();
        node = connection.getSource();
        tmpConnType = connection.getLineStyle();
    } else if (o instanceof NodePart) {
        node = (Node) ((NodePart) o).getModel();
    }
    if (node == null) {
        return false;
    }
    usedConnType = false;
    //$NON-NLS-1$
    String midStr = "output";
    int nb = 0;
    for (Connection connection : (List<Connection>) node.getOutgoingConnections()) {
        if (getConnectionCategory() != null && connection.getLineStyle().hasConnectionCategory(getConnectionCategory())) {
            // avoid the not useful action, on connection.
            if (tmpConnType == null || tmpConnType != null && tmpConnType.hasConnectionCategory(getConnectionCategory())) {
                nb++;
            }
        } else // feature 4505 & 8087
        if (getConnectionType() != null && connection.getLineStyle() == getConnectionType()) {
            midStr = getConnectionType().getDefaultLinkName();
            usedConnType = true;
            // avoid the not useful action, on connection.
            if (tmpConnType == null || tmpConnType != null && tmpConnType == getConnectionType()) {
                nb++;
            }
        }
    }
    if (nb < 2) {
        return false;
    }
    multipleOutputNode = node;
    //$NON-NLS-1$
    setText(Messages.getString("ModifyOutputOrderAction.text", midStr));
    return true;
}
Also used : INode(org.talend.core.model.process.INode) Connection(org.talend.designer.core.ui.editor.connections.Connection) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart) EConnectionType(org.talend.core.model.process.EConnectionType) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 3 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class FilterTraceColumnAction method calculateEnabled.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
     */
@Override
protected boolean calculateEnabled() {
    List parts = getSelectedObjects();
    if (parts.size() != 1) {
        return false;
    }
    Object input = parts.get(0);
    if (input instanceof ConnectionPart) {
        ConnectionPart connPart = (ConnectionPart) input;
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                connection = (Connection) connPart.getModel();
                return connection.enableTraces() && connection.checkTraceShowEnable();
            }
        }
    }
    if (input instanceof ConnLabelEditPart) {
        ConnLabelEditPart labelPart = (ConnLabelEditPart) input;
        ConnectionPart connPart = (ConnectionPart) labelPart.getParent();
        List childParts = connPart.getChildren();
        for (Object part : childParts) {
            if (part != null && part instanceof ConnectionTraceEditPart) {
                connection = (Connection) connPart.getModel();
                return connection.enableTraces() && connection.checkTraceShowEnable();
            }
        }
    }
    if (input instanceof ConnectionTraceEditPart) {
        ConnectionTraceEditPart connTrace = (ConnectionTraceEditPart) input;
        if (connTrace.getParent() instanceof ConnectionPart) {
            ConnectionPart connPart = (ConnectionPart) connTrace.getParent();
            connection = (Connection) connPart.getModel();
            return connection.enableTraces() && connection.checkTraceShowEnable();
        }
    }
    return false;
}
Also used : ConnectionTraceEditPart(org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart) List(java.util.List) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Example 4 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class CreateComponentOnLinkHelper method unselectAllConnections.

public static void unselectAllConnections(SubjobContainerPart containerPart) {
    List children = containerPart.getChildren();
    for (int i = 0; i < children.size(); i++) {
        Object object = children.get(i);
        if (object instanceof NodeContainerPart) {
            NodeContainerPart nodeContainerPart = (NodeContainerPart) object;
            Object nodePart = nodeContainerPart.getChildren().get(0);
            if (nodePart instanceof NodePart) {
                List sourceConnections = ((NodePart) nodePart).getSourceConnections();
                for (int j = 0; j < sourceConnections.size(); j++) {
                    Object connectionPart = sourceConnections.get(j);
                    if (connectionPart instanceof ConnectionPart) {
                        ConnectionPart connPart = (ConnectionPart) connectionPart;
                        org.talend.designer.core.ui.editor.connections.Connection conn = (org.talend.designer.core.ui.editor.connections.Connection) connPart.getModel();
                        ConnectionFigure fig = (ConnectionFigure) connPart.getFigure();
                        if (fig.getLineWidth() != 1) {
                            fig.setLineWidth(1);
                            connPart.refresh();
                        }
                    }
                }
            }
        }
    }
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ConnectionFigure(org.talend.designer.core.ui.editor.connections.ConnectionFigure) IConnection(org.talend.core.model.process.IConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) Point(org.eclipse.draw2d.geometry.Point) Connection(org.talend.designer.core.ui.editor.connections.Connection) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Example 5 with ConnectionPart

use of org.talend.designer.core.ui.editor.connections.ConnectionPart in project tdi-studio-se by Talend.

the class CreateComponentOnLinkHelper method getConnectionParts.

public static List<ConnectionPart> getConnectionParts(ProcessPart processPart, Point point, Node node) {
    List<ConnectionPart> connectionParts = new ArrayList<ConnectionPart>();
    for (Object child : processPart.getChildren()) {
        if (child instanceof SubjobContainerPart) {
            SubjobContainerPart subJobPart = (SubjobContainerPart) child;
            for (Object sChilde : subJobPart.getChildren()) {
                if (sChilde instanceof NodeContainerPart) {
                    NodeContainerPart nodeCPart = (NodeContainerPart) sChilde;
                    for (Object nChild : nodeCPart.getChildren()) {
                        if (nChild instanceof NodePart) {
                            for (Object conn : ((NodePart) nChild).getTargetConnections()) {
                                if (conn instanceof ConnectionPart && canCreateNodeOnLink((Connection) ((ConnectionPart) conn).getModel(), node)) {
                                    ConnectionPart connPart = (ConnectionPart) conn;
                                    // if (connPart.getFigure() != null &&
                                    // connPart.getFigure().getBounds().contains(point)) {
                                    connectionParts.add((ConnectionPart) conn);
                                // }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return connectionParts;
}
Also used : NodeContainerPart(org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) PolylineConnection(org.eclipse.draw2d.PolylineConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) ConnectionPart(org.talend.designer.core.ui.editor.connections.ConnectionPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart) NodePart(org.talend.designer.core.ui.editor.nodes.NodePart)

Aggregations

ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)22 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)17 List (java.util.List)15 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)14 Connection (org.talend.designer.core.ui.editor.connections.Connection)13 ArrayList (java.util.ArrayList)9 NodeContainerPart (org.talend.designer.core.ui.editor.nodecontainer.NodeContainerPart)8 Node (org.talend.designer.core.ui.editor.nodes.Node)7 NoteEditPart (org.talend.designer.core.ui.editor.notes.NoteEditPart)7 ProcessPart (org.talend.designer.core.ui.editor.process.ProcessPart)7 SubjobContainerPart (org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)7 Point (org.eclipse.draw2d.geometry.Point)6 EditPart (org.eclipse.gef.EditPart)6 IConnection (org.talend.core.model.process.IConnection)6 PolylineConnection (org.eclipse.draw2d.PolylineConnection)5 NodeLabelEditPart (org.talend.designer.core.ui.editor.nodes.NodeLabelEditPart)5 INode (org.talend.core.model.process.INode)4 ConnectionTraceEditPart (org.talend.designer.core.ui.editor.connections.ConnectionTraceEditPart)4 PointList (org.eclipse.draw2d.geometry.PointList)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3