use of com.genericworkflownodes.knime.parameter.InvalidParameterValueException in project GenericKnimeNodes by genericworkflownodes.
the class ParamCellEditor method getCellEditorValue.
@Override
public Object getCellEditorValue() {
if (param instanceof StringParameter || param instanceof DoubleParameter || param instanceof IntegerParameter) {
try {
if ((new ParameterVerifier(param)).verify(field)) {
param.fillFromString(field.getText());
} else {
JOptionPane.showMessageDialog(null, String.format("Invalid parameter value. Please provide a valid value for: %s", param.getMnemonic()));
}
} catch (InvalidParameterValueException e) {
LOGGER.error(e.getMessage(), e);
}
}
if (param instanceof StringChoiceParameter) {
StringChoiceParameter scp = (StringChoiceParameter) param;
String selectedValue = (String) choiceComboBox.getSelectedItem();
scp.setValue(selectedValue);
}
if (param instanceof BoolParameter) {
try {
param.fillFromString(choiceComboBox.getSelectedItem().toString());
} catch (InvalidParameterValueException e) {
LOGGER.error(e.getMessage(), e);
}
}
if (param instanceof ListParameter) {
String workaround = listEditorComponent.getParameterValue();
try {
param.fillFromString(workaround);
} catch (InvalidParameterValueException e) {
LOGGER.error(e.getMessage(), e);
}
}
return param;
}
use of com.genericworkflownodes.knime.parameter.InvalidParameterValueException in project GenericKnimeNodes by genericworkflownodes.
the class GenericKnimeNodeDialog method loadSettingsFrom.
@Override
protected void loadSettingsFrom(NodeSettingsRO settings, PortObjectSpec[] specs) throws NotConfigurableException {
String errorsFound = "";
for (String key : config.getParameterKeys()) {
Parameter<?> param = config.getParameter(key);
// skip file parameters
if (param instanceof IFileParameter) {
continue;
}
String value = null;
try {
value = settings.getString(key);
param.fillFromString(value);
} catch (InvalidSettingsException e) {
errorsFound += "- Entry for " + key + " not found in settings.xml.\n";
} catch (InvalidParameterValueException e) {
errorsFound += "- Entry for " + key + " in settings.xml has a value that does not match it restrictions.\n";
// Do not hard fail. Users should be able to edit the value in the dialog.
/*throw new NotConfigurableException(e.getMessage(), e);*/
}
}
if (!errorsFound.isEmpty()) {
LOGGER.error("Errors found loading Settings from disk. Maybe you are loading a node created with another version." + "\nUsing default values as defined in the Tool description." + "\nWe recommend to check the parameters highlighted in red carefully before clicking OK: \n" + errorsFound);
}
int nP = config.getNumberOfOutputPorts();
int[] selectedPorts = new int[nP];
for (int i = 0; i < nP; i++) {
try {
int idx = settings.getInt(GenericKnimeNodeModel.GENERIC_KNIME_NODES_OUTTYPE_PREFIX + i);
selectedPorts[i] = idx;
} catch (InvalidSettingsException e) {
throw new NotConfigurableException(e.getMessage(), e);
}
}
mtc.setSelectedTypes(selectedPorts);
}
Aggregations