Search in sources :

Example 41 with NodeContainerUI

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

the class OpenMultiDialogAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    NodeID[] nodes = new NodeID[nodeParts.length];
    SplitType splitType = SplitType.USER;
    for (int i = 0; i < nodeParts.length; i++) {
        NodeContainerUI nc = nodeParts[i].getNodeContainer();
        nodes[i] = nc.getID();
        if (nc instanceof WorkflowManagerUI) {
            // one metanode disables splitting
            splitType = SplitType.DISALLOWED;
        }
    }
    WrappedMultipleNodeDialog dlg = new WrappedMultipleNodeDialog(Display.getCurrent().getActiveShell(), getManager(), splitType, nodes);
    // the dialog applies new settings on OK
    dlg.open();
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeID(org.knime.core.node.workflow.NodeID) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) WrappedMultipleNodeDialog(org.knime.workbench.ui.wrapper.WrappedMultipleNodeDialog)

Example 42 with NodeContainerUI

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

the class ResumeLoopAction method internalCalculateEnabled.

/**
 * @return <code>true</code>, if just one loop end node part is selected
 *         which is executable and a loop is in progress.
 *
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    if (parts.length != 1) {
        return false;
    }
    // enabled if the one selected node is a configured and "in progress"
    // LoopEndNode
    NodeContainerUI nc = parts[0].getNodeContainer();
    if (Wrapper.wraps(nc, NativeNodeContainer.class)) {
        NativeNodeContainer nnc = Wrapper.unwrap(nc, NativeNodeContainer.class);
        if (nnc.isModelCompatibleTo(LoopEndNode.class) && nnc.getLoopStatus().equals(LoopStatus.PAUSED)) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) LoopEndNode(org.knime.core.node.workflow.LoopEndNode)

Example 43 with NodeContainerUI

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

the class SelectLoopAction method internalCalculateEnabled.

/**
 * @return <code>true</code> if at we have a single node which has a
 *         dialog
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] selected = getSelectedParts(NodeContainerEditPart.class);
    if (selected.length != 1) {
        return false;
    }
    NodeContainerUI node = selected[0].getNodeContainer();
    if (!(node instanceof SingleNodeContainerUI)) {
        return false;
    }
    if (((SingleNodeContainerUI) node).isMemberOfScope()) {
        return true;
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart)

Example 44 with NodeContainerUI

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

the class SetNodeDescriptionAction method runOnNodes.

/**
 * Opens a dialog and collects the user name and description. After the
 * dialog is closed the new name and description are set to the node
 * container if applicable.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    // if more than one node part is selected
    if (nodeParts.length != 1) {
        LOGGER.debug("Execution denied as more than one node is " + "selected. Not allowed in 'Set description' action.");
        return;
    }
    final NodeContainerUI container = nodeParts[0].getNodeContainer();
    try {
        Shell parent = PlatformUI.getWorkbench().getDisplay().getActiveShell();
        String initialDescr = "";
        if (container.getCustomDescription() != null) {
            initialDescr = container.getCustomDescription();
        }
        String dialogTitle = container.getDisplayLabel();
        NodeDescriptionDialog dialog = new NodeDescriptionDialog(parent, dialogTitle, initialDescr, // (bugfix 1402)
        container.getID());
        Point relativeLocation = new Point(nodeParts[0].getFigure().getBounds().x, nodeParts[0].getFigure().getBounds().y);
        relativeLocation = parent.toDisplay(relativeLocation);
        dialog.create();
        dialog.getShell().setLocation(relativeLocation);
        int result = dialog.open();
        // check if ok was pressed
        if (result == Window.OK) {
            String description = dialog.getDescription();
            container.setCustomDescription(description);
        }
    } catch (Exception ex) {
        LOGGER.error("Could not open node description editor: " + ex.getMessage(), ex);
    }
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) Shell(org.eclipse.swt.widgets.Shell) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

Example 45 with NodeContainerUI

use of org.knime.core.ui.node.workflow.NodeContainerUI 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)

Aggregations

NodeContainerUI (org.knime.core.ui.node.workflow.NodeContainerUI)59 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)28 SubNodeContainerUI (org.knime.core.ui.node.workflow.SubNodeContainerUI)17 WorkflowManagerUI (org.knime.core.ui.node.workflow.WorkflowManagerUI)16 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)10 NodeContainerFigure (org.knime.workbench.editor2.figures.NodeContainerFigure)9 SingleNodeContainerUI (org.knime.core.ui.node.workflow.SingleNodeContainerUI)8 NodeUIInformation (org.knime.core.node.workflow.NodeUIInformation)7 HashMap (java.util.HashMap)5 Point (org.eclipse.draw2d.geometry.Point)5 Image (org.eclipse.swt.graphics.Image)5 ConnectionUIInformation (org.knime.core.node.workflow.ConnectionUIInformation)5 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)5 NodeID (org.knime.core.node.workflow.NodeID)5 ArrayList (java.util.ArrayList)4 EditPart (org.eclipse.gef.EditPart)4 LoopEndNode (org.knime.core.node.workflow.LoopEndNode)4 IContainer (org.eclipse.core.resources.IContainer)3 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3