use of org.knime.base.node.preproc.filter.column.FilterColumnPanel.SelectionOption in project knime-core by knime.
the class FilterColumnNodeDialog method loadSettingsFrom.
/**
* Calls the update method of the underlying filter panel using the input
* data table spec from this {@link FilterColumnNodeModel}.
*
* @param settings the node settings to read from
* @param specs the input specs
* @throws NotConfigurableException if no columns are available for
* filtering
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
assert (settings != null && specs.length == 1);
if (specs[FilterColumnNodeModel.INPORT] == null || specs[FilterColumnNodeModel.INPORT].getNumColumns() == 0) {
throw new NotConfigurableException("No columns available for " + "selection.");
}
String[] columns = settings.getStringArray(FilterColumnNodeModel.KEY, new String[0]);
HashSet<String> list = new HashSet<String>();
for (int i = 0; i < columns.length; i++) {
if (specs[FilterColumnNodeModel.INPORT].containsName(columns[i])) {
list.add(columns[i]);
}
}
String selOptionS = settings.getString(FilterColumnNodeModel.CFG_KEY_SELECTIONOPTION, SelectionOption.EnforceExclusion.toString());
SelectionOption selectionOption = SelectionOption.parse(selOptionS, SelectionOption.EnforceExclusion);
// set exclusion list on the panel
FilterColumnPanel p = (FilterColumnPanel) getTab(TAB);
p.update(specs[FilterColumnNodeModel.INPORT], selectionOption, list);
}
use of org.knime.base.node.preproc.filter.column.FilterColumnPanel.SelectionOption in project knime-core by knime.
the class FilterColumnNodeDialog method saveSettingsTo.
/**
* Sets the list of columns to exclude inside the underlying
* {@link FilterColumnNodeModel} retrieving them from the filter panel.
*
* @param settings the node settings to write into
*
* @see NodeDialogPane#saveSettingsTo(NodeSettingsWO)
*/
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
FilterColumnPanel p = (FilterColumnPanel) getTab(TAB);
SelectionOption selOption = p.getSelectionOption();
Set<String> list;
switch(selOption) {
case EnforceExclusion:
list = p.getExcludedColumnSet();
break;
case EnforceInclusion:
list = p.getIncludedColumnSet();
break;
default:
throw new InvalidSettingsException("No selection option chosen.");
}
settings.addString(FilterColumnNodeModel.CFG_KEY_SELECTIONOPTION, selOption.toString());
settings.addStringArray(FilterColumnNodeModel.KEY, list.toArray(new String[0]));
}
Aggregations