Search in sources :

Example 76 with SettingsModelString

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!");
        }
    }
}
Also used : SettingsModelDateTime(org.knime.time.util.SettingsModelDateTime) DataType(org.knime.core.data.DataType) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 77 with SettingsModelString

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);
    }
}
Also used : LocalTimeValue(org.knime.core.data.time.localtime.LocalTimeValue) TemporalAmount(java.time.temporal.TemporalAmount) JComponent(javax.swing.JComponent) Period(java.time.Period) Duration(java.time.Duration) DialogComponentString(org.knime.core.node.defaultnodesettings.DialogComponentString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) LocalDateValue(org.knime.core.data.time.localdate.LocalDateValue)

Example 78 with SettingsModelString

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;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 79 with SettingsModelString

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;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 80 with SettingsModelString

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;
}
Also used : 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