Search in sources :

Example 51 with NodeContainerUI

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

the class ShiftConnectionCommand method getLastConnectedPort.

/**
 * @return the lowest index of a port that is not connected.
 */
private int getLastConnectedPort() {
    NodeContainerUI nc = m_node.getNodeContainer();
    int startIdx = 1;
    if (nc instanceof WorkflowManagerUI) {
        startIdx = 0;
    }
    int lastConnPort = -1;
    for (int p = startIdx; p < nc.getNrInPorts(); p++) {
        if (getHostWFM().getIncomingConnectionFor(m_nodeID, p) != null) {
            lastConnPort = p;
        }
    }
    if ((lastConnPort < 0) && (startIdx > 0) && (getHostWFM().getIncomingConnectionFor(m_nodeID, 0) != null)) {
        // test the implicit flow var port, if it is the only connected port
        lastConnPort = 0;
    }
    return lastConnPort;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI)

Example 52 with NodeContainerUI

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

the class AbstractWorkflowPortBarEditPart method getMinMaxXcoordInWorkflow.

/**
 * returns the minX coordinate and the maxX coordinate of all nodes, annotations and bendpoints in the flow (taking
 * the size of the elements into account). Or Integer.MIN/MAX_value if no elements exist.
 * @return new int[] {minX, maxX};
 */
protected int[] getMinMaxXcoordInWorkflow() {
    int maxX = Integer.MIN_VALUE;
    int minX = Integer.MAX_VALUE;
    // find the smallest and the biggest X coordinate in all the UI infos in the flow
    WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
    for (NodeContainerUI nc : manager.getNodeContainers()) {
        int nodeWidth = NodeContainerFigure.WIDTH;
        NodeAnnotation nodeAnno = nc.getNodeAnnotation();
        if ((nodeAnno != null) && (nodeAnno.getWidth() > nodeWidth)) {
            nodeWidth = nodeAnno.getWidth();
        }
        NodeUIInformation uiInfo = nc.getUIInformation();
        if (uiInfo != null) {
            int x = uiInfo.getBounds()[0];
            // right border of node
            x = x + (nodeWidth / 2);
            if (maxX < x) {
                maxX = x;
            }
            // left border of node
            x = x - nodeWidth;
            if (minX > x) {
                minX = x;
            }
        }
    }
    for (WorkflowAnnotation anno : manager.getWorkflowAnnotations()) {
        int x = anno.getX();
        if (minX > x) {
            minX = x;
        }
        x = x + anno.getWidth();
        if (maxX < x) {
            maxX = x;
        }
    }
    for (ConnectionContainerUI conn : manager.getConnectionContainers()) {
        ConnectionUIInformation uiInfo = conn.getUIInfo();
        if (uiInfo != null) {
            int[][] bendpoints = uiInfo.getAllBendpoints();
            if (bendpoints != null) {
                for (int[] b : bendpoints) {
                    if (maxX < b[0]) {
                        maxX = b[0];
                    }
                    if (minX > b[0]) {
                        minX = b[0];
                    }
                }
            }
        }
    }
    return new int[] { minX, maxX };
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ConnectionUIInformation(org.knime.core.node.workflow.ConnectionUIInformation) ConnectionContainerUI(org.knime.core.ui.node.workflow.ConnectionContainerUI) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation)

Example 53 with NodeContainerUI

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

the class NodeContainerEditPart method updateNodeMessage.

/**
 * Checks the message of the this node and if there is a message in the <code>NodeStatus</code> object the message
 * is set. Otherwise the currently displayed message is removed.
 */
private void updateNodeMessage() {
    NodeContainerUI nc = getNodeContainer();
    NodeContainerFigure containerFigure = (NodeContainerFigure) getFigure();
    NodeMessage nodeMessage = nc.getNodeMessage();
    containerFigure.setMessage(nodeMessage);
    refreshBounds();
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeMessage(org.knime.core.node.workflow.NodeMessage) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 54 with NodeContainerUI

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

the class NodeContainerEditPart method getFreeInPort.

/**
 * @param sourceNode
 * @param srcPortIdx
 * @return the first free port the specified port could be connected to. Or -1 if there is none.
 */
public int getFreeInPort(final ConnectableEditPart sourceNode, final int srcPortIdx) {
    WorkflowManagerUI wm = getWorkflowManager();
    if (wm == null || sourceNode == null || srcPortIdx < 0) {
        return -1;
    }
    // skip variable ports
    int startPortIdx = 1;
    int connPortIdx = -1;
    NodeContainerUI nc = getNodeContainer();
    if (nc instanceof WorkflowManagerUI) {
        startPortIdx = 0;
    }
    for (int i = startPortIdx; i < nc.getNrInPorts(); i++) {
        if (wm.canAddNewConnection(sourceNode.getNodeContainer().getID(), srcPortIdx, nc.getID(), i)) {
            connPortIdx = i;
            break;
        }
    }
    if ((connPortIdx < 0) && (startPortIdx == 1) && wm.canAddConnection(sourceNode.getNodeContainer().getID(), srcPortIdx, nc.getID(), 0)) {
        // if the src is a flow var port, connect it to impl flow var port
        connPortIdx = 0;
    }
    return connPortIdx;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) Point(org.eclipse.draw2d.geometry.Point)

Example 55 with NodeContainerUI

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

the class NodeContainerEditPart method stateChanged.

/**
 * {@inheritDoc}
 */
@Override
public void stateChanged(final NodeStateEvent state) {
    // works because we are retrieving the current state information!
    if (m_updateInProgress.compareAndSet(false, true)) {
        Display display = Display.getDefault();
        if (display.isDisposed()) {
            return;
        }
        display.asyncExec(new Runnable() {

            @Override
            public void run() {
                // let others know we are in the middle of processing
                // this update - they will now need to start their own job.
                NodeContainerFigure fig = (NodeContainerFigure) getFigure();
                m_updateInProgress.set(false);
                if (isActive()) {
                    NodeContainerUI nc = getNodeContainer();
                    fig.setStateFromNC(nc);
                    updateNodeMessage();
                    // reset the tooltip text of the outports
                    for (Object part : getChildren()) {
                        if (part instanceof NodeOutPortEditPart || part instanceof WorkflowInPortEditPart || part instanceof MetaNodeOutPortEditPart) {
                            AbstractPortEditPart outPortPart = (AbstractPortEditPart) part;
                            outPortPart.rebuildTooltip();
                        }
                    }
                    // always refresh visuals (does not seem to do anything
                    // by default though: call repaints on updated figures).
                    refreshVisuals();
                }
            }
        });
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) Display(org.eclipse.swt.widgets.Display) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Aggregations

NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)59 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)28 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)17 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)16 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)10 NodeContainerFigure (org.knime.workbench.editor2.figures.NodeContainerFigure)9 SingleNodeContainerUI (org.knime.core.ui.node.workflow.SingleNodeContainerUI)8 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)7 HashMap (java.util.HashMap)5 Point (org.eclipse.draw2d.geometry.Point)5 Image (org.eclipse.swt.graphics.Image)5 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)5 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)5 NodeID (org.knime.core.node.workflow.NodeID)5 ArrayList (java.util.ArrayList)4 EditPart (org.eclipse.gef.EditPart)4 LoopEndNode (org.knime.core.node.workflow.LoopEndNode)4 IContainer (org.eclipse.core.resources.IContainer)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3