Search in sources :

Example 71 with SettingsModelString

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

the class CreateDateTimeNodeModel method createDurationModel.

/**
 * @return the string model, used in both dialog and model.
 */
static SettingsModelString createDurationModel(final SettingsModelString rowNrOptionSelectionModel, final SettingsModelString durationOrEndSelectionModel) {
    final SettingsModelString settingsModelString = new SettingsModelString("duration", null);
    final ChangeListener changeListener = e -> {
        if (durationOrEndSelectionModel.getStringValue() != null && rowNrOptionSelectionModel.getStringValue() != null) {
            settingsModelString.setEnabled(rowNrOptionSelectionModel.getStringValue().equals(RowNrMode.Variable.name()) || (rowNrOptionSelectionModel.getStringValue().equals(RowNrMode.Fixed.name()) && durationOrEndSelectionModel.getStringValue().equals(EndMode.Duration.name())));
        }
    };
    rowNrOptionSelectionModel.addChangeListener(changeListener);
    durationOrEndSelectionModel.addChangeListener(changeListener);
    changeListener.stateChanged(new ChangeEvent(rowNrOptionSelectionModel));
    return settingsModelString;
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO) RowKey(org.knime.core.data.RowKey) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) SettingsModelLongBounded(org.knime.core.node.defaultnodesettings.SettingsModelLongBounded) LocalDateTimeCellFactory(org.knime.core.data.time.localdatetime.LocalDateTimeCellFactory) ExecutionContext(org.knime.core.node.ExecutionContext) ZonedDateTimeCellFactory(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCellFactory) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) Duration(java.time.Duration) LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) DateTimeType(org.knime.time.util.DateTimeType) ChangeListener(javax.swing.event.ChangeListener) DataCell(org.knime.core.data.DataCell) DateTimeException(java.time.DateTimeException) Period(java.time.Period) ChangeEvent(javax.swing.event.ChangeEvent) DurationPeriodFormatUtils(org.knime.time.util.DurationPeriodFormatUtils) DefaultRow(org.knime.core.data.def.DefaultRow) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) LocalDateCellFactory(org.knime.core.data.time.localdate.LocalDateCellFactory) LocalTimeCellFactory(org.knime.core.data.time.localtime.LocalTimeCellFactory) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) IOException(java.io.IOException) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) NodeModel(org.knime.core.node.NodeModel) File(java.io.File) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DateTimeParseException(java.time.format.DateTimeParseException) BufferedDataTable(org.knime.core.node.BufferedDataTable) ChronoUnit(java.time.temporal.ChronoUnit) SettingsModelLong(org.knime.core.node.defaultnodesettings.SettingsModelLong) LocalDate(java.time.LocalDate) SettingsModelDateTime(org.knime.time.util.SettingsModelDateTime) Temporal(java.time.temporal.Temporal) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 72 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString 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;
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO) RowKey(org.knime.core.data.RowKey) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) SettingsModelLongBounded(org.knime.core.node.defaultnodesettings.SettingsModelLongBounded) LocalDateTimeCellFactory(org.knime.core.data.time.localdatetime.LocalDateTimeCellFactory) ExecutionContext(org.knime.core.node.ExecutionContext) ZonedDateTimeCellFactory(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCellFactory) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) Duration(java.time.Duration) LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) DateTimeType(org.knime.time.util.DateTimeType) ChangeListener(javax.swing.event.ChangeListener) DataCell(org.knime.core.data.DataCell) DateTimeException(java.time.DateTimeException) Period(java.time.Period) ChangeEvent(javax.swing.event.ChangeEvent) DurationPeriodFormatUtils(org.knime.time.util.DurationPeriodFormatUtils) DefaultRow(org.knime.core.data.def.DefaultRow) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) LocalDateCellFactory(org.knime.core.data.time.localdate.LocalDateCellFactory) LocalTimeCellFactory(org.knime.core.data.time.localtime.LocalTimeCellFactory) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) IOException(java.io.IOException) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) NodeModel(org.knime.core.node.NodeModel) File(java.io.File) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DateTimeParseException(java.time.format.DateTimeParseException) BufferedDataTable(org.knime.core.node.BufferedDataTable) ChronoUnit(java.time.temporal.ChronoUnit) SettingsModelLong(org.knime.core.node.defaultnodesettings.SettingsModelLong) LocalDate(java.time.LocalDate) SettingsModelDateTime(org.knime.time.util.SettingsModelDateTime) Temporal(java.time.temporal.Temporal) ChangeEvent(javax.swing.event.ChangeEvent) SettingsModelDateTime(org.knime.time.util.SettingsModelDateTime) ChangeListener(javax.swing.event.ChangeListener)

Example 73 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString 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;
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO) RowKey(org.knime.core.data.RowKey) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) ZonedDateTime(java.time.ZonedDateTime) LocalDateTime(java.time.LocalDateTime) SettingsModelLongBounded(org.knime.core.node.defaultnodesettings.SettingsModelLongBounded) LocalDateTimeCellFactory(org.knime.core.data.time.localdatetime.LocalDateTimeCellFactory) ExecutionContext(org.knime.core.node.ExecutionContext) ZonedDateTimeCellFactory(org.knime.core.data.time.zoneddatetime.ZonedDateTimeCellFactory) DataColumnSpecCreator(org.knime.core.data.DataColumnSpecCreator) Duration(java.time.Duration) LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) DateTimeType(org.knime.time.util.DateTimeType) ChangeListener(javax.swing.event.ChangeListener) DataCell(org.knime.core.data.DataCell) DateTimeException(java.time.DateTimeException) Period(java.time.Period) ChangeEvent(javax.swing.event.ChangeEvent) DurationPeriodFormatUtils(org.knime.time.util.DurationPeriodFormatUtils) DefaultRow(org.knime.core.data.def.DefaultRow) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) LocalDateCellFactory(org.knime.core.data.time.localdate.LocalDateCellFactory) LocalTimeCellFactory(org.knime.core.data.time.localtime.LocalTimeCellFactory) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) IOException(java.io.IOException) BufferedDataContainer(org.knime.core.node.BufferedDataContainer) NodeModel(org.knime.core.node.NodeModel) File(java.io.File) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DateTimeParseException(java.time.format.DateTimeParseException) BufferedDataTable(org.knime.core.node.BufferedDataTable) ChronoUnit(java.time.temporal.ChronoUnit) SettingsModelLong(org.knime.core.node.defaultnodesettings.SettingsModelLong) LocalDate(java.time.LocalDate) SettingsModelDateTime(org.knime.time.util.SettingsModelDateTime) Temporal(java.time.temporal.Temporal) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 74 with SettingsModelString

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

the class ModifyDateNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    m_spec = specs[0];
    m_dialogCompReplaceOrAppend.loadSettingsFrom(settings, specs);
    m_dialogCompSuffix.loadSettingsFrom(settings, specs);
    m_dialogCompDate.loadSettingsFrom(settings, specs);
    m_dialogCompTimeZone.loadSettingsFrom(settings, specs);
    m_dialogCompModifySelect.loadSettingsFrom(settings, specs);
    m_filterOnlyLocalDate = ((SettingsModelString) m_dialogCompModifySelect.getModel()).getStringValue().equals(ModifyDateNodeModel.MODIFY_OPTION_APPEND);
    final DataColumnSpecFilterConfiguration filterConfiguration = ModifyDateNodeModel.createDCFilterConfiguration(m_filterOnlyLocalDate ? ModifyDateNodeModel.LOCAL_TIME_FILTER : ModifyDateNodeModel.DATE_TIME_FILTER);
    filterConfiguration.loadConfigurationInDialog(settings, specs[0]);
    m_dialogCompColFilter.loadConfiguration(filterConfiguration, specs[0]);
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 75 with SettingsModelString

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

the class OldToNewTimeNodeModel method createTimeZoneSelectModel.

/**
 * @param typeModelBool
 * @return the string select model, used in both dialog and model.
 */
static SettingsModelString createTimeZoneSelectModel() {
    final SettingsModelString zoneSelectModel = new SettingsModelString("time_zone_select", ZoneId.systemDefault().getId());
    zoneSelectModel.setEnabled(false);
    return zoneSelectModel;
}
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