Search in sources :

Example 6 with SubNodeContainer

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

use of org.knime.core.node.workflow.SubNodeContainer 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 8 with SubNodeContainer

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

the class ExecuteAndOpenViewAction method executeAndOpen.

private void executeAndOpen(final NodeContainer cont) {
    boolean hasView = cont.getNrViews() > 0;
    final InteractiveWebViewsResult interactiveWebViews = cont.getInteractiveWebViews();
    hasView |= cont.hasInteractiveView() || interactiveWebViews.size() > 0;
    hasView |= OpenSubnodeWebViewAction.hasContainerView(cont);
    if (hasView) {
        // another listener must be registered at the workflow manager to
        // receive also those events from nodes that have just been queued
        cont.addNodeStateChangeListener(new NodeStateChangeListener() {

            @Override
            public void stateChanged(final NodeStateEvent state) {
                NodeContainerState ncState = cont.getNodeContainerState();
                // removed from the queue)
                if ((state.getSource() == cont.getID()) && ncState.isExecuted()) {
                    // if the node was successfully executed
                    // start the view
                    Display.getDefault().asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            // run open view action
                            IAction viewAction;
                            if (cont.hasInteractiveView()) {
                                viewAction = new OpenInteractiveViewAction(cont);
                            } else if (cont instanceof SubNodeContainer) {
                                viewAction = new OpenSubnodeWebViewAction((SubNodeContainer) cont);
                            } else if (interactiveWebViews.size() > 0) {
                                viewAction = new OpenInteractiveWebViewAction(cont, interactiveWebViews.get(0));
                            } else {
                                viewAction = new OpenViewAction(cont, 0);
                            }
                            viewAction.run();
                        }
                    });
                }
                if (!ncState.isExecutionInProgress()) {
                    // in those cases remove the listener
                    cont.removeNodeStateChangeListener(this);
                }
            }
        });
    }
    getManager().executeUpToHere(cont.getID());
}
Also used : IAction(org.eclipse.jface.action.IAction) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerState(org.knime.core.node.workflow.NodeContainerState) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) NodeStateChangeListener(org.knime.core.node.workflow.NodeStateChangeListener) NodeStateEvent(org.knime.core.node.workflow.NodeStateEvent)

Example 9 with SubNodeContainer

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

the class ExpandSubNodeAction method runOnNodes.

/**
 * Expand sub node!
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    if (nodeParts.length < 1) {
        return;
    }
    LOGGER.debug("Creating 'Expand Wrapped Metanode' job for " + nodeParts.length + " node(s)...");
    try {
        WorkflowManager manager = getManager();
        SubNodeContainer subNode = Wrapper.unwrap(nodeParts[0].getNodeContainer(), SubNodeContainer.class);
        if (!subNode.getWorkflowManager().unlock(new GUIWorkflowCipherPrompt())) {
            return;
        }
        // reset the metanode
        if (manager.canResetNode(subNode.getID())) {
            // yes: ask if we can reset, otherwise bail
            MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.OK | SWT.CANCEL);
            mb.setMessage("Executed Nodes inside Wrapped Metanode will be reset" + " - are you sure?");
            mb.setText("Reset Executed Nodes");
            int dialogreturn = mb.open();
            if (dialogreturn == SWT.CANCEL) {
                return;
            }
            // perform reset
            if (manager.canResetNode(subNode.getID())) {
                manager.resetAndConfigureNode(subNode.getID());
            }
        }
        String res = manager.canExpandSubNode(subNode.getID());
        if (res != null) {
            throw new IllegalArgumentException(res);
        }
        ExpandSubNodeCommand emnc = new ExpandSubNodeCommand(manager, subNode.getID(), getEditor());
        execute(emnc);
    } catch (IllegalArgumentException e) {
        MessageBox mb = new MessageBox(Display.getCurrent().getActiveShell(), SWT.ERROR);
        mb.setMessage("Expanding Wrapped Metanode failed: " + e.getMessage());
        mb.setText("Expand failed");
        mb.open();
    }
    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 : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) ExpandSubNodeCommand(org.knime.workbench.editor2.commands.ExpandSubNodeCommand) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) GUIWorkflowCipherPrompt(org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 10 with SubNodeContainer

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

the class OpenSubnodeWebViewAction method hasContainerView.

static boolean hasContainerView(final NodeContainer cont) {
    boolean hasView = false;
    if (cont instanceof SubNodeContainer) {
        SinglePageManager spm = SinglePageManager.of(cont.getParent());
        hasView = spm.hasWizardPage(cont.getID());
    }
    return hasView;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) SinglePageManager(org.knime.core.wizard.SinglePageManager)

Aggregations

SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)26 NodeContainer (org.knime.core.node.workflow.NodeContainer)12 WorkflowManager (org.knime.core.node.workflow.WorkflowManager)12 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)8 NodeID (org.knime.core.node.workflow.NodeID)7 MetaNodeTemplateInformation (org.knime.core.node.workflow.MetaNodeTemplateInformation)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)4 File (java.io.File)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 AbstractExplorerFileStore (org.knime.workbench.explorer.filesystem.AbstractExplorerFileStore)3 AbstractContentProvider (org.knime.workbench.explorer.view.AbstractContentProvider)3 URI (java.net.URI)2 Map (java.util.Map)2 IAction (org.eclipse.jface.action.IAction)2 ConnectionContainer (org.knime.core.node.workflow.ConnectionContainer)2 ConnectionID (org.knime.core.node.workflow.ConnectionID)2 WorkflowContext (org.knime.core.node.workflow.WorkflowContext)2 GUIWorkflowCipherPrompt (org.knime.workbench.editor2.editparts.GUIWorkflowCipherPrompt)2