Search in sources :

Example 11 with SettingsModelBoolean

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

the class CreateBitVectorNodeModel method createMSCHasWildcardsModel.

/**
 *@return the multi string column has wild card model
 */
static SettingsModelBoolean createMSCHasWildcardsModel() {
    final SettingsModelBoolean m = new SettingsModelBoolean("multiStringColumnHasWildcards", false);
    m.setEnabled(false);
    return m;
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean)

Example 12 with SettingsModelBoolean

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

the class CreateBitVectorNodeModel method createMSCRegexModel.

/**
 *@return the multi string column is regex model
 */
static SettingsModelBoolean createMSCRegexModel() {
    final SettingsModelBoolean m = new SettingsModelBoolean("multiStringColumnIsRegex", false);
    m.setEnabled(false);
    return m;
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean)

Example 13 with SettingsModelBoolean

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

the class CreateBitVectorNodeModel method createMSCCaseSensitiveModel.

/**
 *@return the multi string column case sensitive model
 */
static SettingsModelBoolean createMSCCaseSensitiveModel() {
    final SettingsModelBoolean m = new SettingsModelBoolean("multiStringColumnCaseSensitive", false);
    m.setEnabled(false);
    return m;
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean)

Example 14 with SettingsModelBoolean

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

the class AbstractHistogramNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    final SettingsModelBoolean model = m_allRows.createCloneWithValidatedValue(settings);
    if (!model.getBooleanValue()) {
        // read the spinner value only if the user hasn't selected to
        // retrieve all values
        m_noOfRows.validateSettings(settings);
        final SettingsModelInteger copy = m_noOfRows.createCloneWithValidatedValue(settings);
        if (copy.getIntValue() <= 0) {
            throw new InvalidSettingsException("No of rows must be greater zero");
        }
    }
    try {
        m_xColName.validateSettings(settings);
    } catch (final Throwable e) {
        // It's an older node which hasn't stored the aggregation column
        final String xCol = settings.getString("xColumn");
        if (xCol == null || xCol.length() < 1) {
            throw new InvalidSettingsException("Invalid binning column");
        }
    }
    try {
        m_aggrColName.validateSettings(settings);
    } catch (final Throwable e) {
        // It's an older node which hasn't stored the aggregation column
        LOGGER.debug("Exception while validating settings: " + e.getMessage());
    }
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) SettingsModelInteger(org.knime.core.node.defaultnodesettings.SettingsModelInteger) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 15 with SettingsModelBoolean

use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean 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

SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)36 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)15 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)13 ChangeEvent (javax.swing.event.ChangeEvent)5 ChangeListener (javax.swing.event.ChangeListener)5 IOException (java.io.IOException)4 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)4 DialogComponentBoolean (org.knime.core.node.defaultnodesettings.DialogComponentBoolean)4 DialogComponentString (org.knime.core.node.defaultnodesettings.DialogComponentString)4 File (java.io.File)3 DataTableSpec (org.knime.core.data.DataTableSpec)3 RowKey (org.knime.core.data.RowKey)3 BufferedDataTable (org.knime.core.node.BufferedDataTable)3 ExecutionContext (org.knime.core.node.ExecutionContext)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3 NodeModel (org.knime.core.node.NodeModel)3 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)3 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)3 DateTimeException (java.time.DateTimeException)2 Duration (java.time.Duration)2