use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelColor method validateSettingsForModel.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
final Config config = settings.getConfig(getConfigName());
// check all color values
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);
if (red < 0 || green < 0 || blue < 0 || alpha < 0) {
// the color is null
return;
}
// constructor checks the value ranges
new Color(red, green, blue, alpha);
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelFilterString method saveSettingsForModel.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsForModel(final NodeSettingsWO settings) {
Config lists = settings.addConfig(m_configName);
lists.addStringArray(CFGKEY_INCL, getIncludeList().toArray(new String[0]));
lists.addStringArray(CFGKEY_EXCL, getExcludeList().toArray(new String[0]));
lists.addBoolean(CFGKEY_KEEPALL, m_keepAll);
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelFilterString method loadSettingsForDialog.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
try {
Config lists = settings.getConfig(m_configName);
// the way we do this, partially correct settings will be partially
// transferred into the dialog. Which is okay, I guess.
setIncludeList(lists.getStringArray(CFGKEY_INCL, (String[]) null));
setExcludeList(lists.getStringArray(CFGKEY_EXCL, (String[]) null));
setKeepAllSelected(lists.getBoolean(CFGKEY_KEEPALL, false));
} catch (IllegalArgumentException iae) {
// if the argument is not accepted: keep the old value.
} catch (InvalidSettingsException ise) {
// no settings - keep the old value.
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModel method readEnableStatusAndCheckModelID.
/**
* Checks the modelID stored in the settings object and throws an assertion
* if it doesn't match the ID of this model. It also reads the enabled
* status back in - and throws an exeption if any of these settings is
* missing (the enabled status will remain unchanged then).
*
* @param settings the config object to read the enable state and model ID
* from
*/
private void readEnableStatusAndCheckModelID(final NodeSettingsRO settings) throws InvalidSettingsException {
Config idCfg = null;
try {
idCfg = settings.getConfig(getConfigName() + CFGKEY_INTERNAL);
} catch (InvalidSettingsException ise) {
// doesn't exist.
return;
}
String settingsID = idCfg.getString(CFGKEY_MODELID);
m_enabled = idCfg.getBoolean(CFGKEY_ENABLESTAT);
assert getModelTypeID().equals(settingsID) : "Incorrect Implementation:" + "The SettingsModel used to write the values is" + " different from the one that reads them. (WriteID = " + settingsID + ", ReadID = " + getModelTypeID() + ", Reading settings model: " + this.toString() + ")";
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class FilterDefinitionHandlerPortObject method getViews.
/**
* {@inheritDoc}
*/
@Override
public JComponent[] getViews() {
ModelContent model = new ModelContent("FilterDefinition");
Config columnConfig = model.addConfig("Column");
getSpec().forEach(col -> col.getFilterHandler().ifPresent(handler -> handler.save(columnConfig.addConfig(col.getName()))));
return new JComponent[] { new ModelContentOutPortView(model) };
}
Aggregations