use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class CreateDateTimeNodeModel method createEndModel.
/**
* @return the date&time model, used in both dialog and model.
*/
static SettingsModelDateTime createEndModel(final SettingsModelString rowNrOptionSelectionModel, final SettingsModelString durationOrEndSelectionModel, final SettingsModelBoolean useExecTimeModel) {
final SettingsModelDateTime settingsModelDateTime = new SettingsModelDateTime("end", LocalDateTime.now().withNano(0));
final ChangeListener changeListener = e -> {
if (durationOrEndSelectionModel.getStringValue() != null && rowNrOptionSelectionModel.getStringValue() != null) {
settingsModelDateTime.setEnabled((rowNrOptionSelectionModel.getStringValue().equals(RowNrMode.Variable.name()) || (rowNrOptionSelectionModel.getStringValue().equals(RowNrMode.Fixed.name()) && durationOrEndSelectionModel.getStringValue().equals(EndMode.End.name()))) && !useExecTimeModel.getBooleanValue());
}
};
rowNrOptionSelectionModel.addChangeListener(changeListener);
durationOrEndSelectionModel.addChangeListener(changeListener);
useExecTimeModel.addChangeListener(changeListener);
changeListener.stateChanged(new ChangeEvent(rowNrOptionSelectionModel));
return settingsModelDateTime;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class CreateDateTimeNodeModel method createEndUseExecTimeModel.
/**
* @return the boolean model, used in both dialog and model.
*/
static SettingsModelBoolean createEndUseExecTimeModel(final SettingsModelString rowNrOptionSelectionModel, final SettingsModelString durationOrEndSelectionModel) {
SettingsModelBoolean settingsModelBoolean = new SettingsModelBoolean("end_use_exec_time", false);
final ChangeListener changeListener = e -> {
if (durationOrEndSelectionModel.getStringValue() != null && rowNrOptionSelectionModel.getStringValue() != null) {
settingsModelBoolean.setEnabled(rowNrOptionSelectionModel.getStringValue().equals(RowNrMode.Variable.name()) || (rowNrOptionSelectionModel.getStringValue().equals(RowNrMode.Fixed.name()) && durationOrEndSelectionModel.getStringValue().equals(EndMode.End.name())));
}
};
rowNrOptionSelectionModel.addChangeListener(changeListener);
durationOrEndSelectionModel.addChangeListener(changeListener);
changeListener.stateChanged(new ChangeEvent(rowNrOptionSelectionModel));
return settingsModelBoolean;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class ExtractDurationPeriodFieldsNodeModel method createColumnRearranger.
/**
* {@inheritDoc}
*/
@Override
protected ColumnRearranger createColumnRearranger(final DataTableSpec spec) throws InvalidSettingsException {
final ColumnRearranger rearranger = new ColumnRearranger(spec);
if (m_colSelectModel.getStringValue() == null) {
throw new InvalidSettingsException("Node must be configured!");
}
if (spec.findColumnIndex(m_colSelectModel.getStringValue()) < 0) {
throw new InvalidSettingsException("Column '" + m_colSelectModel.getStringValue() + "' not found in the input table.");
}
final boolean isDurationColumn = spec.getColumnSpec(m_colSelectModel.getStringValue()).getType().isCompatible(DurationValue.class);
final List<DataColumnSpec> colSpecs = new ArrayList<>();
if (isDurationColumn) {
for (final SettingsModelBoolean model : m_durModels) {
if (model.getBooleanValue()) {
if (model.equals(m_hourModel)) {
colSpecs.add(new UniqueNameGenerator(spec).newColumn(model.getConfigName(), LongCell.TYPE));
} else {
colSpecs.add(new UniqueNameGenerator(spec).newColumn(model.getConfigName(), IntCell.TYPE));
}
}
}
if (m_subSecondModel.getBooleanValue()) {
colSpecs.add(new UniqueNameGenerator(spec).newColumn(m_subSecondUnitsModel.getStringValue(), IntCell.TYPE));
}
} else {
for (final SettingsModelBoolean model : m_perModels) {
if (model.getBooleanValue()) {
colSpecs.add(new UniqueNameGenerator(spec).newColumn(model.getConfigName(), LongCell.TYPE));
}
}
}
final DataColumnSpec[] colSpecsArray = new DataColumnSpec[colSpecs.size()];
colSpecs.toArray(colSpecsArray);
final CellFactory cellFac;
if (isDurationColumn) {
cellFac = new ExtractDurationFieldsCellFactory(spec.findColumnIndex(m_colSelectModel.getStringValue()), colSpecsArray);
} else {
cellFac = new ExtractPeriodFieldsCellFactory(spec.findColumnIndex(m_colSelectModel.getStringValue()), colSpecsArray);
}
rearranger.append(cellFac);
return rearranger;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class ExtractDateTimeFieldsNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_colSelectModel.validateSettings(settings);
for (final SettingsModelBoolean sm : m_dateModels) {
sm.validateSettings(settings);
}
for (final SettingsModelBoolean sm : m_timeModels) {
sm.validateSettings(settings);
}
m_subsecondUnitsModel.validateSettings(settings);
for (final SettingsModelBoolean sm : m_timeZoneModels) {
sm.validateSettings(settings);
}
m_localeModel.validateSettings(settings);
}
use of org.knime.core.node.defaultnodesettings.SettingsModelBoolean in project knime-core by knime.
the class ExtractDateTimeFieldsNodeModel method loadValidatedSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_colSelectModel.loadSettingsFrom(settings);
for (final SettingsModelBoolean sm : m_dateModels) {
sm.loadSettingsFrom(settings);
}
for (final SettingsModelBoolean sm : m_timeModels) {
sm.loadSettingsFrom(settings);
}
m_subsecondUnitsModel.loadSettingsFrom(settings);
for (final SettingsModelBoolean sm : m_timeZoneModels) {
sm.loadSettingsFrom(settings);
}
m_localeModel.loadSettingsFrom(settings);
}
Aggregations