Search in sources :

Example 11 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class DateTimeToStringNodeModel method createSuffixModel.

/**
 * @param replaceOrAppendModel model for the replace/append button group
 * @return the string model, used in both dialog and model.
 */
public static SettingsModelString createSuffixModel(final SettingsModelString replaceOrAppendModel) {
    final SettingsModelString suffixModel = new SettingsModelString("suffix", "(String)");
    replaceOrAppendModel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(final ChangeEvent e) {
            if (replaceOrAppendModel.getStringValue().equals(OPTION_APPEND)) {
                suffixModel.setEnabled(true);
            } else {
                suffixModel.setEnabled(false);
            }
        }
    });
    suffixModel.setEnabled(false);
    return suffixModel;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 12 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class TimestampToDateTimeNodeModel method createSuffixModel.

/**
 * @param replaceOrAppendModel model for the replace/append button group
 * @return the string model, used in both dialog and model.
 */
public static SettingsModelString createSuffixModel(final SettingsModelString replaceOrAppendModel) {
    final SettingsModelString suffixModel = new SettingsModelString("suffix", "(Date&Time)");
    replaceOrAppendModel.addChangeListener(e -> suffixModel.setEnabled(replaceOrAppendModel.getStringValue().equals(OPTION_APPEND)));
    suffixModel.setEnabled(false);
    return suffixModel;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 13 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class ExtractDateTimeFieldsNodeModel method createSubsecondUnitsModel.

static SettingsModelString createSubsecondUnitsModel(final SettingsModelBoolean subsecondsModelBoolean) {
    final SettingsModelString subsecondsModelString = new SettingsModelString("subsecond_units", MILLISECOND);
    subsecondsModelString.setEnabled(subsecondsModelBoolean.getBooleanValue());
    return subsecondsModelString;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 14 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class DateTimeBasedRowFilterNodeDialog method checkPeriodOrDuration.

/**
 * Checks if period or duration can be parsed
 */
private void checkPeriodOrDuration() {
    String warning = "";
    try {
        DurationPeriodFormatUtils.parsePeriod(((SettingsModelString) m_dialogCompPeriodOrDurationValue.getModel()).getStringValue());
        if (m_dialogCompColSelection.getSelectedAsSpec().getType().isCompatible(LocalTimeValue.class)) {
            warning = "A date-based duration cannot be applied on a time!";
        }
    } catch (DateTimeParseException e) {
        try {
            DurationPeriodFormatUtils.parseDuration(((SettingsModelString) m_dialogCompPeriodOrDurationValue.getModel()).getStringValue());
            if (m_dialogCompColSelection.getSelectedAsSpec().getType().isCompatible(LocalDateValue.class)) {
                warning = "A time-based duration cannot be applied on a date!";
            }
        } catch (DateTimeParseException e2) {
            warning = "Value does not represent a duration!";
        }
    }
    if (!warning.equals("")) {
        ((JComponent) m_dialogCompPeriodOrDurationValue.getComponentPanel().getComponent(1)).setBorder(BorderFactory.createLineBorder(Color.RED));
        m_typeWarningLabel.setText(warning);
    } else {
        ((JComponent) m_dialogCompPeriodOrDurationValue.getComponentPanel().getComponent(1)).setBorder(UIManager.getBorder("TextField.border"));
    }
}
Also used : DateTimeParseException(java.time.format.DateTimeParseException) JComponent(javax.swing.JComponent) 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 15 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class DateTimeShiftNodeModel method createSuffixModel.

/**
 * @param replaceOrAppendModel model for the replace/append button group
 * @return the string model, used in both dialog and model.
 */
public static SettingsModelString createSuffixModel(final SettingsModelString replaceOrAppendModel) {
    final SettingsModelString suffixModel = new SettingsModelString("suffix", "(shifted)");
    replaceOrAppendModel.addChangeListener(e -> suffixModel.setEnabled(replaceOrAppendModel.getStringValue().equals(OPTION_APPEND)));
    suffixModel.setEnabled(false);
    return suffixModel;
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)99 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)39 SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)15 ChangeListener (javax.swing.event.ChangeListener)13 ChangeEvent (javax.swing.event.ChangeEvent)12 IOException (java.io.IOException)8 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)8 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 File (java.io.File)4 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 DateTimeException (java.time.DateTimeException)3