Search in sources :

Example 1 with NodeUIInformation

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

the class NodeContainerEditPart method refreshBounds.

/**
 * Adjusts the height and width of the node's figure. It automatically sets them to the preferred height/width of
 * the figure (which might change if the warning icons change). It doesn't change x/y position of the figure. It
 * does change width and height.
 */
private void refreshBounds() {
    NodeUIInformation uiInfo = getNodeContainer().getUIInformation();
    int[] bounds = uiInfo.getBounds();
    WorkflowRootEditPart parent = (WorkflowRootEditPart) getParent();
    NodeContainerFigure fig = (NodeContainerFigure) getFigure();
    Dimension pref = fig.getPreferredSize();
    boolean set = false;
    if (pref.width != bounds[2]) {
        bounds[2] = pref.width;
        set = true;
    }
    if (pref.height != bounds[3]) {
        bounds[3] = pref.height;
        set = true;
    }
    if (set) {
        // notify uiInfo listeners (e.g. node annotations)
        m_uiListenerActive = false;
        getNodeContainer().setUIInformation(NodeUIInformation.builder().setNodeLocation(bounds[0], bounds[1], bounds[2], bounds[3]).build());
        m_uiListenerActive = true;
    }
    // since ver2.3.0 all coordinates are relative to the icon
    Point offset = fig.getOffsetToRefPoint(uiInfo);
    bounds[0] -= offset.x;
    bounds[1] -= offset.y;
    Rectangle rect = new Rectangle(bounds[0], bounds[1], bounds[2], bounds[3]);
    fig.setBounds(rect);
    parent.setLayoutConstraint(this, fig, rect);
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Dimension(org.eclipse.draw2d.geometry.Dimension) Point(org.eclipse.draw2d.geometry.Point) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 2 with NodeUIInformation

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

the class WorkflowInPortBarEditPart 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 WorkflowInPortBarFigure(newBounds);
    } else {
        return new WorkflowInPortBarFigure(getMinMaxXcoordInWorkflow()[0]);
    }
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) Rectangle(org.eclipse.draw2d.geometry.Rectangle) WorkflowInPortBarFigure(org.knime.workbench.editor2.figures.WorkflowInPortBarFigure)

Example 3 with NodeUIInformation

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

the class WorkflowRootEditPart method getModelChildren.

/**
 * Returns the model chidlren, that is, the <code>NodeConatiner</code>s that
 * are stored in the workflow manager.
 *
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
protected List getModelChildren() {
    List modelChildren = new ArrayList();
    WorkflowManagerUI wfm = getWorkflowManager();
    // Add them first so they appear behind everything else
    for (Annotation anno : wfm.getWorkflowAnnotations()) {
        modelChildren.add(anno);
    }
    // workflow annotations so they appear above them)
    for (NodeAnnotation nodeAnno : wfm.getNodeAnnotations()) {
        modelChildren.add(nodeAnno);
    }
    modelChildren.addAll(wfm.getNodeContainers());
    if (wfm.getNrWorkflowIncomingPorts() > 0) {
        if (m_inBar == null) {
            m_inBar = new WorkflowPortBar(wfm, true);
            NodeUIInformation uiInfo = wfm.getInPortsBarUIInfo();
            if (uiInfo != null) {
                m_inBar.setUIInfo(wfm.getInPortsBarUIInfo());
            }
        }
        modelChildren.add(m_inBar);
    }
    if (wfm.getNrWorkflowOutgoingPorts() > 0) {
        if (m_outBar == null) {
            m_outBar = new WorkflowPortBar(wfm, false);
            NodeUIInformation uiInfo = wfm.getOutPortsBarUIInfo();
            if (uiInfo != null) {
                m_outBar.setUIInfo(wfm.getOutPortsBarUIInfo());
            }
        }
        modelChildren.add(m_outBar);
    }
    return modelChildren;
}
Also used : WorkflowPortBar(org.knime.workbench.editor2.model.WorkflowPortBar) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) ArrayList(java.util.ArrayList) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowAnnotation(org.knime.core.node.workflow.WorkflowAnnotation) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) Annotation(org.knime.core.node.workflow.Annotation)

Example 4 with NodeUIInformation

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

the class NodeContainerEditPart method activate.

/**
 * {@inheritDoc}
 */
@Override
public void activate() {
    super.activate();
    initFigure();
    // If we already have extra info, init figure now
    NodeContainerUI cont = getNodeContainer();
    NodeUIInformation uiInfo = cont.getUIInformation();
    if (uiInfo != null) {
        // takes over all info except the coordinates
        updateFigureFromUIinfo(uiInfo);
    } else {
        // set a new empty UI info
        NodeUIInformation info = NodeUIInformation.builder().setNodeLocation(0, 0, -1, -1).build();
        // not yet a listener -- no event received
        cont.setUIInformation(info);
    }
    // need to notify node annotation about our presence
    // the annotation is a child that's added first (placed in background)
    // to the viewer - so it doesn't know about the correct location yet
    NodeAnnotation nodeAnnotation = cont.getNodeAnnotation();
    NodeAnnotationEditPart nodeAnnotationEditPart = (NodeAnnotationEditPart) getViewer().getEditPartRegistry().get(nodeAnnotation);
    if (nodeAnnotationEditPart != null) {
        nodeAnnotationEditPart.nodeUIInformationChanged(null);
    }
    IPreferenceStore store = KNIMEUIPlugin.getDefault().getPreferenceStore();
    store.addPropertyChangeListener(this);
    // listen to node container (= model object)
    cont.addNodeStateChangeListener(this);
    cont.addNodeMessageListener(this);
    cont.addProgressListener(this);
    cont.addUIInformationListener(this);
    cont.addNodePropertyChangedListener(this);
    addEditPartListener(this);
    updateJobManagerIcon();
    checkMetaNodeTemplateIcon();
    checkMetaNodeLockIcon();
    checkNodeLockIcon();
    // set the active (or disabled) state
    ((NodeContainerFigure) getFigure()).setStateFromNC(cont);
    // set the node message
    updateNodeMessage();
    callHideNodeName();
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) NodeAnnotation(org.knime.core.node.workflow.NodeAnnotation) NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) NodeContainerFigure(org.knime.workbench.editor2.figures.NodeContainerFigure)

Example 5 with NodeUIInformation

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

the class ChangeNodeBoundsCommand method execute.

/**
 * Sets the new bounds.
 *
 * @see org.eclipse.gef.commands.Command#execute()
 */
@Override
public void execute() {
    if (!Arrays.equals(m_oldBounds, m_newBounds)) {
        WorkflowManager wm = getHostWFM();
        NodeUIInformation information = NodeUIInformation.builder().setNodeLocation(m_newBounds[0], m_newBounds[1], m_newBounds[2], m_newBounds[3]).build();
        NodeContainer container = wm.getNodeContainer(m_nodeID);
        // must set explicitly so that event is fired by container
        container.setUIInformation(information);
    }
}
Also used : NodeUIInformation(org.knime.core.node.workflow.NodeUIInformation) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Aggregations

NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)31 NodeID (org.knime.core.node.workflow.NodeID)11 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)8 NodeContainer (org.knime.core.node.workflow.NodeContainer)7 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)7 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)7 WorkflowPortBar (org.knime.workbench.editor2.model.WorkflowPortBar)7 ConnectionID (org.knime.core.node.workflow.ConnectionID)6 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)5 Point (org.eclipse.draw2d.geometry.Point)4 Rectangle (org.eclipse.draw2d.geometry.Rectangle)4 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)4 MessageBox (org.eclipse.swt.widgets.MessageBox)3 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)3 WorkflowAnnotation (org.knime.core.node.workflow.WorkflowAnnotation)3 ArrayList (java.util.ArrayList)2 IFigure (org.eclipse.draw2d.IFigure)2 Test (org.junit.Test)2