use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class DateTimeBasedRowFilterNodeDialog method checkStartAndEnd.
/**
* Checks if start and end string can be parsed with the set format and locale
*/
private void checkStartAndEnd() {
if (m_dialogCompStartDateTime.getModel().isEnabled() && m_dialogCompEndDateTime.getModel().isEnabled() && ((SettingsModelString) m_dialogCompEndSelection.getModel()).getStringValue().equals(EndMode.DateTime.name())) {
boolean isStartAfterEnd = false;
final DataType dataType = m_dialogCompColSelection.getSelectedAsSpec().getType();
if (dataType.isCompatible(LocalDateValue.class)) {
isStartAfterEnd = ((SettingsModelDateTime) m_dialogCompStartDateTime.getModel()).getLocalDate().isAfter(((SettingsModelDateTime) m_dialogCompEndDateTime.getModel()).getLocalDate());
}
if (dataType.isCompatible(LocalTimeValue.class)) {
isStartAfterEnd = ((SettingsModelDateTime) m_dialogCompStartDateTime.getModel()).getLocalTime().isAfter(((SettingsModelDateTime) m_dialogCompEndDateTime.getModel()).getLocalTime());
}
if (dataType.isCompatible(LocalDateTimeValue.class)) {
isStartAfterEnd = ((SettingsModelDateTime) m_dialogCompStartDateTime.getModel()).getLocalDateTime().isAfter(((SettingsModelDateTime) m_dialogCompEndDateTime.getModel()).getLocalDateTime());
}
if (dataType.isCompatible(ZonedDateTimeValue.class)) {
isStartAfterEnd = ((SettingsModelDateTime) m_dialogCompStartDateTime.getModel()).getZonedDateTime().isAfter(((SettingsModelDateTime) m_dialogCompEndDateTime.getModel()).getZonedDateTime());
}
if (isStartAfterEnd) {
m_typeWarningLabel.setText("End date must not be before start date!");
}
}
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class DateTimeBasedRowFilterNodeDialog method checkGranularity.
/**
* Checks if granularity can be applied on column
*/
private void checkGranularity() {
String warning = "";
final TemporalAmount periodOrDuration = Granularity.fromString(((SettingsModelString) m_dialogCompNumericalGranularity.getModel()).getStringValue()).getPeriodOrDuration(1);
if (periodOrDuration instanceof Period && m_dialogCompColSelection.getSelectedAsSpec().getType().isCompatible(LocalTimeValue.class)) {
warning = ((SettingsModelString) m_dialogCompNumericalGranularity.getModel()).getStringValue() + " cannot be applied on a time!";
}
if (periodOrDuration instanceof Duration && m_dialogCompColSelection.getSelectedAsSpec().getType().isCompatible(LocalDateValue.class)) {
warning = ((SettingsModelString) m_dialogCompNumericalGranularity.getModel()).getStringValue() + " cannot be applied on a date!";
}
if (!warning.equals("")) {
((JComponent) m_dialogCompNumericalGranularity.getComponentPanel().getComponent(1)).setBorder(BorderFactory.createLineBorder(Color.RED));
m_typeWarningLabel.setText(warning);
} else {
((JComponent) m_dialogCompNumericalGranularity.getComponentPanel().getComponent(1)).setBorder(null);
}
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class DateTimeShiftNodeModel method createNumericalColSelectModel.
/**
* @param numericalSelectionModel model for the numerical selection button group
* @return the string model, used in both dialog and model.
*/
public static SettingsModelString createNumericalColSelectModel(final SettingsModelString numericalSelectionModel) {
final SettingsModelString model = new SettingsModelString("numerical_col_select", "");
numericalSelectionModel.addChangeListener(l -> model.setEnabled(numericalSelectionModel.getStringValue().equals(NumericalMode.Column.name()) && numericalSelectionModel.isEnabled()));
model.setEnabled(false);
return model;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class DateTimeShiftNodeModel method createPeriodColSelectModel.
/**
* @param periodSelectionModel model for the period selection button group
* @return the string model, used in both dialog and model.
*/
public static SettingsModelString createPeriodColSelectModel(final SettingsModelString periodSelectionModel) {
final SettingsModelString model = new SettingsModelString("period_col_select", "");
periodSelectionModel.addChangeListener(l -> model.setEnabled(periodSelectionModel.getStringValue().equals(DurationMode.Column.name()) && periodSelectionModel.isEnabled()));
return model;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class DateTimeShiftNodeModel method createNumericalGranularityModel.
/**
* @return the string model, used in both dialog and model.
*/
public static SettingsModelString createNumericalGranularityModel() {
final SettingsModelString model = new SettingsModelString("numerical_granularity", "");
model.setEnabled(false);
return model;
}
Aggregations