Search in sources :

Example 1 with MemoryPolicy

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

the class NodeDialogPane method internalLoadSettingsFrom.

/**
 * Method being called from the node when the dialog shall load the
 * settings from a NodeSettingsRO object. This method will call the
 * abstract loadSettingsFrom method and finally load internals
 * (i.e. memory policy of outports, if any).
 * @param settings To load from.
 * @param specs Specs at input ports
 * @param data Data from input ports
 * @param foStack Flow object stack (contains flow variables)
 * @param credentialsProvider The credentials available in the flow
 * @param isWriteProtected Whether ok/apply should be disabled
 *        (write protected metanode)
 * @throws NotConfigurableException
 * If loadSettingsFrom throws this exception.
 * @see #loadSettingsFrom(NodeSettingsRO, PortObjectSpec[])
 */
final void internalLoadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs, final PortObject[] data, final FlowObjectStack foStack, final CredentialsProvider credentialsProvider, final boolean isWriteProtected) throws NotConfigurableException {
    NodeSettingsRO modelSettings = null;
    NodeSettingsRO flowVariablesSettings = null;
    m_flowObjectStack = foStack;
    m_credentialsProvider = credentialsProvider;
    m_specs = specs;
    m_data = data;
    m_isWriteProtected = isWriteProtected;
    SingleNodeContainerSettings sncSettings;
    try {
        sncSettings = new SingleNodeContainerSettings(settings);
        modelSettings = sncSettings.getModelSettings();
        flowVariablesSettings = sncSettings.getVariablesSettings();
    } catch (InvalidSettingsException ise) {
        // silently ignored here, variables get assigned default values
        // if they are null
        sncSettings = new SingleNodeContainerSettings();
    }
    if (modelSettings == null) {
        modelSettings = new NodeSettings("empty");
    }
    if (m_memPolicyTab != null) {
        MemoryPolicy memoryPolicy = sncSettings.getMemoryPolicy();
        if (memoryPolicy == null) {
            memoryPolicy = MemoryPolicy.CacheSmallInMemory;
        }
        m_memPolicyTab.setStatus(memoryPolicy);
    }
    final AtomicReference<Throwable> exRef = new AtomicReference<Throwable>();
    final NodeSettingsRO ms = modelSettings;
    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                callDerivedLoadSettingsFrom(ms, specs, data);
            } catch (Throwable ex) {
                exRef.set(ex);
            }
        }
    };
    ViewUtils.invokeAndWaitInEDT(r);
    if (exRef.get() instanceof NotConfigurableException) {
        throw (NotConfigurableException) exRef.get();
    } else if (exRef.get() != null) {
        m_logger.error("Error loading model settings", exRef.get());
    }
    // add the flow variables tab
    addFlowVariablesTab();
    m_flowVariablesModelChanged = false;
    initFlowVariablesTab(modelSettings, flowVariablesSettings);
    // output memory policy and job manager (stored in NodeContainer)
    if (m_memPolicyTab != null || m_jobMgrTab != null) {
        NodeContainerSettings ncSettings;
        try {
            ncSettings = new NodeContainerSettings();
            ncSettings.load(settings);
        } catch (InvalidSettingsException ise) {
            ncSettings = new NodeContainerSettings();
        }
        if (m_jobMgrTab != null) {
            m_jobMgrTab.loadSettings(ncSettings, specs);
        }
    }
    updateFlowVariablesOverwriteWarning();
}
Also used : MemoryPolicy(org.knime.core.node.workflow.SingleNodeContainer.MemoryPolicy) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) NodeContainerSettings(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) AtomicReference(java.util.concurrent.atomic.AtomicReference)

Aggregations

AtomicReference (java.util.concurrent.atomic.AtomicReference)1 NodeContainerSettings (org.knime.core.node.workflow.NodeContainer.NodeContainerSettings)1 MemoryPolicy (org.knime.core.node.workflow.SingleNodeContainer.MemoryPolicy)1 SingleNodeContainerSettings (org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings)1