Search in sources :

Example 66 with Connection

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

the class ComponentSettingsView method setPropertiesViewerTitle.

/**
     * yzhang Comment method "setPropertiesViewerTitle".
     * 
     * @param elem
     */
private void setPropertiesViewerTitle(Element elem) {
    String label = null;
    Image image = null;
    if (elem instanceof Node) {
        label = ((Node) elem).getLabel();
        String uniqueName = ((Node) elem).getUniqueName();
        if (!label.equals(uniqueName)) {
            //$NON-NLS-1$ //$NON-NLS-2$
            label = label + "(" + uniqueName + ")";
        }
        image = CoreImageProvider.getComponentIcon(((Node) elem).getComponent(), ICON_SIZE.ICON_24);
    } else if (elem instanceof Connection) {
        label = ((Connection) elem).getElementName();
        image = ImageProvider.getImage(EImage.RIGHT_ICON);
    } else if (elem instanceof Note) {
        //$NON-NLS-1$
        label = Messages.getString("ComponentSettingsView.note");
        image = ImageProvider.getImage(EImage.PASTE_ICON);
    } else if (elem instanceof SubjobContainer) {
        //$NON-NLS-1$
        label = Messages.getString("ComponentSettingsView.subjob");
        image = ImageProvider.getImage(EImage.PASTE_ICON);
    } else if (elem instanceof ConnectionLabel) {
        label = ((ConnectionLabel) elem).getConnection().getElementName();
        image = ImageProvider.getImage(EImage.RIGHT_ICON);
    }
    tabFactory.setTitle(label, image);
    super.setTitleToolTip(label);
}
Also used : SubjobContainer(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainer) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) Note(org.talend.designer.core.ui.editor.notes.Note) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) ConnectionLabel(org.talend.designer.core.ui.editor.connections.ConnectionLabel) Image(org.eclipse.swt.graphics.Image) EImage(org.talend.commons.ui.runtime.image.EImage)

Example 67 with Connection

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

the class NodePart method propertyChange.

// ------------------------------------------------------------------------
// Abstract methods from PropertyChangeListener
/*
     * (non-Javadoc)
     * 
     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
     */
@Override
public void propertyChange(final PropertyChangeEvent changeEvent) {
    boolean needUpdateSubjob = false;
    if (!this.isActive()) {
        return;
    }
    if (changeEvent.getPropertyName().equals(Node.LOCATION)) {
        refreshVisuals();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.PERFORMANCE_DATA)) {
        refreshVisuals();
        getParent().refresh();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.INPUTS)) {
        refreshTargetConnections();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.OUTPUTS)) {
        refreshSourceConnections();
        refreshTargetConnections();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.SIZE)) {
        refreshVisuals();
        getParent().refresh();
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(Node.ICON_CHANGE)) {
        changeIcon((Node) changeEvent.getSource());
        refreshVisuals();
    } else if (changeEvent.getPropertyName().equals(EParameterName.ACTIVATE.getName())) {
        if (((INode) getModel()).isActivate()) {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(-1);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        }
    } else if (changeEvent.getPropertyName().equals(EParameterName.DUMMY.getName())) {
        if (((INode) getModel()).isActivate()) {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(-1);
        } else {
            ((NodeFigure) figure).setDummy(((Node) getModel()).isDummy());
            ((NodeFigure) figure).setAlpha(Node.ALPHA_VALUE);
        }
        ((NodeFigure) figure).repaint();
        refreshVisuals();
    } else if (changeEvent.getPropertyName().equals(EParameterName.START.getName())) {
        if (((INode) getModel()).isStart()) {
            ((NodeFigure) figure).setStart(true);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        } else {
            ((NodeFigure) figure).setStart(false);
            ((NodeFigure) figure).repaint();
            refreshVisuals();
        }
    } else if (changeEvent.getPropertyName().equals(EParameterName.HINT.getName())) {
        if (((Node) getModel()).isSetShowHint()) {
            ((NodeFigure) figure).setHint(((Node) getModel()).getShowHintText());
        } else {
            //$NON-NLS-1$ 
            ((NodeFigure) figure).setHint("");
        }
        needUpdateSubjob = true;
    } else if (changeEvent.getPropertyName().equals(EParameterName.CONNECTION_FORMAT.getName())) {
        Node node = (Node) getModel();
        for (IConnection conn : ((Node) getModel()).getOutgoingConnections()) {
            String connIdName = null;
            String oldName = conn.getUniqueName();
            if (conn instanceof Connection && conn.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
                node.getProcess().removeUniqueConnectionName(oldName);
                if (node.getProcess().checkValidConnectionName(node.getConnectionName(), false)) {
                    connIdName = node.getProcess().generateUniqueConnectionName(node.getConnectionName());
                } else {
                    //$NON-NLS-1$
                    connIdName = node.getProcess().generateUniqueConnectionName("row");
                }
                if (node.getProcess().checkValidConnectionName(connIdName)) {
                    ((Connection) conn).setUniqueName(connIdName);
                    node.getProcess().addUniqueConnectionName(connIdName);
                    ((Connection) conn).setName(connIdName);
                } else {
                    node.getProcess().addUniqueConnectionName(oldName);
                }
            }
        }
    } else if (changeEvent.getPropertyName().equals(EParameterName.REPAINT.getName())) {
        ((NodeFigure) figure).repaint();
        refreshVisuals();
        EditPart parentPart = getParent();
        if (parentPart != null) {
            parentPart.refresh();
        }
        needUpdateSubjob = true;
    }
    if (needUpdateSubjob) {
        EditPart editPart = getParent();
        if (editPart != null) {
            while ((!(editPart instanceof ProcessPart)) && (!(editPart instanceof SubjobContainerPart))) {
                editPart = editPart.getParent();
            }
            if (editPart instanceof SubjobContainerPart) {
                editPart.refresh();
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection) AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) RootEditPart(org.eclipse.gef.RootEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeEditPart(org.eclipse.gef.NodeEditPart) IConnection(org.talend.core.model.process.IConnection) ProcessPart(org.talend.designer.core.ui.editor.process.ProcessPart) SubjobContainerPart(org.talend.designer.core.ui.editor.subjobcontainer.SubjobContainerPart)

Example 68 with Connection

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

the class NodePart method getSourceConnectionAnchor.

// ------------------------------------------------------------------------
// Abstract methods from NodeEditPart
/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
     */
@Override
public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection) {
    // return new ChopboxAnchor(getFigure());
    if (connection.getModel() instanceof Connection) {
        if (((Connection) connection.getModel()).getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            ((NodeFigure) getFigure()).addSourceConnection((ConnectionFigure) connection.getFigure());
        }
    }
    Connection conn = (Connection) connection.getModel();
    NodeAnchor anchor = new NodeAnchor((NodeFigure) getFigure(), (IGraphicalNode) conn.getSource(), (IGraphicalNode) conn.getTarget(), false);
    anchor.setConnection(conn);
    return anchor;
}
Also used : Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection)

Example 69 with Connection

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

the class NodePart method getTargetConnectionAnchor.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
     */
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection) {
    if (connection.getModel() instanceof Connection) {
        if (((Connection) connection.getModel()).getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
            ((NodeFigure) getFigure()).setTargetConnection((ConnectionFigure) connection.getFigure());
        }
    }
    Connection conn = (Connection) connection.getModel();
    sourceAnchor = null;
    NodeAnchor anchor = new NodeAnchor((NodeFigure) getFigure(), (IGraphicalNode) conn.getSource(), (IGraphicalNode) conn.getTarget(), true);
    anchor.setConnection(conn);
    return anchor;
}
Also used : Connection(org.talend.designer.core.ui.editor.connections.Connection) IConnection(org.talend.core.model.process.IConnection)

Example 70 with Connection

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

the class ConnectionSetAsMainRef 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) {
        Object o = parts.get(0);
        /*
             * if (!(o instanceof ConnectionPart) && !(o instanceof ConnLabelEditPart)) { return false; }
             */
        ConnectionPart part = null;
        if (o instanceof ConnectionPart) {
            part = (ConnectionPart) o;
        } else {
            if (o instanceof ConnLabelEditPart) {
                part = (ConnectionPart) ((ConnLabelEditPart) o).getParent();
            } else {
                return false;
            }
        }
        if (!(part.getModel() instanceof Connection)) {
            return false;
        }
        connection = (Connection) part.getModel();
        if (!connection.isActivate()) {
            return false;
        }
        if (connection.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
            int nbTargetFlowIn = 0;
            INode node = connection.getTarget();
            for (IConnection currentConnec : node.getIncomingConnections()) {
                if (currentConnec.getLineStyle().equals(EConnectionType.FLOW_MAIN) || currentConnec.getLineStyle().equals(EConnectionType.FLOW_REF)) {
                    nbTargetFlowIn++;
                }
            }
            if (nbTargetFlowIn <= 1) {
                return false;
            }
            setText(TEXT_SET_REF);
        } else {
            if (connection.getLineStyle().equals(EConnectionType.FLOW_REF)) {
                setText(TEXT_SET_MAIN);
            } else {
                return false;
            }
        }
        return true;
    }
    return false;
}
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) ConnLabelEditPart(org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)

Aggregations

Connection (org.talend.designer.core.ui.editor.connections.Connection)84 IConnection (org.talend.core.model.process.IConnection)52 ArrayList (java.util.ArrayList)47 List (java.util.List)46 Node (org.talend.designer.core.ui.editor.nodes.Node)44 INode (org.talend.core.model.process.INode)35 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)28 Process (org.talend.designer.core.ui.editor.process.Process)24 IElementParameter (org.talend.core.model.process.IElementParameter)20 INodeConnector (org.talend.core.model.process.INodeConnector)18 HashMap (java.util.HashMap)12 IComponent (org.talend.core.model.components.IComponent)12 ConnectionPart (org.talend.designer.core.ui.editor.connections.ConnectionPart)12 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 NodePart (org.talend.designer.core.ui.editor.nodes.NodePart)11 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)10 Property (org.talend.core.model.properties.Property)10 Test (org.junit.Test)9 ConnLabelEditPart (org.talend.designer.core.ui.editor.connections.ConnLabelEditPart)9 Map (java.util.Map)8