use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class AbstractFieldExtractorNodeDialog method createUIComponentWithFormatSelection.
/**
* Creates the necessary {@link SettingsModel}s, adds the listener to the
* checkbox and creates the UI component with a horizontally oriented group
* containing the checkbox and text field for the new column name.
* Then closes the group.
*
* @param timeField name of the time field for which a checkbox,
* a text field and a format selection (int or string) should be created
*/
protected void createUIComponentWithFormatSelection(final String timeField) {
// create the settings models and add listener
SettingsModelBoolean checkBoxModel = createUseTimeFieldModel(timeField);
SettingsModelString colNameModel = createTimeFieldColumnNameModel(timeField);
SettingsModelString formatModel = createRepresentationModelFor(timeField);
addListener(checkBoxModel, colNameModel);
addListener(checkBoxModel, formatModel);
createNewGroup("");
setHorizontalPlacement(true);
addDialogComponent(new DialogComponentBoolean(checkBoxModel, timeField));
// add radio buttons for string or int representation
addDialogComponent(new DialogComponentButtonGroup(formatModel, true, "Value as", AS_STRING, AS_INT));
addDialogComponent(new DialogComponentString(colNameModel, "Column name:", true, 20));
closeCurrentGroup();
setHorizontalPlacement(false);
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class AbstractFieldExtractorNodeDialog method validateColumnName.
// general helper methods
/**
* @param settings settings to read from
* @param enabledModel the check box model in order to validate only active
* column name models
* @param colNameModel the column name model for which the value should be
* validated
* @return true if the name is enabled and valid, false if the name is not
* enabled
* @throws InvalidSettingsException if the string value of the column model
* is either <code>null</code> or empty
*/
public static boolean validateColumnName(final NodeSettingsRO settings, final SettingsModelBoolean enabledModel, final SettingsModelString colNameModel) throws InvalidSettingsException {
SettingsModelBoolean isEnabled = enabledModel.createCloneWithValidatedValue(settings);
if (!isEnabled.getBooleanValue()) {
return false;
}
SettingsModelString colNameClone = colNameModel.createCloneWithValidatedValue(settings);
String colName = colNameClone.getStringValue();
if (colName == null || colName.isEmpty()) {
throw new InvalidSettingsException("A column name must not be empty!");
}
return true;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class DateGeneratorNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_from.validateSettings(settings);
m_to.validateSettings(settings);
m_noOfRows.validateSettings(settings);
// we only validate the true date if we do not use the execution time
boolean checkFrom = true;
try {
SettingsModelBoolean useEx = m_useExecution.createCloneWithValidatedValue(settings);
if (useEx.getBooleanValue()) {
checkFrom = false;
}
} catch (Exception e) {
// Do nothing, backward compatibility
}
if (checkFrom) {
SettingsModelCalendar from = m_from.createCloneWithValidatedValue(settings);
validateDates(from);
}
SettingsModelCalendar to = m_to.createCloneWithValidatedValue(settings);
validateDates(to);
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class MovingAggregationNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_winLength.validateSettings(settings);
m_windowType.validateSettings(settings);
m_cumulativeComputing.validateSettings(settings);
m_handleMissings.validateSettings(settings);
m_removeRetainedCols.validateSettings(settings);
m_maxUniqueVals.validateSettings(settings);
m_valueDelimiter.validateSettings(settings);
final List<ColumnAggregator> aggregators = ColumnAggregator.loadColumnAggregators(settings);
final List<DataTypeAggregator> typeAggregators = new LinkedList<>();
final List<PatternAggregator> regexAggregators = new LinkedList<>();
try {
regexAggregators.addAll(PatternAggregator.loadAggregators(settings, CFG_PATTERN_AGGREGATORS));
typeAggregators.addAll(DataTypeAggregator.loadAggregators(settings, CFG_DATA_TYPE_AGGREGATORS));
} catch (InvalidSettingsException e) {
// introduced in 2.11
}
if (aggregators.isEmpty() && regexAggregators.isEmpty() && typeAggregators.isEmpty()) {
throw new IllegalArgumentException("Please select at least one aggregation option");
}
final String policyLabel = ((SettingsModelString) m_columnNamePolicy.createCloneWithValidatedValue(settings)).getStringValue();
final ColumnNamePolicy namePolicy = ColumnNamePolicy.getPolicy4Label(policyLabel);
try {
GroupByNodeModel.checkDuplicateAggregators(namePolicy, aggregators);
} catch (IllegalArgumentException e) {
throw new InvalidSettingsException(e.getMessage());
}
final boolean removeAggrCols = ((SettingsModelBoolean) m_removeAggregationCols.createCloneWithValidatedValue(settings)).getBooleanValue();
if (ColumnNamePolicy.KEEP_ORIGINAL_NAME.equals(namePolicy) && !removeAggrCols) {
throw new InvalidSettingsException("'" + ColumnNamePolicy.KEEP_ORIGINAL_NAME.getLabel() + "' option only valid if aggregation columns are filtered");
}
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class FromDecisionTreeNodeDialog method createScoreDistribution.
/**
* {@inheritDoc}
*/
@Override
protected void createScoreDistribution(final FromDecisionTreeSettings settings) {
createNewGroup("Score distribution");
setHorizontalPlacement(true);
// Record count
m_scorePmmlRecordCount = settings.getScorePmmlRecordCount();
final SettingsModelBoolean scoreTableRecordCount = settings.getScoreTableRecordCount();
final SettingsModelString scoreTableRecordCountPrefix = settings.getScoreTableRecordCountPrefix();
addDialogComponent(new DialogComponentBoolean(m_scorePmmlRecordCount, "Provide score distibution record count in PMML"));
addDialogComponent(new DialogComponentBoolean(scoreTableRecordCount, "Provide score distibution record count in table with column name prefix:"));
addDialogComponent(new DialogComponentString(scoreTableRecordCountPrefix, ""));
setHorizontalPlacement(false);
setHorizontalPlacement(true);
// Probability
final SettingsModelBoolean scorePmmlProbability = settings.getScorePmmlProbability();
final SettingsModelBoolean scoreTableProbability = settings.getScoreTableProbability();
final SettingsModelString scoreTableProbabilityPrefix = settings.getScoreTableProbabilityPrefix();
addDialogComponent(new DialogComponentBoolean(scorePmmlProbability, "Provide score distibution probability in PMML"));
addDialogComponent(new DialogComponentBoolean(scoreTableProbability, "Provide score distibution probability in table with column name prefix:"));
addDialogComponent(new DialogComponentString(scoreTableProbabilityPrefix, ""));
m_scorePmmlRecordCount.addChangeListener(c -> scoreTableRecordCount.setEnabled(m_scorePmmlRecordCount.getBooleanValue()));
m_scorePmmlRecordCount.addChangeListener(c -> scorePmmlProbability.setEnabled(m_scorePmmlRecordCount.getBooleanValue()));
scoreTableRecordCount.addChangeListener(c -> scoreTableRecordCountPrefix.setEnabled(scoreTableRecordCount.isEnabled() && scoreTableRecordCount.getBooleanValue()));
scorePmmlProbability.addChangeListener(c -> scoreTableProbability.setEnabled(scorePmmlProbability.isEnabled() && scorePmmlProbability.getBooleanValue()));
scoreTableProbability.addChangeListener(c -> scoreTableProbabilityPrefix.setEnabled(scoreTableProbability.isEnabled() && scoreTableProbability.getBooleanValue()));
}
Aggregations