use of org.knime.core.node.config.Config in project knime-core by knime.
the class BufferedDataTable method saveSpec.
/**
* Utility method that is used when the node saves its state. It saves
* it to a file spec.xml.
* @param spec To save
* @param dataPortDir destination directory
* @throws IOException if that fails for any reason
*/
static void saveSpec(final DataTableSpec spec, final File dataPortDir) throws IOException {
// is configured but can't calculate output, e.g. transpose node)
if (spec == null) {
return;
}
File specFile = new File(dataPortDir, TABLE_SPEC_FILE);
Config c = new NodeSettings(TABLE_SPEC_FILE);
spec.save(c);
c.saveToXML(new BufferedOutputStream(new FileOutputStream(specFile)));
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelAuthentication method saveSettingsForModel.
/**
* {@inheritDoc}
*/
@Override
protected void saveSettingsForModel(final NodeSettingsWO settings) {
Config config = settings.addConfig(m_configName);
config.addString(CREDENTIAL, m_credentials);
config.addString(USERNAME, m_username);
config.addPassword(PASSWORD, secretKey, m_password);
config.addString(SELECTED_TYPE, m_type.name());
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelAuthentication method loadSettingsForDialog.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
// use the current value, if no value is stored in the settings
final Config config;
try {
config = settings.getConfig(m_configName);
setValues(AuthenticationType.valueOf(config.getString(SELECTED_TYPE, m_type.name())), config.getString(CREDENTIAL, m_credentials), config.getString(USERNAME, m_username), config.getPassword(PASSWORD, secretKey, m_password));
} catch (InvalidSettingsException ex) {
throw new NotConfigurableException(ex.getMessage());
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelAuthentication method validateSettingsForModel.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
final Config config = settings.getConfig(m_configName);
final String type = config.getString(SELECTED_TYPE);
final String credential = config.getString(CREDENTIAL);
final String userName = config.getString(USERNAME);
final String pwd = config.getPassword(PASSWORD, secretKey);
final AuthenticationType authType = AuthenticationType.get(type);
switch(authType) {
case CREDENTIALS:
if (credential == null || credential.isEmpty()) {
throw new InvalidSettingsException("Please select a valid credential");
}
break;
case KERBEROS:
break;
case NONE:
break;
case USER:
if (userName == null || userName.isEmpty()) {
throw new InvalidSettingsException("Please enter a valid user name");
}
break;
case USER_PWD:
if (userName == null || userName.isEmpty()) {
throw new InvalidSettingsException("Please enter a valid user name");
}
if (pwd == null || pwd.isEmpty()) {
throw new InvalidSettingsException("Please enter a valid password");
}
break;
default:
break;
}
}
use of org.knime.core.node.config.Config in project knime-core by knime.
the class SettingsModelColor method loadSettingsForDialog.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
if (!settings.containsKey(getConfigName())) {
// use the current value, if no value is stored in the settings
setColorValue(m_value);
return;
}
try {
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) {
// if the argument is not accepted: keep the old value.
} catch (final InvalidSettingsException e) {
// if the argument is not accepted: keep the old value.
} finally {
// always notify the listeners. That is, because there could be an
// invalid value displayed in the listener.
notifyChangeListeners();
}
}
Aggregations