Search in sources :

Example 11 with WorkflowManagerUI

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

the class WorkflowEditorDropTargetListener method dragOver.

/**
 * {@inheritDoc}
 *
 * Marks nodes or edges if a new node should replace an old node or should be inserted on an edge.
 */
@Override
public void dragOver(final DropTargetEvent event) {
    WorkflowManagerUI wfm = ((WorkflowRootEditPart) getViewer().getRootEditPart().getContents()).getWorkflowManager();
    m_node = null;
    m_edge = null;
    m_nodeCount = 0;
    m_edgeCount = 0;
    // edge-/nodedist
    double edgedist = Integer.MAX_VALUE;
    double nodedist = Integer.MAX_VALUE;
    Point dropLocation = getDropLocation(event);
    EditPart ep = getViewer().findObjectAt(dropLocation.getTranslated(0, 0));
    if (ep instanceof NodeContainerEditPart) {
        double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
        // choose nearest node to mouse position
        if (nodedist >= temp) {
            m_node = (NodeContainerEditPart) ep;
            nodedist = temp;
        }
        m_nodeCount++;
    } else if (ep instanceof ConnectionContainerEditPart) {
        double temp = dropLocation.getDistance(dropLocation.getTranslated(0, 0));
        // choose nearest edge to mouse-position
        if (edgedist >= temp) {
            m_edge = (ConnectionContainerEditPart) ep;
            edgedist = temp;
        }
        m_edgeCount++;
    }
    unmark(wfm);
    if (m_node != null && m_nodeCount >= m_edgeCount) {
        m_markedNode = m_node;
        m_markedNode.mark();
        // workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
        WindowsDNDHelper.hideDragImage();
    } else if (m_edge != null) {
        m_edgeColor = m_edge.getFigure().getForegroundColor();
        m_edgeWidth = ((ProgressPolylineConnection) m_edge.getFigure()).getLineWidth();
        m_markedEdge = m_edge;
        ((ProgressPolylineConnection) m_markedEdge.getFigure()).setLineWidth(m_edgeWidth + 3);
        m_markedEdge.getFigure().setForegroundColor(RED);
        // workaround for eclipse bug 393868 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=393868)
        WindowsDNDHelper.hideDragImage();
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowRootEditPart(org.knime.workbench.editor2.editparts.WorkflowRootEditPart) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) WorkflowOutPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowOutPortBarEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) ProgressPolylineConnection(org.knime.workbench.editor2.figures.ProgressPolylineConnection) Point(org.eclipse.draw2d.geometry.Point)

Example 12 with WorkflowManagerUI

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

the class WorkflowOutPortBarEditPart 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.getNrWorkflowOutgoingPorts(); i++) {
        ports.add(manager.getOutPort(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)

Example 13 with WorkflowManagerUI

use of org.knime.core.ui.node.workflow.WorkflowManagerUI 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 14 with WorkflowManagerUI

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

the class LockMetaNodeAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of
 *         <code>WorkflowManager</code>, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    if (getManager().isWriteProtected()) {
        return false;
    }
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    Object model = nodes[0].getModel();
    if (model instanceof WorkflowManagerUI) {
        WorkflowManagerUI metaNode = (WorkflowManagerUI) model;
        if (metaNode.isWriteProtected()) {
            return false;
        }
        return true;
    } else {
        return false;
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI)

Example 15 with WorkflowManagerUI

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

the class KnimeResourceContentProvider method getChildren.

/**
 * {@inheritDoc}
 */
@Override
public Object[] getChildren(final Object element) {
    if (element instanceof IFile) {
        return EMPTY_ARRAY;
    }
    if (isKNIMEWorkflow(element)) {
        IContainer project = (IContainer) element;
        NodeContainerUI workflow = ProjectWorkflowMap.getWorkflowUI(project.getLocationURI());
        if (workflow != null) {
            // the number of contained nodes is returned
            return getSortedNodeContainers(((WorkflowManagerUI) workflow).getNodeContainers());
        }
    } else if (element instanceof WorkflowManager) {
        return getSortedNodeContainers(((WorkflowManagerUI) element).getNodeContainers());
    }
    return getFolders(element);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) IFile(org.eclipse.core.resources.IFile) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) IContainer(org.eclipse.core.resources.IContainer)

Aggregations

WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)37 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)16 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)12 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)7 ArrayList (java.util.ArrayList)6 WorkflowPortBar (org.knime.workbench.editor2.model.WorkflowPortBar)6 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)5 URI (java.net.URI)3 IContainer (org.eclipse.core.resources.IContainer)3 Point (org.eclipse.draw2d.geometry.Point)3 EditPart (org.eclipse.gef.EditPart)3 Image (org.eclipse.swt.graphics.Image)3 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)3 NodeAnnotation (org.knime.core.node.workflow.NodeAnnotation)3 NodeID (org.knime.core.node.workflow.NodeID)3 SingleNodeContainerUI (org.knime.core.ui.node.workflow.SingleNodeContainerUI)3 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)3 WorkflowInPortEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortEditPart)3 List (java.util.List)2 IFile (org.eclipse.core.resources.IFile)2