Search in sources :

Example 81 with NodeContainerEditPart

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

the class SubNodeReconfigureAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    if (nodeParts.length < 1) {
        return;
    }
    NodeContainerEditPart ep = nodeParts[0];
    SubNodeContainerUI subnodeNC = (SubNodeContainerUI) ep.getModel();
    if (!Wrapper.unwrap(subnodeNC, SubNodeContainer.class).getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
        return;
    }
    SetupSubnodeWizard wizard = new SetupSubnodeWizard(ep.getViewer(), Wrapper.unwrap(subnodeNC, SubNodeContainer.class));
    SubnodeWizardDialog dlg = new SubnodeWizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dlg.create();
    dlg.open();
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) SubnodeWizardDialog(org.knime.workbench.editor2.subnode.SubnodeWizardDialog) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) SetupSubnodeWizard(org.knime.workbench.editor2.subnode.SetupSubnodeWizard)

Example 82 with NodeContainerEditPart

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

the class SubNodeReconfigureAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of <code>WorkflowManager</code>, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    NodeContainer nc = Wrapper.unwrapOptionalNC(nodes[0].getNodeContainer()).orElse(null);
    if (nc instanceof SubNodeContainer) {
        return !((SubNodeContainer) nc).isWriteProtected();
    }
    return false;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Example 83 with NodeContainerEditPart

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

the class StepLoopAction method runOnNodes.

/**
 * Perform one step through the entire loop and pause again.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating 'Step Loop Execution' job for " + nodeParts.length + " node(s)...");
    WorkflowManager manager = getManager();
    for (NodeContainerEditPart p : nodeParts) {
        NodeContainerUI nc = p.getNodeContainer();
        if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
            NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
            if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
                manager.resumeLoopExecution(nnc, /*oneStep=*/
                true);
            } else if (manager.canExecuteNodeDirectly(nc.getID())) {
                manager.executeUpToHere(nc.getID());
                manager.pauseLoopExecution(nnc);
            }
        }
    }
    try {
        // Give focus to the editor again. Otherwise the actions (selection)
        // is not updated correctly.
        getWorkbenchPart().getSite().getPage().activate(getWorkbenchPart());
    } catch (Exception e) {
    // ignore
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) LoopEndNode(org.knime.core.node.workflow.LoopEndNode)

Example 84 with NodeContainerEditPart

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

the class SubnodeLayoutAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    WorkflowManager manager = getManager();
    SubNodeContainer subnode = (SubNodeContainer) manager.getDirectNCParent();
    SubnodeLayoutWizard wizard = new SubnodeLayoutWizard(subnode);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dlg.create();
    dlg.open();
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) SubnodeLayoutWizard(org.knime.workbench.editor2.subnode.SubnodeLayoutWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 85 with NodeContainerEditPart

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

the class CreateConnectionCommand method canExecute.

/**
 * @return <code>true</code> if the connection can be added (that is, all
 *         fields were set to valid values before and the corresponding edit
 *         parts are not locked
 * @see org.eclipse.gef.commands.Command#canExecute()
 */
@Override
public boolean canExecute() {
    if (!super.canExecute()) {
        return false;
    }
    if (m_sourceNode == null || m_targetNode == null) {
        return false;
    }
    WorkflowManager wm = getHostWFM();
    if (m_targetPortID < 0) {
        ConnectableEditPart target = getTargetNode();
        if (target instanceof NodeContainerEditPart) {
            m_targetPortID = ((NodeContainerEditPart) target).getFreeInPort(getSourceNode(), getSourcePortID());
        }
    }
    // check whether an existing connection can be removed
    ConnectionContainer conn = wm.getIncomingConnectionFor(m_targetNode.getNodeContainer().getID(), m_targetPortID);
    boolean canRemove = conn == null || wm.canRemoveConnection(conn);
    // let the workflow manager check if the connection can be created
    // or removed
    boolean canAdd = wm.canAddConnection(m_sourceNode.getNodeContainer().getID(), m_sourcePortID, m_targetNode.getNodeContainer().getID(), m_targetPortID);
    return canRemove && canAdd;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainer(org.knime.core.node.workflow.ConnectionContainer) ConnectableEditPart(org.knime.workbench.editor2.editparts.ConnectableEditPart) WorkflowManager(org.knime.core.node.workflow.WorkflowManager)

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