use of org.knime.core.node.defaultnodesettings.SettingsModelStringArray in project GenericKnimeNodes by genericworkflownodes.
the class ListMimeFileImporterNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
SettingsModelStringArray tmp_filenames = m_filenames.createCloneWithValidatedValue(settings);
if (tmp_filenames == null || tmp_filenames.getStringArrayValue().length == 0) {
throw new InvalidSettingsException("No Files selected.");
}
SettingsModelOptionalString tmp_file_extension = m_file_extension.createCloneWithValidatedValue(settings);
if (tmp_file_extension.isActive()) {
if (tmp_file_extension.getStringValue().equals("")) {
throw new InvalidSettingsException("No File extension (override) provided.");
} else if (MIMETypeHelper.getMIMEtypeByExtension(tmp_file_extension.getStringValue()) == null) {
throw new InvalidSettingsException("No MIMEtype registered for file extension: " + tmp_file_extension.getStringValue());
}
} else {
List<String> mts = new ArrayList<String>();
String mt = null;
for (String filename : tmp_filenames.getStringArrayValue()) {
mt = MIMETypeHelper.getMIMEtype(filename);
if (mt == null) {
throw new InvalidSettingsException("Files of unknown MIMEtype selected: " + filename);
}
mts.add(mt);
}
for (String mimeType : mts) {
if (!mimeType.equals(mt)) {
throw new InvalidSettingsException("Files with mixed MIMEType loaded");
}
}
}
}
use of org.knime.core.node.defaultnodesettings.SettingsModelStringArray in project GenericKnimeNodes by genericworkflownodes.
the class DialogComponentMultiFileChooser method validateSettingsBeforeSave.
@Override
protected void validateSettingsBeforeSave() throws InvalidSettingsException {
String[] filenames = new String[listbox.getModel().getSize()];
int idx = 0;
for (File file : ((FileListModel) listbox.getModel()).getFiles()) {
String filename = file.getAbsolutePath();
filenames[idx] = filename;
idx++;
}
((SettingsModelStringArray) getModel()).setStringArrayValue(filenames);
}
Aggregations