Search in sources :

Example 46 with SettingsModelString

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

the class SleepNodeDialog method waitForFile.

private void waitForFile() {
    m_events = new DialogComponentButtonGroup(new SettingsModelString(SleepNodeModel.CFGKEY_FILESTATUS, "Modification"), false, null, "Creation", "Modification", "Deletion");
    FlowVariableModel fvm = createFlowVariableModel(SleepNodeModel.CFGKEY_FILEPATH, Type.STRING);
    m_fileChooser = new FilesHistoryPanel(fvm, SleepNodeModel.CFGKEY_FILEPATH, LocationValidation.None);
    m_fileRB = new JRadioButton("Wait for file.. ");
    m_fileRB.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(final ItemEvent e) {
            if (m_fileRB.isSelected()) {
                m_selection = 2;
            }
            m_fileChooser.setEnabled(m_fileRB.isSelected());
            m_events.getModel().setEnabled(m_fileRB.isSelected());
        }
    });
}
Also used : FlowVariableModel(org.knime.core.node.FlowVariableModel) DialogComponentButtonGroup(org.knime.core.node.defaultnodesettings.DialogComponentButtonGroup) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) FilesHistoryPanel(org.knime.core.node.util.FilesHistoryPanel) ItemListener(java.awt.event.ItemListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 47 with SettingsModelString

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

the class SleepNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    int selection = settings.getInt(CFGKEY_WAITOPTION);
    if (!(0 <= selection && selection <= 2)) {
        throw new InvalidSettingsException("Selected wait option is not available. Please reconfigure.");
    }
    int h = 0;
    int m = 0;
    int s = 0;
    if (selection == 0) {
        h = settings.getInt(CFGKEY_FORHOURS);
        m = settings.getInt(CFGKEY_FORMINUTES);
        s = settings.getInt(CFGKEY_FORSECONDS);
    } else if (selection == 1) {
        h = settings.getInt(CFGKEY_TOHOURS);
        m = settings.getInt(CFGKEY_TOMINUTES);
        s = settings.getInt(CFGKEY_TOSECONDS);
    }
    if (!(0 <= h) && !(h <= 23)) {
        throw new InvalidSettingsException("Number of hours must be between 0 and 23. Hours = " + h + ".");
    } else if (!(0 <= m) && !(m <= 59)) {
        throw new InvalidSettingsException("Number of minutes must be between 0 and 59. Minutes = " + m + ".");
    } else if (!(0 <= s) && !(s <= 59)) {
        throw new InvalidSettingsException("Number of seconds must be between 0 and 59. Secondss = " + s + ".");
    }
    if (selection == 2) {
        SettingsModelString sms = new SettingsModelString(CFGKEY_FILESTATUS, null);
        sms.loadSettingsFrom(settings);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 48 with SettingsModelString

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

the class SleepNodeModel method loadValidatedSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_selection = settings.getInt(CFGKEY_WAITOPTION);
    if (m_selection == 0) {
        m_forHours = settings.getInt(CFGKEY_FORHOURS);
        m_forMin = settings.getInt(CFGKEY_FORMINUTES);
        m_forSec = settings.getInt(CFGKEY_FORSECONDS);
    } else if (m_selection == 1) {
        m_toHours = settings.getInt(CFGKEY_TOHOURS);
        m_toMin = settings.getInt(CFGKEY_TOMINUTES);
        m_toSec = settings.getInt(CFGKEY_TOSECONDS);
    } else if (m_selection == 2) {
        m_filePath = settings.getString(CFGKEY_FILEPATH);
        SettingsModelString sms = new SettingsModelString(CFGKEY_FILESTATUS, null);
        sms.loadSettingsFrom(settings);
        m_fileStatus = sms.getStringValue();
    }
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 49 with SettingsModelString

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

the class CaseEndNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    if (settings.containsKey(m_multipleActiveHandlingSettingsModel.getKey())) {
        SettingsModelString c = (SettingsModelString) m_multipleActiveHandlingSettingsModel.createCloneWithValidatedValue(settings);
        String value = c.getStringValue();
        try {
            MultipleActiveHandling.valueOf(value);
        } catch (Exception e) {
            throw new InvalidSettingsException("invalid constant for multiple-active handling policy: " + value);
        }
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException)

Example 50 with SettingsModelString

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

the class PieNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_allRows.validateSettings(settings);
    m_noOfRows.validateSettings(settings);
    m_pieColumn.validateSettings(settings);
    m_aggrMethod.validateSettings(settings);
    final String aggrMethod = ((SettingsModelString) m_aggrMethod.createCloneWithValidatedValue(settings)).getStringValue();
    final AggregationMethod method = AggregationMethod.getMethod4Command(aggrMethod);
    m_aggrColumn.validateSettings(settings);
    if (!AggregationMethod.COUNT.equals(method)) {
        final String value = ((SettingsModelString) m_aggrColumn.createCloneWithValidatedValue(settings)).getStringValue();
        if (value == null) {
            throw new InvalidSettingsException("No aggregation column only valid for method count");
        }
    }
}
Also used : AggregationMethod(org.knime.base.node.viz.aggregation.AggregationMethod) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) 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