Search in sources :

Example 1 with ViewHideable

use of org.knime.core.node.wizard.ViewHideable in project knime-core by knime.

the class SubNodeContainer method setHideNodeFromWizard.

/**
 * Sets a flag on a given {@link WizardNode} of nested subnode, whether or not it is hidden from wizard execution
 * @param id the node to set the flag on
 * @param hide true if the node is supposed to be hidden from WebPortal or wizard execution, false otherwise
 * @since 3.5
 * @noreference This method is not intended to be referenced by clients.
 */
public void setHideNodeFromWizard(final NodeID id, final boolean hide) {
    try (WorkflowLock lock = lock()) {
        NodeContainer container = m_wfm.getNodeContainer(id, NodeContainer.class, true);
        ViewHideable vh = null;
        NativeNodeContainer nnc = null;
        if (container instanceof SubNodeContainer) {
            vh = (SubNodeContainer) container;
        } else if (container instanceof NativeNodeContainer) {
            nnc = (NativeNodeContainer) container;
            NodeModel model = nnc.getNodeModel();
            CheckUtils.checkArgument(model instanceof WizardNode, "Can't set hide in wizard flag on non-wizard nodes.");
            vh = (WizardNode<?, ?>) model;
        } else {
            throw new IllegalArgumentException("Node with id " + id + " needs to be a native node or a subnode container!");
        }
        if (vh != null) {
            if (hide != vh.isHideInWizard()) {
                vh.setHideInWizard(hide);
                if (nnc != null) {
                    nnc.saveNodeSettingsToDefault();
                    nnc.setDirty();
                }
            }
        }
    }
}
Also used : VirtualSubNodeOutputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeModel) VirtualSubNodeInputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeModel) NodeModel(org.knime.core.node.NodeModel) ViewHideable(org.knime.core.node.wizard.ViewHideable) WizardNode(org.knime.core.node.wizard.WizardNode)

Example 2 with ViewHideable

use of org.knime.core.node.wizard.ViewHideable in project knime-core by knime.

the class WizardPageUtil method collectWizardPageNodes.

private static void collectWizardPageNodes(final WorkflowManager wfm, final boolean recurseIntoComponents, final boolean includeHiddenNodes, final List<NativeNodeContainer> res) {
    for (NodeContainer nc : wfm.getNodeContainers()) {
        if (nc instanceof NativeNodeContainer) {
            NativeNodeContainer nnc = (NativeNodeContainer) nc;
            var nodeModel = nnc.getNodeModel();
            if (!includeHiddenNodes && nodeModel instanceof ViewHideable && ((ViewHideable) nodeModel).isHideInWizard()) {
                continue;
            }
            if (isWizardPageNode(nnc)) {
                res.add(nnc);
            }
        } else if (recurseIntoComponents && nc instanceof SubNodeContainer) {
            collectWizardPageNodes(((SubNodeContainer) nc).getWorkflowManager(), recurseIntoComponents, includeHiddenNodes, res);
        }
    }
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) ViewHideable(org.knime.core.node.wizard.ViewHideable) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer) SingleNodeContainer(org.knime.core.node.workflow.SingleNodeContainer) NativeNodeContainer(org.knime.core.node.workflow.NativeNodeContainer)

Aggregations

ViewHideable (org.knime.core.node.wizard.ViewHideable)2 NodeModel (org.knime.core.node.NodeModel)1 WizardNode (org.knime.core.node.wizard.WizardNode)1 NativeNodeContainer (org.knime.core.node.workflow.NativeNodeContainer)1 NodeContainer (org.knime.core.node.workflow.NodeContainer)1 SingleNodeContainer (org.knime.core.node.workflow.SingleNodeContainer)1 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)1 VirtualSubNodeInputNodeModel (org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeModel)1 VirtualSubNodeOutputNodeModel (org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeOutputNodeModel)1