Search in sources :

Example 21 with NodeContainerUI

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

the class ExecuteAndOpenViewAction method internalCalculateEnabled.

/**
 * @return <code>true</code>, if just one node part is selected which is
 *         executable and additionally has at least one view.
 *
 * @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) {
        return false;
    }
    for (int i = 0; i < parts.length; i++) {
        NodeContainerUI nc = parts[i].getNodeContainer();
        boolean hasView = nc.getNrViews() > 0;
        if (Wrapper.wraps(nc, NodeContainer.class)) {
            hasView |= nc.hasInteractiveView() || unwrapNC(nc).getInteractiveWebViews().size() > 0;
            hasView |= OpenSubnodeWebViewAction.hasContainerView(unwrapNC(nc));
        }
        if (wm.canExecuteNode(nc.getID()) && hasView) {
            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 22 with NodeContainerUI

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

the class ResetAction method internalCalculateEnabled.

/**
 * @return <code>true</code> if at least one node is resetable
 * @see org.eclipse.gef.ui.actions.WorkbenchPartAction#calculateEnabled()
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] parts = getSelectedParts(NodeContainerEditPart.class);
    for (int i = 0; i < parts.length; i++) {
        NodeContainerEditPart part = parts[i];
        NodeContainerUI nc = part.getNodeContainer();
        if (getManager().canResetNode(nc.getID())) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart)

Example 23 with NodeContainerUI

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

the class OpenFirstOutPortViewAction method runOnNodes.

/**
 * This opens the first view of all the selected nodes.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating open first out-port view job for " + nodeParts.length + " node(s)...");
    for (NodeContainerEditPart p : nodeParts) {
        final NodeContainerUI cont = p.getNodeContainer();
        final java.awt.Rectangle knimeWindowBounds = OpenViewAction.getAppBoundsAsAWTRec();
        // first port is flow var port
        final OptionalInt portIndex = getPortIndex(cont);
        if (portIndex.isPresent()) {
            SwingUtilities.invokeLater(new Runnable() {

                /**
                 * {inheritDoc}
                 */
                @Override
                public void run() {
                    NodeOutPort port = Wrapper.unwrapNC(cont).getOutPort(portIndex.getAsInt());
                    LOGGER.debug("Open First Out-Port View " + cont.getName() + " on port " + port.getPortName());
                    port.openPortView(port.getPortName(), knimeWindowBounds);
                }
            });
        }
    }
    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) NodeOutPort(org.knime.core.node.workflow.NodeOutPort) OptionalInt(java.util.OptionalInt)

Example 24 with NodeContainerUI

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

the class PauseLoopExecutionAction method internalCalculateEnabled.

/**
 * @return <code>true</code>, if just one loop end node part is selected
 *         which is executing.
 *
 * @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 an executing LoopEndNode
    NodeContainerUI nc = parts[0].getNodeContainer();
    if (Wrapper.wraps(nc, SingleNodeContainer.class)) {
        SingleNodeContainer snc = Wrapper.unwrap(nc, SingleNodeContainer.class);
        if ((snc.isModelCompatibleTo(LoopEndNode.class)) && (nc.getNodeContainerState().isExecutionInProgress())) {
            return true;
        }
    }
    return false;
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer)

Example 25 with NodeContainerUI

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

the class ResumeLoopAction method runOnNodes.

/**
 * Resume paused loop.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating 'Resume 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=*/
                false);
            }
        }
    }
    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