Search in sources :

Example 26 with NodeContainerEditPart

use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.

the class PortGraphicalRoleEditPolicy method getConnectionCompleteCommand.

/**
 * This tries to complete the command to create a connection.
 *
 * {@inheritDoc}
 */
@Override
protected Command getConnectionCompleteCommand(final CreateConnectionRequest request) {
    // get the previously started command
    CreateConnectionCommand cmd = (CreateConnectionCommand) request.getStartCommand();
    if (cmd == null) {
        return null;
    }
    EditPart target = request.getTargetEditPart();
    if ((target instanceof NodeOutPortEditPart) || target instanceof WorkflowInPortEditPart) {
        return null;
    } else if (target instanceof NodeInPortEditPart || target instanceof WorkflowOutPortEditPart) {
        cmd.setTargetPortID(((AbstractPortEditPart) target).getIndex());
        cmd.setTargetNode((ConnectableEditPart) target.getParent());
    } else if (target instanceof NodeContainerEditPart) {
        if (cmd.wasStartedOnOutPort()) {
            cmd.setTargetPortID(-1);
            cmd.setTargetNode((NodeContainerEditPart) target);
        } else {
            cmd.setSourcePortID(-1);
            cmd.setSourceNode((NodeContainerEditPart) target);
        }
    } else {
        return null;
    }
    return cmd;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectableEditPart(org.knime.workbench.editor2.editparts.ConnectableEditPart) NodeOutPortEditPart(org.knime.workbench.editor2.editparts.NodeOutPortEditPart) MetaNodeOutPortEditPart(org.knime.workbench.editor2.editparts.MetaNodeOutPortEditPart) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) AbstractPortEditPart(org.knime.workbench.editor2.editparts.AbstractPortEditPart) NodeInPortEditPart(org.knime.workbench.editor2.editparts.NodeInPortEditPart) WorkflowOutPortEditPart(org.knime.workbench.editor2.editparts.WorkflowOutPortEditPart) ConnectableEditPart(org.knime.workbench.editor2.editparts.ConnectableEditPart) NodeOutPortEditPart(org.knime.workbench.editor2.editparts.NodeOutPortEditPart) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) MetaNodeOutPortEditPart(org.knime.workbench.editor2.editparts.MetaNodeOutPortEditPart) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) WorkflowOutPortEditPart(org.knime.workbench.editor2.editparts.WorkflowOutPortEditPart) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) CreateConnectionCommand(org.knime.workbench.editor2.commands.CreateConnectionCommand) NodeInPortEditPart(org.knime.workbench.editor2.editparts.NodeInPortEditPart)

Example 27 with NodeContainerEditPart

use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.

the class DisconnectSubNodeLinkAction 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);
    for (NodeContainerEditPart p : nodes) {
        Object model = p.getModel();
        if (Wrapper.wraps(model, SubNodeContainer.class)) {
            SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
            MetaNodeTemplateInformation i = snc.getTemplateInformation();
            if (Role.Link.equals(i.getRole())) {
                return true;
            }
        }
    }
    return false;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 28 with NodeContainerEditPart

use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.

the class DisconnectSubNodeLinkAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    List<NodeID> idList = new ArrayList<NodeID>();
    for (NodeContainerEditPart p : nodeParts) {
        Object model = p.getModel();
        if (Wrapper.wraps(model, SubNodeContainer.class)) {
            SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
            MetaNodeTemplateInformation i = snc.getTemplateInformation();
            if (Role.Link.equals(i.getRole())) {
                idList.add(snc.getID());
            }
        }
    }
    NodeID[] ids = idList.toArray(new NodeID[idList.size()]);
    DisconnectSubNodeLinkCommand disCmd = new DisconnectSubNodeLinkCommand(getManager(), ids);
    execute(disCmd);
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NodeID(org.knime.core.node.workflow.NodeID) ArrayList(java.util.ArrayList) DisconnectSubNodeLinkCommand(org.knime.workbench.editor2.commands.DisconnectSubNodeLinkCommand) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

Example 29 with NodeContainerEditPart

use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.

the class ExecuteAction method internalCalculateEnabled.

/**
 * @return always <code>true</code>, as the WFM tries to execute as much
 *         as possible
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    // enable if we have at least one executable node in our selection
    WorkflowManager wm = getEditor().getWorkflowManager().orElse(null);
    if (wm == null) {
        // fixes NPE when shutting down
        return false;
    }
    for (int i = 0; i < parts.length; i++) {
        NodeContainerUI nc = parts[i].getNodeContainer();
        if (wm.canExecuteNode(nc.getID())) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager)

Example 30 with NodeContainerEditPart

use of org.knime.workbench.editor2.editparts.NodeContainerEditPart in project knime-core by knime.

the class ExecuteAndOpenViewAction method getToolTipText.

/**
 * {@inheritDoc}
 */
@Override
public String getToolTipText() {
    String tooltip = "Execute the selected node";
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    if (parts.length == 1) {
        NodeContainer nc = Wrapper.unwrapNC(parts[0].getNodeContainer());
        if (nc.hasInteractiveView() || nc.getInteractiveWebViews().size() > 0) {
            return tooltip + " and open interactive view.";
        }
    } else {
        tooltip += "s";
    }
    return tooltip + " and open first view.";
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Aggregations

NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)77 NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)28 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)24 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)16 EditPart (org.eclipse.gef.EditPart)15 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)14 Point (org.eclipse.draw2d.geometry.Point)11 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)11 NodeContainer (org.knime.core.node.workflow.NodeContainer)9 NodeID (org.knime.core.node.workflow.NodeID)9 AnnotationEditPart (org.knime.workbench.editor2.editparts.AnnotationEditPart)9 NodeAnnotationEditPart (org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)9 WorkflowRootEditPart (org.knime.workbench.editor2.editparts.WorkflowRootEditPart)9 ArrayList (java.util.ArrayList)8 GUIWorkflowCipherPrompt (org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)8 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)6 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)6 WorkflowInPortBarEditPart (org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart)6 Rectangle (org.eclipse.draw2d.geometry.Rectangle)5 MessageBox (org.eclipse.swt.widgets.MessageBox)5