Search in sources :

Example 1 with InteractiveWebViewsResult

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

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

the class WorkflowContextMenuProvider method buildContextMenu.

/**
 * {@inheritDoc}
 */
@Override
public void buildContextMenu(final IMenuManager manager) {
    final String FLOW_VAR_PORT_GRP = "Flow Variable Ports";
    // add the groups (grouped by separators) in their order first
    manager.add(new Separator(IWorkbenchActionConstants.GROUP_APP));
    manager.add(new Separator(FLOW_VAR_PORT_GRP));
    GEFActionConstants.addStandardActionGroups(manager);
    IAction action;
    action = m_actionRegistry.getAction("cut");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("copy");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction(PasteActionContextMenu.ID);
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("undo");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("redo");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    action = m_actionRegistry.getAction("delete");
    manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
    ((UpdateAction) action).update();
    // Add (some) available actions from the registry to the context menu
    // manager
    // openDialog
    action = m_actionRegistry.getAction(OpenDialogAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // execute
    action = m_actionRegistry.getAction(ExecuteAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // execute and open first view
    action = m_actionRegistry.getAction(ExecuteAndOpenViewAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // cancel execution
    action = m_actionRegistry.getAction(CancelAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // show some menu items on LoopEndNodes only
    List parts = m_viewer.getSelectedEditParts();
    if (parts.size() == 1) {
        EditPart p = (EditPart) parts.get(0);
        if (p instanceof NodeContainerEditPart) {
            NodeContainerUI container = (NodeContainerUI) ((NodeContainerEditPart) p).getModel();
            if (container instanceof SingleNodeContainerUI) {
                SingleNodeContainerUI snc = (SingleNodeContainerUI) container;
                Wrapper.unwrapOptional(snc, SingleNodeContainer.class).ifPresent(sncImpl -> {
                    if (sncImpl.isModelCompatibleTo(LoopEndNode.class)) {
                        // pause loop execution
                        IAction loopAction;
                        loopAction = m_actionRegistry.getAction(PauseLoopExecutionAction.ID);
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, loopAction);
                        ((AbstractNodeAction) loopAction).update();
                        // step loop execution
                        loopAction = m_actionRegistry.getAction(StepLoopAction.ID);
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, loopAction);
                        ((AbstractNodeAction) loopAction).update();
                        // resume loop execution
                        loopAction = m_actionRegistry.getAction(ResumeLoopAction.ID);
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, loopAction);
                        ((AbstractNodeAction) loopAction).update();
                    }
                });
            }
        }
    }
    // reset
    action = m_actionRegistry.getAction(ResetAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // set name and description
    action = m_actionRegistry.getAction(SetNodeDescriptionAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // add workflow annotation
    action = m_actionRegistry.getAction(AddAnnotationAction.ID);
    AddAnnotationAction aaa = (AddAnnotationAction) action;
    aaa.setLocation(m_lastLocation.x, m_lastLocation.y);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // collapse metanodes
    action = m_actionRegistry.getAction(CollapseMetaNodeAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    action = m_actionRegistry.getAction(EncapsulateSubNodeAction.ID);
    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
    ((AbstractNodeAction) action).update();
    // insert "select loop" if loop nodes are selected
    boolean addSelectLoop = true;
    for (Object p : parts) {
        if (!(p instanceof NodeContainerEditPart)) {
            addSelectLoop = false;
            break;
        }
        NodeContainerUI nc = ((NodeContainerEditPart) p).getNodeContainer();
        if (!(nc instanceof SingleNodeContainerUI)) {
            addSelectLoop = false;
            break;
        }
        if (!((SingleNodeContainerUI) nc).isMemberOfScope()) {
            addSelectLoop = false;
            break;
        }
    }
    if (addSelectLoop) {
        action = m_actionRegistry.getAction(SelectLoopAction.ID);
        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
        ((AbstractNodeAction) action).update();
    }
    IMenuManager metanodeMenuMgr = null;
    IMenuManager subnodeMenuMgr = null;
    IMenuManager subnodeViewMgr = null;
    // depending on the current selection: add the actions for the port
    // views and the node views
    // also check whether this node part is a meta-node
    // if so offer the "edit meta-node" option
    // all these feature are only offered if exactly 1 part is selected
    parts = m_viewer.getSelectedEditParts();
    // by now, we only support one part...
    if (parts.size() == 1) {
        EditPart p = (EditPart) parts.get(0);
        if (p instanceof WorkflowInPortBarEditPart) {
            WorkflowInPortBarEditPart root = (WorkflowInPortBarEditPart) p;
            manager.add(new Separator("outPortViews"));
            for (Object o : p.getChildren()) {
                EditPart child = (EditPart) o;
                if (child instanceof WorkflowInPortEditPart && ((WorkflowInPortEditPart) child).isSelected()) {
                    final WorkflowManager wm = Wrapper.unwrapWFM(((WorkflowPortBar) root.getModel()).getWorkflowManager());
                    action = new OpenWorkflowPortViewAction(wm, ((WorkflowInPortEditPart) child).getIndex(), wm.getNrInPorts());
                    manager.appendToGroup("outPortViews", action);
                    ((WorkflowInPortEditPart) child).setSelected(false);
                }
            }
        }
        if (p instanceof NodeContainerEditPart) {
            NodeContainerUI container = null;
            container = (NodeContainerUI) ((NodeContainerEditPart) p).getModel();
            if (!(container instanceof WorkflowManagerUI)) {
                action = m_actionRegistry.getAction(ToggleFlowVarPortsAction.ID);
                manager.appendToGroup(FLOW_VAR_PORT_GRP, action);
                ((AbstractNodeAction) action).update();
            }
            // add for node views option if applicable
            int numNodeViews = container.getNrViews();
            for (int i = 0; i < numNodeViews; i++) {
                action = new OpenViewAction(unwrapNC(container), i);
                manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
            }
            // add interactive view options
            if (container.hasInteractiveView()) {
                action = new OpenInteractiveViewAction(unwrapNC(container));
                manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
            } else {
                // TODO for subnodes move to submenu?
                if (wraps(container, NativeNodeContainer.class)) {
                    InteractiveWebViewsResult interactiveWebViewsResult = unwrapNC(container).getInteractiveWebViews();
                    for (int i = 0; i < interactiveWebViewsResult.size(); i++) {
                        action = new OpenInteractiveWebViewAction(unwrapNC(container), interactiveWebViewsResult.get(i));
                        manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
                    }
                }
            }
            if (container instanceof WorkflowManagerUI) {
                metanodeMenuMgr = getMetaNodeMenuManager(metanodeMenuMgr, manager);
                // OPEN META NODE
                action = new OpenSubworkflowEditorAction((NodeContainerEditPart) p);
                metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                // EXPAND META NODE
                action = m_actionRegistry.getAction(ExpandMetaNodeAction.ID);
                metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                ((AbstractNodeAction) action).update();
                // RECONFIGURE META NODE
                if (parts.size() == 1) {
                    action = m_actionRegistry.getAction(MetaNodeReconfigureAction.ID);
                    metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                    ((AbstractNodeAction) action).update();
                }
                // WRAP
                action = m_actionRegistry.getAction(ConvertMetaNodeToSubNodeAction.ID);
                metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
                ((AbstractNodeAction) action).update();
            }
            // SUBNODE
            if (container instanceof SubNodeContainerUI) {
                subnodeMenuMgr = getSubNodeMenuManager(subnodeMenuMgr, manager);
                // OPEN SUBNODE
                action = new OpenSubNodeEditorAction((NodeContainerEditPart) p);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                // EXPAND SUBNODE
                action = m_actionRegistry.getAction(ExpandSubNodeAction.ID);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                ((AbstractNodeAction) action).update();
                // RECONFIGURE SUBNODE
                action = m_actionRegistry.getAction(SubNodeReconfigureAction.ID);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                ((AbstractNodeAction) action).update();
                // UNWRAP
                action = m_actionRegistry.getAction(ConvertSubNodeToMetaNodeAction.ID);
                subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
                ((AbstractNodeAction) action).update();
                if (wraps(container, SubNodeContainer.class)) {
                    InteractiveWebViewsResult interactiveWebViewsResult = unwrapNC(container).getInteractiveWebViews();
                    if (interactiveWebViewsResult.size() > 0) {
                        subnodeViewMgr = getSingleSubNodeViewsMenuManager(subnodeViewMgr, subnodeMenuMgr);
                        for (int i = 0; i < interactiveWebViewsResult.size(); i++) {
                            action = new OpenInteractiveWebViewAction(unwrapNC(container), interactiveWebViewsResult.get(i));
                            subnodeViewMgr.appendToGroup(GROUP_SUBNODE_VIEWS, action);
                        }
                    }
                    action = new OpenSubnodeWebViewAction(Wrapper.unwrap(container, SubNodeContainer.class));
                    manager.appendToGroup(IWorkbenchActionConstants.GROUP_APP, action);
                }
            }
            // add port views
            manager.add(new Separator("outPortViews"));
            int numOutPorts = container.getNrOutPorts();
            for (int i = 0; i < numOutPorts; i++) {
                if (i == 0 && !(container instanceof WorkflowManagerUI)) {
                    // skip the implicit flow var ports on "normal" nodes
                    continue;
                }
                if (wraps(container, NodeContainer.class)) {
                    action = new OpenPortViewAction(unwrapNC(container), i, numOutPorts);
                    manager.appendToGroup("outPortViews", action);
                }
            }
        }
    }
    boolean addMetaNodeActions = false;
    boolean addSubNodeActions = false;
    for (Object p : parts) {
        if (p instanceof NodeContainerEditPart) {
            NodeContainerUI model = ((NodeContainerEditPart) p).getNodeContainer();
            if (model instanceof WorkflowManagerUI) {
                addMetaNodeActions = true;
            } else if (model instanceof SubNodeContainerUI) {
                addSubNodeActions = true;
            }
        }
    }
    if (addMetaNodeActions) {
        metanodeMenuMgr = getMetaNodeMenuManager(metanodeMenuMgr, manager);
        // SAVE AS TEMPLATE
        action = m_actionRegistry.getAction(SaveAsMetaNodeTemplateAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // CHECK UPDATE
        action = m_actionRegistry.getAction(CheckUpdateMetaNodeLinkAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // DISCONNECT
        action = m_actionRegistry.getAction(DisconnectMetaNodeLinkAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // LINK TYPE
        action = m_actionRegistry.getAction(ChangeMetaNodeLinkAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // REVEAL TEMPLATE
        action = m_actionRegistry.getAction(RevealMetaNodeTemplateAction.ID);
        metanodeMenuMgr.appendToGroup(GROUP_METANODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // LOCK
        if (Boolean.getBoolean(KNIMEConstants.PROPERTY_SHOW_METANODE_LOCK_ACTION)) {
            action = m_actionRegistry.getAction(LockMetaNodeAction.ID);
            metanodeMenuMgr.appendToGroup(GROUP_METANODE, action);
            ((AbstractNodeAction) action).update();
        }
    }
    if (addSubNodeActions) {
        subnodeMenuMgr = getSubNodeMenuManager(subnodeMenuMgr, manager);
        // SAVE AS TEMPLATE (SUBNODE)
        action = m_actionRegistry.getAction(SaveAsSubNodeTemplateAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // CHECK UPDATE (SUBNODE)
        action = m_actionRegistry.getAction(CheckUpdateMetaNodeLinkAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // DISCONNECT LINK (SUBNODE)
        action = m_actionRegistry.getAction(DisconnectSubNodeLinkAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // CHANGE LINK (SUBNODE)
        action = m_actionRegistry.getAction(ChangeSubNodeLinkAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // REVEAL TEMPLATE (SUBNODE)
        action = m_actionRegistry.getAction(RevealSubNodeTemplateAction.ID);
        subnodeMenuMgr.appendToGroup(GROUP_SUBNODE_LINKS, action);
        ((AbstractNodeAction) action).update();
        // LOCK SUBNODE
        if (Boolean.getBoolean(KNIMEConstants.PROPERTY_SHOW_METANODE_LOCK_ACTION)) {
            action = m_actionRegistry.getAction(LockSubNodeAction.ID);
            subnodeMenuMgr.appendToGroup(GROUP_SUBNODE, action);
            ((AbstractNodeAction) action).update();
        }
    }
    manager.updateAll(true);
}
Also used : NodeContainerUI(org.knime.core.ui.node.workflow.NodeContainerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) SingleNodeContainerUI(org.knime.core.ui.node.workflow.SingleNodeContainerUI) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) ExecuteAndOpenViewAction(org.knime.workbench.editor2.actions.ExecuteAndOpenViewAction) OpenViewAction(org.knime.workbench.editor2.actions.OpenViewAction) OpenInteractiveWebViewAction(org.knime.workbench.editor2.actions.OpenInteractiveWebViewAction) AddAnnotationAction(org.knime.workbench.editor2.actions.AddAnnotationAction) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) OpenPortViewAction(org.knime.workbench.editor2.actions.OpenPortViewAction) AbstractNodeAction(org.knime.workbench.editor2.actions.AbstractNodeAction) OpenSubNodeEditorAction(org.knime.workbench.editor2.actions.OpenSubNodeEditorAction) List(java.util.List) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) IAction(org.eclipse.jface.action.IAction) OpenSubworkflowEditorAction(org.knime.workbench.editor2.actions.OpenSubworkflowEditorAction) UpdateAction(org.eclipse.gef.ui.actions.UpdateAction) OpenInteractiveViewAction(org.knime.workbench.editor2.actions.OpenInteractiveViewAction) WorkflowInPortBarEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortBarEditPart) EditPart(org.eclipse.gef.EditPart) WorkflowInPortEditPart(org.knime.workbench.editor2.editparts.WorkflowInPortEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) WorkflowManagerUI(org.knime.core.ui.node.workflow.WorkflowManagerUI) SubNodeContainerUI(org.knime.core.ui.node.workflow.SubNodeContainerUI) Point(org.eclipse.swt.graphics.Point) OpenSubnodeWebViewAction(org.knime.workbench.editor2.actions.OpenSubnodeWebViewAction) OpenWorkflowPortViewAction(org.knime.workbench.editor2.actions.OpenWorkflowPortViewAction) IMenuManager(org.eclipse.jface.action.IMenuManager) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) Separator(org.eclipse.jface.action.Separator)

Example 3 with InteractiveWebViewsResult

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

the class DefaultOpenViewAction method runOnNodes.

/**
 * This opens the first view of all the selected nodes.
 *
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    LOGGER.debug("Creating open default view job for " + nodeParts.length + " node(s)...");
    for (NodeContainerEditPart p : nodeParts) {
        final NodeContainer cont = unwrapNC(p.getNodeContainer());
        final InteractiveWebViewsResult webViewsResult = cont.getInteractiveWebViews();
        boolean hasView = cont.getNrViews() > 0;
        hasView |= cont.hasInteractiveView() || webViewsResult.size() > 0;
        hasView |= OpenSubnodeWebViewAction.hasContainerView(cont);
        if (cont.getNodeContainerState().isExecuted() && hasView) {
            Display.getDefault().asyncExec(new Runnable() {

                @Override
                public void run() {
                    try {
                        final IAction action;
                        if (cont.hasInteractiveView()) {
                            action = new OpenInteractiveViewAction(cont);
                        } else if (cont instanceof SubNodeContainer) {
                            action = new OpenSubnodeWebViewAction((SubNodeContainer) cont);
                        } else if (webViewsResult.size() > 0) {
                            action = new OpenInteractiveWebViewAction(cont, webViewsResult.get(0));
                        } else {
                            action = new OpenViewAction(cont, 0);
                        }
                        action.run();
                    } catch (Throwable t) {
                        MessageBox mb = new MessageBox(Display.getDefault().getActiveShell(), SWT.ICON_ERROR | SWT.OK);
                        mb.setText("View cannot be opened");
                        mb.setMessage("The view cannot be opened for the " + "following reason:\n" + t.getMessage());
                        mb.open();
                        LOGGER.error("The view for node '" + cont.getNameWithID() + "' has thrown a '" + t.getClass().getSimpleName() + "'. That is most likely an " + "implementation error.", t);
                    }
                }
            });
        }
    }
    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 : IAction(org.eclipse.jface.action.IAction) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer) MessageBox(org.eclipse.swt.widgets.MessageBox) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult)

Example 4 with InteractiveWebViewsResult

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

the class SubNodeContainer method getInteractiveWebViews.

/**
 * A {@link InteractiveWebViewsResult} for a subnode containing either a single page view on all appropriate wizard views or a set of all individual wizard views (no recursion).
 *
 * @param combinedView
 * @return
 */
public InteractiveWebViewsResult getInteractiveWebViews(final boolean combinedView) {
    try (WorkflowLock lock = m_wfm.lock()) {
        Builder builder = InteractiveWebViewsResult.newBuilder();
        if (combinedView) {
        } else {
            // collect all the nodes first, then do make names unique (in case there are 2+ scatterplot)
            NativeNodeContainer[] nodesWithViews = m_wfm.getWorkflow().getNodeValues().stream().filter(n -> n instanceof NativeNodeContainer).filter(n -> n.getInteractiveWebViews().size() > 0).map(n -> (NativeNodeContainer) n).toArray(NativeNodeContainer[]::new);
            // count how often certain names are in use
            Map<String, Long> uniqueNameBag = Arrays.stream(nodesWithViews).map(n -> n.getInteractiveViewName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
            for (NativeNodeContainer n : nodesWithViews) {
                String name = n.getInteractiveViewName();
                if (uniqueNameBag.get(name) >= 2L) {
                    name = name.concat(" (ID " + n.getID().getIndex() + ")");
                }
                builder.add(n, name);
            }
        }
        return builder.build();
    }
}
Also used : WizardNode(org.knime.core.node.wizard.WizardNode) VirtualSubNodeInputNodeFactory(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeFactory) Arrays(java.util.Arrays) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) ReferencedFile(org.knime.core.internal.ReferencedFile) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) NodeContainerExecutionStatus(org.knime.core.node.workflow.execresult.NodeContainerExecutionStatus) VirtualSubNodeOutputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeModel) Node(org.knime.core.node.Node) Document(org.w3c.dom.Document) Map(java.util.Map) ComponentMetadataBuilder(org.knime.core.node.workflow.ComponentMetadata.ComponentMetadataBuilder) NodeDescription(org.knime.core.node.NodeDescription) LockFailedException(org.knime.core.util.LockFailedException) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) ThreadPool(org.knime.core.util.ThreadPool) Set(java.util.Set) ThreadNodeExecutionJobManager(org.knime.core.node.exec.ThreadNodeExecutionJobManager) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) Callable(java.util.concurrent.Callable) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) ArrayList(java.util.ArrayList) NotConfigurableException(org.knime.core.node.NotConfigurableException) WorkflowExecutionResult(org.knime.core.node.workflow.execresult.WorkflowExecutionResult) DialogNode(org.knime.core.node.dialog.DialogNode) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) InteractiveView(org.knime.core.node.interactive.InteractiveView) FileOutputStream(java.io.FileOutputStream) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) IOException(java.io.IOException) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) ExecutionException(java.util.concurrent.ExecutionException) EnabledDialogNodeModelFilter(org.knime.core.node.dialog.EnabledDialogNodeModelFilter) CSSModifiable(org.knime.core.node.wizard.CSSModifiable) XmlException(org.apache.xmlbeans.XmlException) TreeMap(java.util.TreeMap) VirtualSubNodeOutputNodeFactory(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeFactory) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) NodeType(org.knime.core.node.NodeFactory.NodeType) ViewHideable(org.knime.core.node.wizard.ViewHideable) Builder(org.knime.core.node.workflow.action.InteractiveWebViewsResult.Builder) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) URL(java.net.URL) NodeConfigureHelper(org.knime.core.node.NodeConfigureHelper) NodeDialogPane(org.knime.core.node.NodeDialogPane) ByteArrayInputStream(java.io.ByteArrayInputStream) VirtualSubNodeExchange(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeExchange) AbstractNodeView(org.knime.core.node.AbstractNodeView) URI(java.net.URI) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortType(org.knime.core.node.port.PortType) Collection(java.util.Collection) VirtualSubNodeInputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeModel) NodeModel(org.knime.core.node.NodeModel) Collectors(java.util.stream.Collectors) List(java.util.List) BufferedDataTable(org.knime.core.node.BufferedDataTable) WorkflowPortTemplate(org.knime.core.node.workflow.WorkflowPersistor.WorkflowPortTemplate) NodeContainerTemplateLinkUpdateResult(org.knime.core.node.workflow.WorkflowPersistor.NodeContainerTemplateLinkUpdateResult) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Optional(java.util.Optional) CheckUtils(org.knime.core.node.util.CheckUtils) PortObject(org.knime.core.node.port.PortObject) NodeContainerExecutionResult(org.knime.core.node.workflow.execresult.NodeContainerExecutionResult) SubNodeDescriptionProvider(org.knime.core.node.dialog.SubNodeDescriptionProvider) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) LoadVersion(org.knime.core.util.LoadVersion) HashMap(java.util.HashMap) ArrayUtils(org.apache.commons.lang3.ArrayUtils) NodeSettings(org.knime.core.node.NodeSettings) ConnectionType(org.knime.core.node.workflow.ConnectionContainer.ConnectionType) Function(java.util.function.Function) Pair(org.knime.core.util.Pair) ExecutionContext(org.knime.core.node.ExecutionContext) ConnectionContainerTemplate(org.knime.core.node.workflow.WorkflowPersistor.ConnectionContainerTemplate) ObjectUtils(org.apache.commons.lang3.ObjectUtils) NodeLogger(org.knime.core.node.NodeLogger) DOMException(org.w3c.dom.DOMException) EXECUTED(org.knime.core.node.workflow.InternalNodeContainerState.EXECUTED) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) Role(org.knime.core.node.workflow.MetaNodeTemplateInformation.Role) InteractiveWebViewsResult(org.knime.core.node.workflow.action.InteractiveWebViewsResult) NodeDescription27Proxy(org.knime.core.node.NodeDescription27Proxy) OutputStream(java.io.OutputStream) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) TemplateType(org.knime.core.node.workflow.MetaNodeTemplateInformation.TemplateType) NodeModelFilter(org.knime.core.node.workflow.WorkflowManager.NodeModelFilter) MetaPortInfo(org.knime.core.node.port.MetaPortInfo) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) Type(org.knime.core.node.workflow.NodeMessage.Type) TimeUnit(java.util.concurrent.TimeUnit) Collectors.toList(java.util.stream.Collectors.toList) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigurationLayoutUtil(org.knime.core.node.dialog.util.ConfigurationLayoutUtil) NodeProperty(org.knime.core.node.workflow.NodePropertyChangedEvent.NodeProperty) MetaNodeDialogType(org.knime.core.node.workflow.MetaNodeDialogPane.MetaNodeDialogType) SubnodeContainerExecutionResult(org.knime.core.node.workflow.execresult.SubnodeContainerExecutionResult) Collections(java.util.Collections) InputStream(java.io.InputStream) ComponentMetadataBuilder(org.knime.core.node.workflow.ComponentMetadata.ComponentMetadataBuilder) Builder(org.knime.core.node.workflow.action.InteractiveWebViewsResult.Builder)

Aggregations

InteractiveWebViewsResult (org.knime.core.node.workflow.action.InteractiveWebViewsResult)4 IAction (org.eclipse.jface.action.IAction)3 List (java.util.List)2 NodeContainerEditPart (org.knime.workbench.editor2.editparts.NodeContainerEditPart)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 URI (java.net.URI)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1 Optional (java.util.Optional)1