Search in sources :

Example 6 with JavaSnippetSettings

use of org.knime.base.node.jsnippet.util.JavaSnippetSettings in project knime-core by knime.

the class JavaSnippetNodeDialog method saveSettingsTo.

@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    ViewUtils.invokeAndWaitInEDT(() -> {
        // pressed.
        if (null != m_inFieldsTable.getTable().getCellEditor()) {
            m_inFieldsTable.getTable().getCellEditor().stopCellEditing();
        }
        if (null != m_outFieldsTable.getTable().getCellEditor()) {
            m_outFieldsTable.getTable().getCellEditor().stopCellEditing();
        }
    });
    final JavaSnippetSettings s = m_snippet.getSettings();
    // if settings have less fields than defined in the table it means
    // that the tables contain errors
    final FieldsTableModel inFieldsModel = (FieldsTableModel) m_inFieldsTable.getTable().getModel();
    if (!inFieldsModel.validateValues()) {
        throw new IllegalArgumentException("The input fields table has errors.");
    }
    final FieldsTableModel outFieldsModel = (FieldsTableModel) m_outFieldsTable.getTable().getModel();
    if (!outFieldsModel.validateValues()) {
        throw new IllegalArgumentException("The output fields table has errors.");
    }
    s.setBundles(m_bundleListPanel.getBundles());
    // give subclasses the chance to modify settings
    preSaveSettings(s);
    s.saveSettings(settings);
}
Also used : JavaSnippetSettings(org.knime.base.node.jsnippet.util.JavaSnippetSettings) FieldsTableModel(org.knime.base.node.jsnippet.ui.FieldsTableModel) OutFieldsTableModel(org.knime.base.node.jsnippet.ui.OutFieldsTableModel)

Example 7 with JavaSnippetSettings

use of org.knime.base.node.jsnippet.util.JavaSnippetSettings in project knime-core by knime.

the class JavaSnippetNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    JavaSnippetSettings s = new JavaSnippetSettings();
    s.loadSettings(settings);
}
Also used : JavaSnippetSettings(org.knime.base.node.jsnippet.util.JavaSnippetSettings)

Aggregations

JavaSnippetSettings (org.knime.base.node.jsnippet.util.JavaSnippetSettings)7 Test (org.junit.Test)3 AbstractJSnippet (org.knime.base.node.jsnippet.expression.AbstractJSnippet)3 Field (java.lang.reflect.Field)1 Abort (org.knime.base.node.jsnippet.expression.Abort)1 FieldsTableModel (org.knime.base.node.jsnippet.ui.FieldsTableModel)1 OutFieldsTableModel (org.knime.base.node.jsnippet.ui.OutFieldsTableModel)1 OutCol (org.knime.base.node.jsnippet.util.field.OutCol)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)1