Search in sources :

Example 26 with SettingsModelString

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

the class ColumnComparatorNodeDialogPane method createMismatchValue.

/**
 * @return settings model for replacement value
 */
static SettingsModelString createMismatchValue() {
    SettingsModelString model = new SettingsModelString("mismatch_value", "FALSE");
    model.setEnabled(false);
    return model;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 27 with SettingsModelString

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

the class CrossJoinerNodeModel method createFirstRowIdsNameSettingsModel.

/**
 * @param showFirstRowIdsSettingsModel the enable checker model.
 * @return the column name for the first tables rowids
 */
static SettingsModelString createFirstRowIdsNameSettingsModel(final SettingsModelBoolean showFirstRowIdsSettingsModel) {
    final SettingsModelString settingsModel = new SettingsModelString("CFG_FIRST_COLUMNNAME", "FirstRowIDs");
    showFirstRowIdsSettingsModel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            settingsModel.setEnabled(showFirstRowIdsSettingsModel.getBooleanValue());
        }
    });
    settingsModel.setEnabled(showFirstRowIdsSettingsModel.getBooleanValue());
    return settingsModel;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 28 with SettingsModelString

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

the class CAIMDiscretizationNodeModel method validateSettings.

/**
 * This method validates the settings. That is:
 * <ul>
 * <li>The number of the class column must be an integer > 0</li>
 * <li>The positive value <code>DataCell</code> must not be null</li>
 * </ul>
 *
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    SettingsModelString tmp = m_classColumnName.createCloneWithValidatedValue(settings);
    String classifyColumn = tmp.getStringValue();
    if (classifyColumn == null || classifyColumn.equals("")) {
        throw new InvalidSettingsException("Discretization column not set");
    }
    SettingsModelFilterString tmpIncl = null;
    try {
        tmpIncl = m_includedColumnNames.createCloneWithValidatedValue(settings);
    } catch (InvalidSettingsException ise) {
    // new with 2.0
    }
    if (tmpIncl == null || tmpIncl.getIncludeList() == null || tmpIncl.getIncludeList().size() == 0) {
        setWarningMessage(WARNING_NO_COLS_SELECTED);
    }
    m_sortInMemory.validateSettings(settings);
}
Also used : SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 29 with SettingsModelString

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

the class GroupByNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_groupByCols.validateSettings(settings);
    // FIX bug 5040: potential problem with clone settings method when in-/exclude list contain same elements
    final SettingsModelFilterString tmpSett = new SettingsModelFilterString(CFG_GROUP_BY_COLUMNS);
    tmpSett.loadSettingsFrom(settings);
    final List<String> groupByCols = tmpSett.getIncludeList();
    m_maxUniqueValues.validateSettings(settings);
    m_enableHilite.validateSettings(settings);
    // with Knime 2.0 as well as the naming policy
    try {
        final List<ColumnAggregator> aggregators = ColumnAggregator.loadColumnAggregators(settings);
        final List<DataTypeAggregator> typeAggregators = new LinkedList<>();
        final List<PatternAggregator> patternAggregators = new LinkedList<>();
        try {
            patternAggregators.addAll(PatternAggregator.loadAggregators(settings, CFG_PATTERN_AGGREGATORS));
            typeAggregators.addAll(DataTypeAggregator.loadAggregators(settings, CFG_DATA_TYPE_AGGREGATORS));
        } catch (InvalidSettingsException e) {
        // introduced in 2.11
        }
        if (groupByCols.isEmpty() && aggregators.isEmpty() && patternAggregators.isEmpty() && typeAggregators.isEmpty()) {
            throw new IllegalArgumentException("Please select at least one group column or aggregation option");
        }
        ColumnNamePolicy namePolicy;
        try {
            final String policyLabel = ((SettingsModelString) m_columnNamePolicy.createCloneWithValidatedValue(settings)).getStringValue();
            namePolicy = ColumnNamePolicy.getPolicy4Label(policyLabel);
        } catch (final InvalidSettingsException e) {
            namePolicy = compGetColumnNamePolicy(settings);
        }
        checkDuplicateAggregators(namePolicy, aggregators);
    } catch (final InvalidSettingsException e) {
    // these settings are prior Knime 2.0 and can't contain
    // a column several times
    } catch (final IllegalArgumentException e) {
        throw new InvalidSettingsException(e.getMessage());
    }
}
Also used : PatternAggregator(org.knime.base.data.aggregation.dialogutil.pattern.PatternAggregator) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) DataTypeAggregator(org.knime.base.data.aggregation.dialogutil.type.DataTypeAggregator) LinkedList(java.util.LinkedList) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 30 with SettingsModelString

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

the class RoundDoubleNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_filterDoubleColModel.validateSettings(settings);
    m_numberPrecisionModel.validateSettings(settings);
    m_appendColumnsModel.validateSettings(settings);
    m_columnSuffixModel.validateSettings(settings);
    m_roundingModeModel.validateSettings(settings);
    try {
        // added in 2.8
        m_outputTypeModel.validateSettings(settings);
    } catch (InvalidSettingsException ise) {
        RoundDoubleNodeDialog.getOutputAsStringModel().validateSettings(settings);
    }
    m_numberModeModel.validateSettings(settings);
    // additional sanity checks
    StringBuffer errMsgBuffer = new StringBuffer();
    boolean err = false;
    // precision number has to be between 0 and inf
    int precision = ((SettingsModelIntegerBounded) m_numberPrecisionModel.createCloneWithValidatedValue(settings)).getIntValue();
    if (precision < MIN_PRECISION || precision > MAX_PRECISION) {
        errMsgBuffer.append("Rounding precision has to be between " + MIN_PRECISION + " and " + MAX_PRECISION + "\n");
        err = true;
    }
    // if rounded values have to be appended, check for valid column suffix
    boolean append = ((SettingsModelBoolean) m_appendColumnsModel.createCloneWithValidatedValue(settings)).getBooleanValue();
    if (append) {
        String suffix = ((SettingsModelString) m_columnSuffixModel.createCloneWithValidatedValue(settings)).getStringValue();
        if (suffix.length() <= 0) {
            errMsgBuffer.append("Column suffix may not be empty if append " + "columns is set!\n");
            err = true;
        }
    }
    // rounding mode string needs to be a valid round mode
    String roundingModeString = ((SettingsModelString) m_roundingModeModel.createCloneWithValidatedValue(settings)).getStringValue();
    try {
        RoundingMode.valueOf(roundingModeString);
    } catch (Exception e) {
        errMsgBuffer.append("Specified round mode is not valid!\n");
        err = true;
    }
    // number mode string needs to be a valid number mode
    String numberModeString = ((SettingsModelString) m_numberModeModel.createCloneWithValidatedValue(settings)).getStringValue();
    try {
        NumberMode.valueByDescription(numberModeString);
    } catch (Exception e) {
        errMsgBuffer.append("Specified number mode is not valid!\n");
        err = true;
    // throw exception when at least one settings is invalid
    } finally {
        if (err) {
            throw new InvalidSettingsException(errMsgBuffer.toString());
        }
    }
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelIntegerBounded(org.knime.core.node.defaultnodesettings.SettingsModelIntegerBounded) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException)

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