Search in sources :

Example 31 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class RowKeyNodeModel2 method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    assert (settings != null);
    final SettingsModelBoolean replaceRowKeyModel = m_replaceKey.createCloneWithValidatedValue(settings);
    final SettingsModelBoolean appendRowKeyModel = m_appendRowKey.createCloneWithValidatedValue(settings);
    final SettingsModelString newRowKeyModel = m_newRowKeyColumn.createCloneWithValidatedValue(settings);
    final SettingsModelString newColNameModel = m_newColumnName.createCloneWithValidatedValue(settings);
    validateInput(null, appendRowKeyModel.getBooleanValue(), newColNameModel.getStringValue(), replaceRowKeyModel.getBooleanValue(), newRowKeyModel.getStringValue(), appendRowKeyModel.getBooleanValue());
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 32 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class NumericRowSplitterNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_columnSelection.validateSettings(settings);
    m_lowerBound.validateSettings(settings);
    m_lowerBoundCheck.validateSettings(settings);
    m_lowerBoundValue.validateSettings(settings);
    m_upperBound.validateSettings(settings);
    m_upperBoundCheck.validateSettings(settings);
    m_upperBoundValue.validateSettings(settings);
    SettingsModelBoolean lowerBoundCheck = m_lowerBoundCheck.createCloneWithValidatedValue(settings);
    SettingsModelBoolean upperBoundCheck = m_upperBoundCheck.createCloneWithValidatedValue(settings);
    if (lowerBoundCheck.getBooleanValue() && upperBoundCheck.getBooleanValue()) {
        SettingsModelDouble lowerBoundValue = m_lowerBoundValue.createCloneWithValidatedValue(settings);
        double low = lowerBoundValue.getDoubleValue();
        SettingsModelDouble upperBoundValue = m_upperBoundValue.createCloneWithValidatedValue(settings);
        double upp = upperBoundValue.getDoubleValue();
        if (low > upp) {
            throw new InvalidSettingsException("Check lower and upper " + "bound values: " + low + " > " + upp);
        }
        if (low == upp) {
            SettingsModelString lowerBound = m_lowerBound.createCloneWithValidatedValue(settings);
            boolean inclLow = NumericRowSplitterNodeDialogPane.includeLowerBound(lowerBound);
            SettingsModelString upperBound = m_upperBound.createCloneWithValidatedValue(settings);
            boolean inclUpp = NumericRowSplitterNodeDialogPane.includeUpperBound(upperBound);
            if ((inclLow ^ inclUpp) || (!inclLow & !inclUpp)) {
                throw new InvalidSettingsException("Lower and upper bounds " + "are inconsistent with borders!");
            }
        }
    }
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelDouble(org.knime.core.node.defaultnodesettings.SettingsModelDouble) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 33 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class SQLInjectNodeDialog method loadAdditionalSettingsFrom.

/**
 * List of available string flow variables must be updated since it could
 * have changed.
 *
 * {@inheritDoc}
 */
@Override
public void loadAdditionalSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    super.loadAdditionalSettingsFrom(settings, specs);
    Map<String, FlowVariable> flowVars = getAvailableFlowVariables();
    // check for selected value
    String flowVar = "";
    try {
        flowVar = ((SettingsModelString) m_flowVarSettingsModel.createCloneWithValidatedValue(settings)).getStringValue();
    } catch (InvalidSettingsException e) {
        LOGGER.debug("Settings model could not be cloned with given settings!");
    } finally {
        m_flowVarSelection.replaceListItems(flowVars.values(), flowVar);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 34 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class DBDropTableNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    final String tableName = ((SettingsModelString) m_tableName.createCloneWithValidatedValue(settings)).getStringValue();
    if (tableName == null || tableName.isEmpty()) {
        throw new InvalidSettingsException("Please provide the table name to drop");
    }
    m_cascade.validateSettings(settings);
    m_failIfNotExists.validateSettings(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 35 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class SleepNodeModel method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
    settings.addInt(CFGKEY_WAITOPTION, m_selection);
    settings.addInt(CFGKEY_FORHOURS, m_forHours);
    settings.addInt(CFGKEY_FORMINUTES, m_forMin);
    settings.addInt(CFGKEY_FORSECONDS, m_forSec);
    settings.addInt(CFGKEY_TOHOURS, m_toHours);
    settings.addInt(CFGKEY_TOMINUTES, m_toMin);
    settings.addInt(CFGKEY_TOSECONDS, m_toSec);
    settings.addString(CFGKEY_FILEPATH, m_filePath);
    SettingsModelString sms = new SettingsModelString(CFGKEY_FILESTATUS, "Modification");
    sms.setStringValue(m_fileStatus);
    sms.saveSettingsTo(settings);
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)99 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)39 SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)15 ChangeListener (javax.swing.event.ChangeListener)13 ChangeEvent (javax.swing.event.ChangeEvent)12 IOException (java.io.IOException)8 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)8 DialogComponentString (org.knime.core.node.defaultnodesettings.DialogComponentString)7 Duration (java.time.Duration)5 Period (java.time.Period)5 DateTimeParseException (java.time.format.DateTimeParseException)5 SettingsModelDateTime (org.knime.time.util.SettingsModelDateTime)5 File (java.io.File)4 LocalDate (java.time.LocalDate)4 LocalDateTime (java.time.LocalDateTime)4 ZonedDateTime (java.time.ZonedDateTime)4 Temporal (java.time.temporal.Temporal)4 TemporalAmount (java.time.temporal.TemporalAmount)4 DateTimeType (org.knime.time.util.DateTimeType)4 DateTimeException (java.time.DateTimeException)3