Search in sources :

Example 66 with Config

use of org.knime.core.node.config.Config in project knime-core by knime.

the class SettingsModelAuthentication method loadSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    // no default value, throw an exception instead
    Config config = settings.getConfig(m_configName);
    setValues(AuthenticationType.valueOf(config.getString(SELECTED_TYPE)), config.getString(CREDENTIAL), config.getString(USERNAME), config.getPassword(PASSWORD, secretKey));
}
Also used : Config(org.knime.core.node.config.Config)

Example 67 with Config

use of org.knime.core.node.config.Config in project knime-core by knime.

the class SettingsModelColor method loadSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    try {
        // no default value, throw an exception instead
        final Config config = settings.getConfig(getConfigName());
        final int red = config.getInt(CNFG_RED);
        final int green = config.getInt(CNFG_GREEN);
        final int blue = config.getInt(CNFG_BLUE);
        final int alpha = config.getInt(CNFG_ALPHA);
        Color color;
        if (red < 0 || green < 0 || blue < 0 || alpha < 0) {
            // the color is null
            color = null;
        } else {
            color = new Color(red, green, blue, alpha);
        }
        setColorValue(color);
    } catch (final IllegalArgumentException iae) {
        throw new InvalidSettingsException(iae.getMessage());
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config) Color(java.awt.Color)

Example 68 with Config

use of org.knime.core.node.config.Config in project knime-core by knime.

the class SettingsModelColor method saveSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsForModel(final NodeSettingsWO settings) {
    final Config config = settings.addConfig(getConfigName());
    final int red, green, blue, alpha;
    if (m_value != null) {
        red = m_value.getRed();
        green = m_value.getGreen();
        blue = m_value.getBlue();
        alpha = m_value.getAlpha();
    } else {
        red = -1;
        green = -1;
        blue = -1;
        alpha = -1;
    }
    config.addInt(CNFG_RED, red);
    config.addInt(CNFG_GREEN, green);
    config.addInt(CNFG_BLUE, blue);
    config.addInt(CNFG_ALPHA, alpha);
}
Also used : Config(org.knime.core.node.config.Config)

Example 69 with Config

use of org.knime.core.node.config.Config in project knime-core by knime.

the class SettingsModelFilterString method loadSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    try {
        // no default value, throw an exception instead
        Config lists = settings.getConfig(m_configName);
        String[] incl = lists.getStringArray(CFGKEY_INCL);
        String[] excl = lists.getStringArray(CFGKEY_EXCL);
        setIncludeList(incl);
        setExcludeList(excl);
        boolean keepAll = lists.getBoolean(CFGKEY_KEEPALL, false);
        setKeepAllSelected(keepAll);
    } catch (IllegalArgumentException iae) {
        throw new InvalidSettingsException(iae.getMessage());
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Config(org.knime.core.node.config.Config)

Example 70 with Config

use of org.knime.core.node.config.Config in project knime-core by knime.

the class SettingsModelFilterString method validateSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    // expect a sub-config with two string arrays: include and exclude list
    Config lists = settings.getConfig(m_configName);
    lists.getStringArray(CFGKEY_INCL);
    lists.getStringArray(CFGKEY_EXCL);
}
Also used : Config(org.knime.core.node.config.Config)

Aggregations

Config (org.knime.core.node.config.Config)84 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)25 Color (java.awt.Color)10 File (java.io.File)10 FileOutputStream (java.io.FileOutputStream)8 NodeSettings (org.knime.core.node.NodeSettings)8 ArrayList (java.util.ArrayList)7 DataColumnSpec (org.knime.core.data.DataColumnSpec)7 ConfigRO (org.knime.core.node.config.ConfigRO)7 HashMap (java.util.HashMap)6 GZIPOutputStream (java.util.zip.GZIPOutputStream)6 LinkedHashMap (java.util.LinkedHashMap)5 DataColumnSpecCreator (org.knime.core.data.DataColumnSpecCreator)5 DataTableSpec (org.knime.core.data.DataTableSpec)5 SimpleStreamableOperatorInternals (org.knime.core.node.streamable.simple.SimpleStreamableOperatorInternals)5 FileInputStream (java.io.FileInputStream)4 IOException (java.io.IOException)4 HashSet (java.util.HashSet)4 GZIPInputStream (java.util.zip.GZIPInputStream)4 DataCell (org.knime.core.data.DataCell)4