Search in sources :

Example 6 with WizardNodeLayoutInfo

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

the class FileSubNodeContainerPersistor method save.

/**
 * @param subnodeNC
 * @param settings
 * @param exec
 * @param nodeDirRef
 * @param saveHelper
 * @throws LockFailedException
 * @throws CanceledExecutionException
 * @throws IOException
 */
static void save(final SubNodeContainer subnodeNC, final NodeSettings settings, final ExecutionMonitor exec, final ReferencedFile nodeDirRef, final WorkflowSaveHelper saveHelper) throws IOException, CanceledExecutionException, LockFailedException {
    NativeNodeContainer virtualInNode = subnodeNC.getVirtualInNode();
    settings.addInt("virtual-in-ID", virtualInNode.getID().getIndex());
    NodeSettingsWO inportsSettings = settings.addNodeSettings("inports");
    // input of subnode is represented by output of virtual in node.
    for (int i = 1; i < virtualInNode.getNrOutPorts(); i++) {
        // start at one to skip the hidden flow var port
        NodeSettingsWO inportSetting = inportsSettings.addNodeSettings("inport_" + (i - 1));
        inportSetting.addInt("index", i - 1);
        NodeSettingsWO portTypeSettings = inportSetting.addNodeSettings("type");
        virtualInNode.getOutputType(i).save(portTypeSettings);
    }
    NativeNodeContainer virtualOutNode = subnodeNC.getVirtualOutNode();
    settings.addInt("virtual-out-ID", virtualOutNode.getID().getIndex());
    // output of subnode is represented by input of virtual in node.
    NodeSettingsWO outportsSettings = settings.addNodeSettings("outports");
    for (int i = 1; i < virtualOutNode.getNrInPorts(); i++) {
        // start at one to skip the hidden flow var port
        NodeSettingsWO inportSetting = outportsSettings.addNodeSettings("outport_" + (i - 1));
        inportSetting.addInt("index", i - 1);
        NodeSettingsWO portTypeSettings = inportSetting.addNodeSettings("type");
        virtualOutNode.getInPort(i).getPortType().save(portTypeSettings);
    }
    subnodeNC.getTemplateInformation().save(settings);
    Map<Integer, WizardNodeLayoutInfo> layoutInfoMap = subnodeNC.getLayoutInfo();
    Integer[] layoutIDs = layoutInfoMap.keySet().toArray(new Integer[0]);
    NodeSettingsWO layoutInfoSettings = settings.addNodeSettings("layoutInfos");
    for (int i = 0; i < layoutInfoMap.size(); i++) {
        NodeSettingsWO curLayoutInfoSettings = layoutInfoSettings.addNodeSettings("layoutInfo_" + (i));
        curLayoutInfoSettings.addInt("nodeID", layoutIDs[i]);
        WizardNodeLayoutInfo.saveToNodeSettings(curLayoutInfoSettings, layoutInfoMap.get(layoutIDs[i]));
    }
    settings.addString("layoutJSON", subnodeNC.getLayoutJSONString());
    WorkflowManager workflowManager = subnodeNC.getWorkflowManager();
    FileWorkflowPersistor.save(workflowManager, nodeDirRef, exec, saveHelper);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) WizardNodeLayoutInfo(org.knime.core.node.wizard.WizardNodeLayoutInfo)

Aggregations

WizardNodeLayoutInfo (org.knime.core.node.wizard.WizardNodeLayoutInfo)6 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 Font (org.eclipse.swt.graphics.Font)1 FontData (org.eclipse.swt.graphics.FontData)1 Image (org.eclipse.swt.graphics.Image)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)1 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)1 NodeContainer (org.knime.core.node.workflow.NodeContainer)1 NodeID (org.knime.core.node.workflow.NodeID)1 SubNodeContainer (org.knime.core.node.workflow.SubNodeContainer)1