Search in sources :

Example 61 with SettingsModelString

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

the class CrossJoinerNodeModel method createSecondRowIdsNameSettingsModel.

/**
 * @param showSecondRowIdsSettingsModel the enable checker model.
 * @return the column name for the second tables rowids
 */
static SettingsModelString createSecondRowIdsNameSettingsModel(final SettingsModelBoolean showSecondRowIdsSettingsModel) {
    final SettingsModelString settingsModel = new SettingsModelString("CFG_SECOND_COLUMNNAME", "SecondRowIDs");
    showSecondRowIdsSettingsModel.addChangeListener(new ChangeListener() {

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

Example 62 with SettingsModelString

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

the class CellSplitterByPosNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    SettingsModelString tmpSplits = m_splitPoints.createCloneWithValidatedValue(settings);
    SettingsModelString tmpColNames = m_newColNames.createCloneWithValidatedValue(settings);
    // null or empty string is invalid for split points or colNames
    if ((tmpSplits.getStringValue() == null) || tmpSplits.getStringValue().equals("")) {
        throw new InvalidSettingsException("Please specify split points");
    }
    if ((tmpColNames.getStringValue() == null) || tmpColNames.getStringValue().equals("")) {
        throw new InvalidSettingsException("Please specify new column names");
    }
    int[] points = convertSplitPointsToInts(tmpSplits.getStringValue());
    String[] colNames = convertNewColumnNames(tmpColNames.getStringValue(), null);
    // make sure enough (and not too many) col names are specified
    if (points.length + 1 != colNames.length) {
        throw new InvalidSettingsException("Number of new column names is not as " + "required for the specified splits " + "(no. of new columns: " + (points.length + 1) + ")");
    }
    m_splitPoints.validateSettings(settings);
    m_newColNames.validateSettings(settings);
    m_selColumn.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 63 with SettingsModelString

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

the class ColumnComparatorNodeDialogPane method createMatchValue.

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

Example 64 with SettingsModelString

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

the class ColumnComparatorNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    SettingsModelString first = m_firstColumn.createCloneWithValidatedValue(settings);
    SettingsModelString second = m_secondColumn.createCloneWithValidatedValue(settings);
    if (first.getStringValue() == null || second.getStringValue() == null) {
        throw new InvalidSettingsException("No column is selected for comparison.");
    }
    if (first.getStringValue().equals(second.getStringValue())) {
        throw new InvalidSettingsException("Left and right column are the same: " + first.getStringValue());
    }
    SettingsModelString matchOption = m_matchOption.createCloneWithValidatedValue(settings);
    SettingsModelString mismatchOption = m_mismatchOption.createCloneWithValidatedValue(settings);
    if (!matchOption.getStringValue().equals(REPL_OPTIONS[3]) && !mismatchOption.getStringValue().equals(REPL_OPTIONS[3])) {
        if (matchOption.getStringValue().equals(mismatchOption.getStringValue())) {
            throw new InvalidSettingsException("Replacement options are the same for true/false!");
        }
    }
    m_firstColumn.validateSettings(settings);
    m_secondColumn.validateSettings(settings);
    m_matchOption.validateSettings(settings);
    m_mismatchOption.validateSettings(settings);
    m_operator.validateSettings(settings);
    m_matchValue.validateSettings(settings);
    m_mismatchValue.validateSettings(settings);
    m_newColumn.validateSettings(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 65 with SettingsModelString

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

the class ColumnHeaderExtractorNodeModel method createUnifyHeaderPrefix.

/**
 * @param replaceColHeader column header model (enable/disable listener)
 * @return new settings model for prefix of new header
 */
static SettingsModelString createUnifyHeaderPrefix(final SettingsModelBoolean replaceColHeader) {
    final SettingsModelString result = new SettingsModelString("unifyHeaderPrefix", "Column ");
    replaceColHeader.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent chEvent) {
            result.setEnabled(replaceColHeader.getBooleanValue());
        }
    });
    return result;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) 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