Search in sources :

Example 1 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.

the class NewBendpointCreateCommand method redo.

/**
 * {@inheritDoc}
 */
@Override
public void redo() {
    ConnectionContainer connection = getConnectionContainer();
    ConnectionUIInformation uiInfo = getUIInfo(connection);
    Point location = m_location.getCopy();
    WorkflowEditor.adaptZoom(m_zoomManager, location, true);
    uiInfo = ConnectionUIInformation.builder(uiInfo).addBendpoint(location.x, location.y, m_index).build();
    // we need this to fire some update event up
    connection.setUIInfo(uiInfo);
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.

the class NewBendpointMoveCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    ConnectionContainer connection = getConnection();
    ConnectionUIInformation uiInfo = connection.getUIInfo();
    ConnectionUIInformation.Builder uiInfoBuilder = ConnectionUIInformation.builder(connection.getUIInfo());
    int[] p = uiInfo.getBendpoint(m_index);
    m_oldLocation = new Point(p[0], p[1]);
    Point newLocation = m_newLocation.getCopy();
    WorkflowEditor.adaptZoom(m_zoomManager, newLocation, true);
    // TODO for every single bendpoint move a new ConnectionUIInformation object needs to be created
    uiInfoBuilder.removeBendpoint(m_index);
    uiInfoBuilder.addBendpoint(newLocation.x, newLocation.y, m_index);
    // issue notification
    connection.setUIInfo(uiInfoBuilder.build());
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) Builder(org.knime.core.node.workflow.ConnectionUIInformation.Builder) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) Point(org.eclipse.draw2d.geometry.Point)

Example 3 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.

the class NewBendpointMoveCommand method redo.

/**
 * {@inheritDoc}
 */
@Override
public void redo() {
    ConnectionContainer connection = getConnection();
    ConnectionUIInformation.Builder uiInfoBuilder = ConnectionUIInformation.builder(connection.getUIInfo());
    uiInfoBuilder.removeBendpoint(m_index);
    Point newLocation = m_newLocation.getCopy();
    WorkflowEditor.adaptZoom(m_zoomManager, newLocation, true);
    uiInfoBuilder.addBendpoint(newLocation.x, newLocation.y, m_index);
    // issue notification
    connection.setUIInfo(uiInfoBuilder.build());
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) Builder(org.knime.core.node.workflow.ConnectionUIInformation.Builder) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.

the class ShiftConnectionCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    m_oldPort = getLastConnectedPort();
    ConnectionContainer existingConn = getHostWFM().getIncomingConnectionFor(m_nodeID, m_oldPort);
    assert existingConn != null;
    m_newPort = getNextMatchingPort(existingConn);
    getHostWFM().removeConnection(existingConn);
    try {
        getHostWFM().addConnection(existingConn.getSource(), existingConn.getSourcePort(), m_nodeID, m_newPort);
    } catch (Exception e) {
        LOGGER.error("Unable to insert new connection - " + "restoring old connection", e);
        getHostWFM().addConnection(existingConn.getSource(), existingConn.getSourcePort(), m_nodeID, m_oldPort);
        m_oldPort = -1;
        m_newPort = -1;
    }
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer)

Example 5 with ConnectionContainer

use of org.knime.core.node.workflow.ConnectionContainer in project knime-core by knime.

the class ShiftConnectionCommand method undo.

/**
 * {@inheritDoc}
 */
@Override
public void undo() {
    ConnectionContainer newConn = getHostWFM().getIncomingConnectionFor(m_nodeID, m_newPort);
    assert newConn != null;
    getHostWFM().removeConnection(newConn);
    try {
        getHostWFM().addConnection(newConn.getSource(), newConn.getSourcePort(), m_nodeID, m_oldPort);
    } catch (Exception e) {
        LOGGER.error("Unable to redo connection shift - " + "restoring shifted connection", e);
        getHostWFM().addConnection(newConn.getSource(), newConn.getSourcePort(), m_nodeID, m_newPort);
    }
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer)

Aggregations

ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)28 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)14 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)9 NodeID (org.knime.core.node.workflow.NodeID)8 Point (org.eclipse.draw2d.geometry.Point)6 NodeContainer (org.knime.core.node.workflow.NodeContainer)6 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)5 ConnectionID (org.knime.core.node.workflow.ConnectionID)4 Map (java.util.Map)3 Builder (org.knime.core.node.workflow.ConnectionUIInformation.Builder)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)2 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)2 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)2 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)2 List (java.util.List)1 Set (java.util.Set)1 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1