Search in sources :

Example 6 with WorkflowPortBar

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

the class ChangeWorkflowPortBarCommand method execute.

/**
 * Sets the new bounds.
 *
 * @see org.eclipse.gef.commands.Command#execute()
 */
@Override
public void execute() {
    WorkflowPortBar barModel = (WorkflowPortBar) m_bar.getModel();
    NodeUIInformation uiInfo = NodeUIInformation.builder().setNodeLocation(m_newBounds.x, m_newBounds.y, m_newBounds.width, m_newBounds.height).build();
    // must set explicitly so that event is fired by container
    barModel.setUIInfo(uiInfo);
    IFigure fig = m_bar.getFigure();
    fig.setBounds(m_newBounds);
    fig.getParent().setConstraint(fig, m_newBounds);
    m_bar.getParent().refresh();
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) IFigure(org.eclipse.draw2d.IFigure)

Example 7 with WorkflowPortBar

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

the class ChangeWorkflowPortBarCommand method undo.

/**
 * Sets the old bounds.
 *
 * @see org.eclipse.gef.commands.Command#execute()
 */
@Override
public void undo() {
    WorkflowPortBar barModel = (WorkflowPortBar) m_bar.getModel();
    NodeUIInformation uiInfo = NodeUIInformation.builder().setNodeLocation(m_oldBounds.x, m_oldBounds.y, m_oldBounds.width, m_oldBounds.height).build();
    // must set explicitly so that event is fired by container
    barModel.setUIInfo(uiInfo);
    IFigure fig = m_bar.getFigure();
    fig.setBounds(m_oldBounds);
    fig.getParent().setConstraint(fig, m_oldBounds);
    m_bar.getParent().refresh();
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) IFigure(org.eclipse.draw2d.IFigure)

Example 8 with WorkflowPortBar

use of org.knime.workbench.editor2.model.WorkflowPortBar 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 9 with WorkflowPortBar

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

the class AbstractWorkflowPortBarEditPart method refreshVisuals.

/**
 * {@inheritDoc}
 */
@Override
protected void refreshVisuals() {
    NodeUIInformation uiInfo = ((WorkflowPortBar) getModel()).getUIInfo();
    if (uiInfo != null && !((AbstractWorkflowPortBarFigure) getFigure()).isInitialized()) {
        int[] bounds = uiInfo.getBounds();
        ((AbstractWorkflowPortBarFigure) getFigure()).setBounds(new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]));
    }
    super.refreshVisuals();
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) AbstractWorkflowPortBarFigure(org.knime.workbench.editor2.figures.AbstractWorkflowPortBarFigure) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 10 with WorkflowPortBar

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

the class WorkflowInPortBarEditPart method getModelChildren.

/**
 * {@inheritDoc}
 */
@Override
protected List<NodePortUI> getModelChildren() {
    WorkflowManagerUI manager = ((WorkflowPortBar) getModel()).getWorkflowManager();
    List<NodePortUI> ports = new ArrayList<NodePortUI>();
    for (int i = 0; i < manager.getNrWorkflowIncomingPorts(); i++) {
        ports.add(manager.getInPort(i));
    }
    return ports;
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) ArrayList(java.util.ArrayList) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) NodePortUI(org.knime.core.ui.node.workflow.NodePortUI)

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