Search in sources :

Example 66 with SettingsModelString

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

the class NaiveBayesLearnerNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    final SettingsModelString colName = m_classifyColumnName.createCloneWithValidatedValue(settings);
    if (colName == null || colName.getStringValue().trim().length() < 1) {
        throw new InvalidSettingsException("No class column selected");
    }
    final SettingsModelIntegerBounded maxNoOfNomVals = m_maxNoOfNominalVals.createCloneWithValidatedValue(settings);
    if (maxNoOfNomVals.getIntValue() < 0) {
        throw new InvalidSettingsException("Maximum number of unique " + "nominal values should be a positive number");
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelIntegerBounded(org.knime.core.node.defaultnodesettings.SettingsModelIntegerBounded) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 67 with SettingsModelString

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

the class NewToOldTimeNodeModel method createSuffixModel.

/**
 * @param replaceOrAppendModel model for the replace/append button group
 * @return the string model, used in both dialog and model.
 */
public static SettingsModelString createSuffixModel(final SettingsModelString replaceOrAppendModel) {
    final SettingsModelString suffixModel = new SettingsModelString("suffix", "(old Date&Time)");
    replaceOrAppendModel.addChangeListener(e -> suffixModel.setEnabled(replaceOrAppendModel.getStringValue().equals(OPTION_APPEND)));
    suffixModel.setEnabled(false);
    return suffixModel;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 68 with SettingsModelString

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

the class StringToDateTimeNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_colSelect.validateSettings(settings);
    m_isReplaceOrAppend.validateSettings(settings);
    m_suffix.validateSettings(settings);
    m_format.validateSettings(settings);
    m_locale.validateSettings(settings);
    try {
        LocaleUtils.toLocale(m_locale.getStringValue());
    } catch (IllegalArgumentException ex) {
        throw new InvalidSettingsException("Unsupported locale in setting (" + m_locale.getStringValue() + "): " + ex.getMessage(), ex);
    }
    m_cancelOnFail.validateSettings(settings);
    final SettingsModelString formatClone = m_format.createCloneWithValidatedValue(settings);
    final String format = formatClone.getStringValue();
    if (StringUtils.isEmpty(format)) {
        throw new InvalidSettingsException("Format must not be empty!");
    }
    try {
        DateTimeFormatter.ofPattern(format);
    } catch (IllegalArgumentException e) {
        String msg = "Invalid date format: \"" + format + "\".";
        final String errMsg = e.getMessage();
        if (!StringUtils.isEmpty(errMsg)) {
            msg += " Reason: " + errMsg;
        }
        throw new InvalidSettingsException(msg, e);
    }
    settings.getString("typeEnum");
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 69 with SettingsModelString

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

the class StringToDateTimeNodeModel method createSuffixModel.

/**
 * @param replaceOrAppendModel model for the replace/append button group
 * @return the string model, used in both dialog and model.
 */
public static SettingsModelString createSuffixModel(final SettingsModelString replaceOrAppendModel) {
    final SettingsModelString suffixModel = new SettingsModelString("suffix", "(Date&Time)");
    replaceOrAppendModel.addChangeListener(e -> suffixModel.setEnabled(replaceOrAppendModel.getStringValue().equals(OPTION_APPEND)));
    suffixModel.setEnabled(false);
    return suffixModel;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 70 with SettingsModelString

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

the class ExtendedStatisticsNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_computeMedian.validateSettings(settings);
    m_nominalValues.validateSettings(settings);
    m_nominalValuesOutput.validateSettings(settings);
    m_nominalFilter.validateSettings(settings);
    getImageFormat().validateSettings(settings);
    SettingsModelString tmpFormat = createImageFormat();
    tmpFormat.loadSettingsFrom(settings);
    String format = tmpFormat.getStringValue();
    if (!POSSIBLE_IMAGE_FORMATS.contains(format)) {
        throw new InvalidSettingsException("Unsupported image format: " + format);
    }
    getHistogramWidth().validateSettings(settings);
    getHistogramHeight().validateSettings(settings);
    getEnableHiLite().validateSettings(settings);
    getShowMinMax().validateSettings(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)96 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)36 SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)15 ChangeListener (javax.swing.event.ChangeListener)13 ChangeEvent (javax.swing.event.ChangeEvent)12 IOException (java.io.IOException)7 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)7 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 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 File (java.io.File)3 DateTimeException (java.time.DateTimeException)3