Search in sources :

Example 11 with WorkflowPortBar

use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.

the class WorkflowOutPortBarEditPart method createFigure.

/**
 * {@inheritDoc}
 */
@Override
protected IFigure createFigure() {
    NodeUIInformation uiInfo = ((WorkflowPortBar) getModel()).getUIInfo();
    if (uiInfo != null) {
        int[] bounds = uiInfo.getBounds();
        Rectangle newBounds = new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]);
        return new WorkflowOutPortBarFigure(newBounds);
    } else {
        int[] minmax = getMinMaxXcoordInWorkflow();
        return new WorkflowOutPortBarFigure(minmax[1]);
    }
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) WorkflowOutPortBarFigure(org.knime.workbench.editor2.figures.WorkflowOutPortBarFigure) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 12 with WorkflowPortBar

use of org.knime.workbench.editor2.model.WorkflowPortBar in project knime-core by knime.

the class PortGraphicalRoleEditPolicy method getConnectionCreateCommand.

/**
 * This tries to initialize the command to create a connection as far as
 * possible. However, it is completed by
 * <code>getConnectionCompleteCommand</code>
 *
 * {@inheritDoc}
 */
@Override
protected Command getConnectionCreateCommand(final CreateConnectionRequest req) {
    if (!(getHost() instanceof AbstractPortEditPart)) {
        return null;
    }
    ConnectableEditPart nodePart = (ConnectableEditPart) getHost().getParent();
    WorkflowManagerUI wm;
    // TODO: if NodeContainerEditPart -> getParent
    if (nodePart instanceof NodeContainerEditPart) {
        NodeContainerEditPart p = (NodeContainerEditPart) nodePart;
        wm = p.getWorkflowManager();
    } else if (nodePart instanceof WorkflowInPortBarEditPart) {
        WorkflowInPortBarEditPart barEditPart = (WorkflowInPortBarEditPart) nodePart;
        WorkflowPortBar model = (WorkflowPortBar) barEditPart.getModel();
        wm = model.getWorkflowManager();
    } else {
        return null;
    }
    CreateConnectionCommand cmd = new CreateConnectionCommand(Wrapper.unwrapWFM(wm));
    if (getHost() instanceof NodeOutPortEditPart || getHost() instanceof WorkflowInPortEditPart || getHost() instanceof MetaNodeOutPortEditPart) {
        // request started on out port?
        cmd.setSourceNode(nodePart);
        cmd.setSourcePortID(((AbstractPortEditPart) getHost()).getIndex());
        cmd.setStartedOnOutPort(true);
    } else if (getHost() instanceof NodeInPortEditPart || getHost() instanceof WorkflowOutPortEditPart) {
        return null;
    }
    // we need the manager to execute the command
    // we must remember this partially initialized command in the request.
    req.setStartCommand(cmd);
    return cmd;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) ConnectableEditPart(org.knime.workbench.editor2.editparts.ConnectableEditPart) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) NodeOutPortEditPart(org.knime.workbench.editor2.editparts.NodeOutPortEditPart) MetaNodeOutPortEditPart(org.knime.workbench.editor2.editparts.MetaNodeOutPortEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) MetaNodeOutPortEditPart(org.knime.workbench.editor2.editparts.MetaNodeOutPortEditPart) WorkflowOutPortEditPart(org.knime.workbench.editor2.editparts.WorkflowOutPortEditPart) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) CreateConnectionCommand(org.knime.workbench.editor2.commands.CreateConnectionCommand) NodeInPortEditPart(org.knime.workbench.editor2.editparts.NodeInPortEditPart)

Aggregations

WorkflowPortBar (org.knime.workbench.editor2.model.WorkflowPortBar)11 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)7 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)7 ArrayList (java.util.ArrayList)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)3 NodePortUI (org.knime.core.ui.node.workflow.NodePortUI)3 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)3 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)3 WorkflowInPortEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortEditPart)3 List (java.util.List)2 IFigure (org.eclipse.draw2d.IFigure)2 EditPart (org.eclipse.gef.EditPart)2 Annotation (org.knime.core.node.workflow.Annotation)2 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)2 ConnectionContainerUI (org.knime.core.ui.node.workflow.ConnectionContainerUI)2 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)2 SingleNodeContainerUI (org.knime.core.ui.node.workflow.SingleNodeContainerUI)2 MetaNodeOutPortEditPart (org.knime.workbench.editor2.editparts.MetaNodeOutPortEditPart)2 NodeInPortEditPart (org.knime.workbench.editor2.editparts.NodeInPortEditPart)2