use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class DateShiftConfigure method createNumColmodel.
/**
* @return settings model for the first time column
*/
public static SettingsModelString createNumColmodel() {
SettingsModelString sms = new SettingsModelString(CFG_COL1, null);
sms.setEnabled(false);
return sms;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString 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.SettingsModelString 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.SettingsModelString in project knime-core by knime.
the class DateFieldExtractorNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_selectedColumn.validateSettings(settings);
m_monthRepresentation.validateSettings(settings);
SettingsModelString monthRepModel = m_monthRepresentation.createCloneWithValidatedValue(settings);
String monthRep = monthRepModel.getStringValue();
if (!monthRep.equals(AbstractFieldExtractorNodeDialog.AS_INT) && !monthRep.equals(AbstractFieldExtractorNodeDialog.AS_STRING)) {
throw new InvalidSettingsException("Month representation must be one of " + AbstractFieldExtractorNodeDialog.AS_INT + ", " + AbstractFieldExtractorNodeDialog.AS_STRING);
}
// year
m_useYear.validateSettings(settings);
m_yearColName.validateSettings(settings);
// quarter
m_useQuarter.validateSettings(settings);
m_quarterColName.validateSettings(settings);
// month
m_useMonth.validateSettings(settings);
m_monthColName.validateSettings(settings);
// day of week
m_useDayOfWeek.validateSettings(settings);
m_dayOfWeekColName.validateSettings(settings);
m_dayOfWeekRepresentationModel.validateSettings(settings);
// day of month
m_useDay.validateSettings(settings);
m_dayColName.validateSettings(settings);
boolean atLeastOneChecked = false;
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useYear, m_yearColName);
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useQuarter, m_quarterColName);
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useMonth, m_monthColName);
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useDay, m_dayColName);
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useDayOfWeek, m_dayOfWeekColName);
try {
// day of year
m_useDayOfYear.validateSettings(settings);
m_dayOfYearColName.validateSettings(settings);
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useDayOfYear, m_dayOfYearColName);
} catch (InvalidSettingsException ise) {
// nothing to do
}
// new since 2.9.1
try {
// week of year
m_useWeekOfYear.validateSettings(settings);
m_weekOfYearColName.validateSettings(settings);
atLeastOneChecked |= AbstractFieldExtractorNodeDialog.validateColumnName(settings, m_useWeekOfYear, m_weekOfYearColName);
} catch (InvalidSettingsException ise) {
// nothing to do
}
// all unchecked?
if (!atLeastOneChecked) {
setWarningMessage("No time field selected. Output table will be same as input table!");
}
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class MaskTimeNodeModel method createNewColumnNameModel.
/**
* @return settings model to store the mask selection
*/
static SettingsModelString createNewColumnNameModel() {
SettingsModelString sm = new SettingsModelString(CFG_NEW_COL_NAME, "MaskedTime");
sm.setEnabled(false);
return sm;
}
Aggregations