Search in sources :

Example 1 with ConnectionUIInformation

use of org.knime.core.node.workflow.ConnectionUIInformation 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 ConnectionUIInformation

use of org.knime.core.node.workflow.ConnectionUIInformation 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 ConnectionUIInformation

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

the class ConnectionContainerEditPart method refreshVisuals.

/**
 * {@inheritDoc}
 */
@Override
protected void refreshVisuals() {
    super.refreshVisuals();
    LOGGER.debug("refreshing visuals for: " + getModel());
    ConnectionUIInformation ei = null;
    ei = getModel().getUIInfo();
    LOGGER.debug("modelling info: " + ei);
    // make flow variable port connections look red.
    CurvedPolylineConnection fig = (CurvedPolylineConnection) getFigure();
    if (getModel().isFlowVariablePortConnection()) {
        fig.setForegroundColor(AbstractPortFigure.getFlowVarPortColor());
    }
    // update 'curved' settings and line width
    EditorUIInformation uiInfo = getCurrentEditorSettings();
    fig.setCurved(uiInfo.getHasCurvedConnections());
    fig.setLineWidth(uiInfo.getConnectionLineWidth());
    // recreate list of bendpoints
    ArrayList<AbsoluteBendpoint> constraint = new ArrayList<AbsoluteBendpoint>();
    if (ei != null) {
        int[][] p = ei.getAllBendpoints();
        for (int i = 0; i < p.length; i++) {
            AbsoluteBendpoint bp = new AbsoluteBendpoint(p[i][0], p[i][1]);
            constraint.add(bp);
        }
    }
    fig.setRoutingConstraint(constraint);
}
Also used : AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) EditorUIInformation(org.knime.core.node.workflow.EditorUIInformation) ArrayList(java.util.ArrayList) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) CurvedPolylineConnection(org.knime.workbench.editor2.figures.CurvedPolylineConnection) AbsoluteBendpoint(org.eclipse.draw2d.AbsoluteBendpoint) Point(org.eclipse.draw2d.geometry.Point)

Example 4 with ConnectionUIInformation

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

the class NewBendpointDeleteCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    ConnectionContainer connection = getConnectionContainer();
    ConnectionUIInformation uiInfo = getUIInfo(connection);
    m_point = uiInfo.getBendpoint(m_index);
    uiInfo = ConnectionUIInformation.builder(uiInfo).removeBendpoint(m_index).build();
    // issue notification
    connection.setUIInfo(uiInfo);
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation)

Example 5 with ConnectionUIInformation

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

the class PasteFromWorkflowPersistorCommand method execute.

/**
 * {@inheritDoc}
 */
@Override
public void execute() {
    WorkflowManager manager = m_editor.getWorkflowManager().get();
    WorkflowPersistor copyPersistor = m_clipboardObject.getCopyPersistor();
    m_pastedContent = manager.paste(copyPersistor);
    NodeID[] pastedNodes = m_pastedContent.getNodeIDs();
    WorkflowAnnotation[] pastedAnnos = m_pastedContent.getAnnotations();
    // fast lookup below
    Set<NodeID> newIDs = new HashSet<NodeID>();
    List<int[]> insertedElementBounds = new ArrayList<int[]>();
    for (NodeID i : pastedNodes) {
        NodeContainer nc = manager.getNodeContainer(i);
        NodeUIInformation ui = nc.getUIInformation();
        int[] bounds = ui.getBounds();
        insertedElementBounds.add(bounds);
    }
    for (WorkflowAnnotation a : pastedAnnos) {
        int[] bounds = new int[] { a.getX(), a.getY(), a.getWidth(), a.getHeight() };
        insertedElementBounds.add(bounds);
    }
    int[] moveDist = m_shiftCalculator.calculateShift(insertedElementBounds, manager, m_clipboardObject);
    // for redo-operations we need the exact same shift.
    m_shiftCalculator = new FixedShiftCalculator(moveDist);
    for (NodeID id : pastedNodes) {
        newIDs.add(id);
        NodeContainer nc = manager.getNodeContainer(id);
        NodeUIInformation oldUI = nc.getUIInformation();
        NodeUIInformation newUI = NodeUIInformation.builder(oldUI).translate(moveDist).build();
        nc.setUIInformation(newUI);
    }
    for (ConnectionContainer conn : manager.getConnectionContainers()) {
        if (newIDs.contains(conn.getDest()) && newIDs.contains(conn.getSource())) {
            // get bend points and move them
            ConnectionUIInformation oldUI = conn.getUIInfo();
            if (oldUI != null) {
                ConnectionUIInformation newUI = ConnectionUIInformation.builder(oldUI).translate(moveDist).build();
                conn.setUIInfo(newUI);
            }
        }
    }
    for (WorkflowAnnotation a : pastedAnnos) {
        a.shiftPosition(moveDist[0], moveDist[1]);
    }
    EditPartViewer partViewer = m_editor.getViewer();
    partViewer.deselectAll();
    // select the new ones....
    if (partViewer.getRootEditPart().getContents() != null && partViewer.getRootEditPart().getContents() instanceof WorkflowRootEditPart) {
        WorkflowRootEditPart rootEditPart = (WorkflowRootEditPart) partViewer.getRootEditPart().getContents();
        rootEditPart.setFutureSelection(pastedNodes);
        rootEditPart.setFutureAnnotationSelection(Arrays.asList(pastedAnnos));
    }
}
Also used : ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowPersistor(org.knime.core.node.workflow.WorkflowPersistor) ArrayList(java.util.ArrayList) EditPartViewer(org.eclipse.gef.EditPartViewer) NodeContainer(org.knime.core.node.workflow.NodeContainer) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) NodeID(org.knime.core.node.workflow.NodeID) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) HashSet(java.util.HashSet)

Aggregations

ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)19 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)13 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)8 Point (org.eclipse.draw2d.geometry.Point)7 NodeID (org.knime.core.node.workflow.NodeID)7 ConnectionID (org.knime.core.node.workflow.ConnectionID)6 Map (java.util.Map)5 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)5 NodeContainer (org.knime.core.node.workflow.NodeContainer)4 HashMap (java.util.HashMap)3 ConnectionContainerUI (org.knime.core.ui.node.workflow.ConnectionContainerUI)3 ArrayList (java.util.ArrayList)2 Builder (org.knime.core.node.workflow.ConnectionUIInformation.Builder)2 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)2 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)2 Point2D (java.awt.geom.Point2D)1 HashSet (java.util.HashSet)1 AbsoluteBendpoint (org.eclipse.draw2d.AbsoluteBendpoint)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1 EditorUIInformation (org.knime.core.node.workflow.EditorUIInformation)1