Search in sources :

Example 21 with SubNodeContainer

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

the class LockSubNodeAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of
 *         <code>SubNodeContainer</code>, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    if (getManager().isWriteProtected()) {
        return false;
    }
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    Object model = nodes[0].getModel();
    if (Wrapper.wraps(model, SubNodeContainer.class)) {
        SubNodeContainer snc = Wrapper.unwrap((UI) model, SubNodeContainer.class);
        if (snc.isWriteProtected()) {
            return false;
        }
        return true;
    } else {
        return false;
    }
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart)

Example 22 with SubNodeContainer

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

the class SaveAsSubNodeTemplateAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of
 *         <code>SubNodeContainer</code> and there is no link associated
 *         with it, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    if (getManager().isWriteProtected()) {
        return false;
    }
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    Object model = nodes[0].getModel();
    if (Wrapper.wraps(model, SubNodeContainer.class)) {
        SubNodeContainer snc = unwrap((UI) model, SubNodeContainer.class);
        switch(snc.getTemplateInformation().getRole()) {
            case None:
                break;
            default:
                return false;
        }
        for (AbstractContentProvider p : ExplorerMountTable.getMountedContent().values()) {
            if (p.canHostMetaNodeTemplates()) {
                return true;
            }
        }
    }
    return false;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) AbstractContentProvider(org.knime.workbench.explorer.view.AbstractContentProvider) ContentObject(org.knime.workbench.explorer.view.ContentObject)

Example 23 with SubNodeContainer

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

the class SubNodeReconfigureAction method internalCalculateEnabled.

/**
 * @return true, if underlying model instance of <code>WorkflowManager</code>, otherwise false
 */
@Override
protected boolean internalCalculateEnabled() {
    NodeContainerEditPart[] nodes = getSelectedParts(NodeContainerEditPart.class);
    if (nodes.length != 1) {
        return false;
    }
    NodeContainer nc = Wrapper.unwrapOptionalNC(nodes[0].getNodeContainer()).orElse(null);
    if (nc instanceof SubNodeContainer) {
        return !((SubNodeContainer) nc).isWriteProtected();
    }
    return false;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) NodeContainer(org.knime.core.node.workflow.NodeContainer)

Example 24 with SubNodeContainer

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

the class SubnodeLayoutAction method runOnNodes.

/**
 * {@inheritDoc}
 */
@Override
public void runOnNodes(final NodeContainerEditPart[] nodeParts) {
    WorkflowManager manager = getManager();
    SubNodeContainer subnode = (SubNodeContainer) manager.getDirectNCParent();
    SubnodeLayoutWizard wizard = new SubnodeLayoutWizard(subnode);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), wizard);
    dlg.create();
    dlg.open();
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) WorkflowManager(org.knime.core.node.workflow.WorkflowManager) SubnodeLayoutWizard(org.knime.workbench.editor2.subnode.SubnodeLayoutWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 25 with SubNodeContainer

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

the class ChangeSubNodeLinkCommand method setLink.

private boolean setLink(final URI link) {
    NodeContainer subNode = getHostWFM().getNodeContainer(m_subNodeID);
    if (!(subNode instanceof SubNodeContainer)) {
        LOGGER.error("Command failed: Specified node is not a Wrapped Metanode");
        return false;
    }
    MetaNodeTemplateInformation templateInfo = ((SubNodeContainer) subNode).getTemplateInformation();
    MetaNodeTemplateInformation newInfo;
    try {
        newInfo = templateInfo.createLinkWithUpdatedSource(m_newLink);
    } catch (InvalidSettingsException e1) {
        // will not happen.
        LOGGER.error("Command failed: Specified node is not a Wrapped Metanode with a link." + e1.getMessage(), e1);
        return false;
    }
    getHostWFM().setTemplateInformation(m_subNodeID, newInfo);
    return true;
}
Also used : SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeContainer(org.knime.core.node.workflow.NodeContainer) SubNodeContainer(org.knime.core.node.workflow.SubNodeContainer) MetaNodeTemplateInformation(org.knime.core.node.workflow.MetaNodeTemplateInformation)

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