Search in sources :

Example 1 with AbstractQuickFormConfiguration

use of org.knime.core.quickform.AbstractQuickFormConfiguration in project knime-core by knime.

the class WorkflowManager method loadSettings.

/**
 * {@inheritDoc}
 */
@Override
void loadSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    super.loadSettings(settings);
    NodeSettingsRO modelSettings = settings.getNodeSettings("model");
    Map<NodeID, QuickFormInputNode> nodes = findNodes(QuickFormInputNode.class, false);
    for (Entry<NodeID, QuickFormInputNode> entry : nodes.entrySet()) {
        NodeID id = entry.getKey();
        String nodeID = Integer.toString(id.getIndex());
        if (modelSettings.containsKey(nodeID)) {
            NodeSettingsRO conf = modelSettings.getNodeSettings(nodeID);
            QuickFormInputNode qfin = entry.getValue();
            NodeSettingsWO oldSettings = new NodeSettings(nodeID);
            qfin.getConfiguration().getValueConfiguration().saveValue(oldSettings);
            if (!conf.equals(oldSettings)) {
                // FIXME: likely not here but in the WFM...
                // not needed (actually nodes not work) because WFM itself
                // was reset completely if any one of the settings change.
                // SingleNodeContainer snc = (SingleNodeContainer)this.getNodeContainer(id);
                // snc.reset();
                @SuppressWarnings("unchecked") AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration> config = (AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration>) qfin.getConfiguration();
                if (config != null) {
                    config.getValueConfiguration().loadValueInModel(conf);
                    saveNodeSettingsToDefault(id);
                }
            // see above: not needed
            // this.configureNodeAndSuccessors(id, true);
            }
        }
    }
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) NodeSettings(org.knime.core.node.NodeSettings) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode)

Example 2 with AbstractQuickFormConfiguration

use of org.knime.core.quickform.AbstractQuickFormConfiguration in project knime-core by knime.

the class WorkflowManager method saveSettings.

/**
 * {@inheritDoc}
 */
@Override
void saveSettings(final NodeSettingsWO settings) {
    super.saveSettings(settings);
    // TODO: as we don't have a node model associated with the wfm, we must
    // do the same thing a dialog does when saving settings (it assumes
    // existance of a node).
    // Node.SettingsLoaderAndWriter l = new Node.SettingsLoaderAndWriter();
    // NodeSettings model = new NodeSettings("field_ignored");
    // NodeSettings variables;
    // l.setModelSettings(model);
    // l.setVariablesSettings(variables);
    // l.save(settings);
    NodeSettingsWO modelSettings = settings.addNodeSettings("model");
    for (Map.Entry<NodeID, QuickFormInputNode> e : findNodes(QuickFormInputNode.class, false).entrySet()) {
        String nodeID = Integer.toString(e.getKey().getIndex());
        NodeSettingsWO subSettings = modelSettings.addNodeSettings(nodeID);
        @SuppressWarnings("unchecked") AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration> config = (AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration>) e.getValue().getConfiguration();
        if (config != null) {
            config.getValueConfiguration().saveValue(subSettings);
        }
    }
    SingleNodeContainerSettings s = new SingleNodeContainerSettings();
    NodeContainerSettings ncSet = new NodeContainerSettings();
    ncSet.save(settings);
    s.save(settings);
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Example 3 with AbstractQuickFormConfiguration

use of org.knime.core.quickform.AbstractQuickFormConfiguration in project knime-core by knime.

the class MetaNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    // we may have quickform nodes to allow a column selection?)
    for (Map.Entry<NodeID, MetaNodeDialogNode> e : m_nodes.entrySet()) {
        if (e.getValue() instanceof QuickFormInputNode) {
            AbstractQuickFormConfiguration config = ((QuickFormInputNode) e.getValue()).getConfiguration();
            AbstractQuickFormValueInConfiguration valueConfig = config.getValueConfiguration();
            try {
                NodeSettingsRO subSettings = settings.getNodeSettings(Integer.toString(e.getKey().getIndex()));
                valueConfig.loadValueInDialog(subSettings);
                QuickFormConfigurationPanel panel = m_quickFormInputNodePanels.get(e.getKey());
                assert panel != null : "No panel instance for node " + e.getKey();
                panel.loadSettings(valueConfig);
            } catch (InvalidSettingsException ise) {
            // no op
            }
        } else if (e.getValue() instanceof DialogNode) {
            final DialogNode dialogNode = (DialogNode) e.getValue();
            final DialogNodeValue nodeValue = dialogNode.createEmptyDialogValue();
            final String parameterName = SubNodeContainer.getDialogNodeParameterName(dialogNode, e.getKey());
            try {
                NodeSettingsRO subSettings = settings.getNodeSettings(parameterName);
                nodeValue.loadFromNodeSettingsInDialog(subSettings);
                final DialogNodePanel dialogNodePanel = m_dialogNodePanels.get(e.getKey());
                dialogNodePanel.loadNodeValue(nodeValue);
            } catch (InvalidSettingsException ex) {
            // no op
            }
        }
    }
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) QuickFormConfigurationPanel(org.knime.core.quickform.QuickFormConfigurationPanel) DialogNode(org.knime.core.node.dialog.DialogNode) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DialogNodePanel(org.knime.core.node.dialog.DialogNodePanel)

Example 4 with AbstractQuickFormConfiguration

use of org.knime.core.quickform.AbstractQuickFormConfiguration in project knime-core by knime.

the class MetaNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    for (Map.Entry<NodeID, MetaNodeDialogNode> e : m_nodes.entrySet()) {
        final NodeID key = e.getKey();
        if (e.getValue() instanceof QuickFormInputNode) {
            AbstractQuickFormConfiguration config = ((QuickFormInputNode) e.getValue()).getConfiguration();
            AbstractQuickFormValueInConfiguration valueConfig = config.createValueConfiguration();
            QuickFormConfigurationPanel value = m_quickFormInputNodePanels.get(key);
            value.saveSettings(valueConfig);
            NodeSettingsWO subSettings = settings.addNodeSettings((Integer.toString(key.getIndex())));
            valueConfig.saveValue(subSettings);
        } else if (e.getValue() instanceof DialogNode) {
            DialogNode dialogNode = (DialogNode) e.getValue();
            DialogNodePanel nodePanel = m_dialogNodePanels.get(key);
            DialogNodeValue nodeValue = nodePanel.getNodeValue();
            final String parameterName = SubNodeContainer.getDialogNodeParameterName(dialogNode, key);
            if (nodeValue != null) {
                NodeSettingsWO subSettings = settings.addNodeSettings((parameterName));
                nodeValue.saveToNodeSettings(subSettings);
            }
        }
    }
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) QuickFormConfigurationPanel(org.knime.core.quickform.QuickFormConfigurationPanel) DialogNode(org.knime.core.node.dialog.DialogNode) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DialogNodePanel(org.knime.core.node.dialog.DialogNodePanel)

Aggregations

AbstractQuickFormConfiguration (org.knime.core.quickform.AbstractQuickFormConfiguration)4 AbstractQuickFormValueInConfiguration (org.knime.core.quickform.AbstractQuickFormValueInConfiguration)4 QuickFormInputNode (org.knime.core.quickform.in.QuickFormInputNode)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)3 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)2 DialogNode (org.knime.core.node.dialog.DialogNode)2 DialogNodePanel (org.knime.core.node.dialog.DialogNodePanel)2 DialogNodeValue (org.knime.core.node.dialog.DialogNodeValue)2 MetaNodeDialogNode (org.knime.core.node.dialog.MetaNodeDialogNode)2 QuickFormConfigurationPanel (org.knime.core.quickform.QuickFormConfigurationPanel)2 HashMap (java.util.HashMap)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NodeSettings (org.knime.core.node.NodeSettings)1 SingleNodeContainerSettings (org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings)1