use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class AccuracyScorerNodeDialog method loadSettingsFrom.
// ScorerNodeDialog(NodeModel)
/**
* Fills the two combo boxes with all column names retrieved from the input
* table spec. The second and last column will be selected by default unless
* the settings object contains others.
*
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
assert (settings != null && specs != null);
m_firstColumns.removeAllItems();
m_secondColumns.removeAllItems();
DataTableSpec spec = specs[getDataInputPortIndex()];
if ((spec == null) || (spec.getNumColumns() < 2)) {
throw new NotConfigurableException("Scorer needs an input table " + "with at least two columns");
}
int numCols = spec.getNumColumns();
for (int i = 0; i < numCols; i++) {
DataColumnSpec c = spec.getColumnSpec(i);
m_firstColumns.addItem(c);
m_secondColumns.addItem(c);
}
// if at least two columns available
String col2DefaultName = (numCols > 0) ? spec.getColumnSpec(numCols - 1).getName() : null;
String col1DefaultName = (numCols > 1) ? spec.getColumnSpec(numCols - 2).getName() : col2DefaultName;
DataColumnSpec col1 = spec.getColumnSpec(settings.getString(getFirstCompID(), col1DefaultName));
DataColumnSpec col2 = spec.getColumnSpec(settings.getString(getSecondCompID(), col2DefaultName));
m_firstColumns.setSelectedItem(col1);
m_secondColumns.setSelectedItem(col2);
String varPrefix = settings.getString(getFlowVarPrefix(), null);
boolean useFlowVar = varPrefix != null;
if (m_flowvariableBox.isSelected() != useFlowVar) {
m_flowvariableBox.doClick();
}
if (varPrefix != null) {
m_flowVariablePrefixTextField.setText(varPrefix);
}
try {
m_sortingOptions.loadDefault(settings);
} catch (InvalidSettingsException e) {
m_sortingOptions.setSortingStrategy(getFallbackStrategy());
m_sortingOptions.setReverseOrder(false);
}
m_sortingOptions.updateControls();
if (m_missingValueOption) {
boolean ignoreMissingValues = settings.getBoolean(AccuracyScorerNodeModel.ACTION_ON_MISSING_VALUES, AccuracyScorerNodeModel.DEFAULT_IGNORE_MISSING_VALUES);
m_ignoreMissingValues.setSelected(ignoreMissingValues);
m_failOnMissingValues.setSelected(!ignoreMissingValues);
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class LinReg2LinePlotterProperties method update.
/**
* Updates the selection boxes with the new
* {@link org.knime.core.data.DataTableSpec} and selects the passed indices.
* Takes care, that the x column selection box only contains the columns
* used for model calculation. For this purpose the ItemListeners of this
* box are removed and afterwards added again in order to avoid event loops.
*
* @param spec the new data table spec.
* @param xPreSelect the x column index (-1 if unknown)
* @param yPreSelect the y column (-1 if unknown)
*/
@Override
public void update(final DataTableSpec spec, final int xPreSelect, final int yPreSelect) {
try {
m_xSelector.update(spec, spec.getColumnSpec(xPreSelect).getName(), true);
m_ySelector.update(spec, spec.getColumnSpec(yPreSelect).getName(), true);
// store the old selected one
Object oldSelected = m_xSelector.getSelectedItem();
// suppress events
ItemListener[] listeners = m_xSelector.getItemListeners();
for (ItemListener listener : listeners) {
m_xSelector.removeItemListener(listener);
}
if (m_includs != null) {
// cleanup -> remove all items and add only the included
m_xSelector.removeAllItems();
List<String> survivors = Arrays.asList(m_includs);
for (DataColumnSpec colSpec : spec) {
if (!colSpec.getName().equals(m_targetColumn) && survivors.contains(colSpec.getName())) {
m_xSelector.addItem(colSpec);
}
}
// restore the previously selected
m_xSelector.setSelectedItem(oldSelected);
for (ItemListener listener : listeners) {
m_xSelector.addItemListener(listener);
}
}
} catch (NotConfigurableException e) {
LOGGER.warn(e.getMessage(), e);
}
DataColumnSpec x = (DataColumnSpec) m_xSelector.getSelectedItem();
DataColumnSpec y = (DataColumnSpec) m_ySelector.getSelectedItem();
m_ySelector.setEnabled(false);
updateRangeSpinner(x, y);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class FuzzyClusterNodeDialog method loadSettingsFrom.
/**
* Loads the settings from the model, Number of Clusters and
* maximum number of Iterations.
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
assert (settings != null && specs != null);
if (specs[0].getNumColumns() <= 0) {
throw new NotConfigurableException("No input data");
}
if (settings.containsKey(FuzzyClusterNodeModel.NRCLUSTERS_KEY)) {
try {
int tempnrclusters = settings.getInt(FuzzyClusterNodeModel.NRCLUSTERS_KEY);
if ((1 < tempnrclusters) && (tempnrclusters < MAXNRCLUSTERS)) {
m_nrClustersSpinner.setValue(tempnrclusters);
} else {
throw new InvalidSettingsException("Value out of range for number of" + " clusters, must be in [1,9999]");
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.MAXITERATIONS_KEY)) {
try {
int tempmaxiter = settings.getInt(FuzzyClusterNodeModel.MAXITERATIONS_KEY);
if ((1 <= tempmaxiter) && (tempmaxiter < MAXNRCLUSTERS)) {
m_maxNrIterationsSpinner.setValue(tempmaxiter);
} else {
throw new InvalidSettingsException("Value out of range " + "for maximum number of iterations, must be in " + "[1,9999]");
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.FUZZIFIER_KEY)) {
try {
double tempfuzzifier = settings.getDouble(FuzzyClusterNodeModel.FUZZIFIER_KEY);
if ((1 < tempfuzzifier) && (tempfuzzifier < MAXFUZZIFIER)) {
m_fuzzifierSpinner.setValue(tempfuzzifier);
} else {
throw new InvalidSettingsException("Value out of range " + "for fuzzifier, must be in " + "[>1,10]");
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.NOISE_KEY)) {
try {
boolean noise = settings.getBoolean(FuzzyClusterNodeModel.NOISE_KEY);
if (noise) {
m_noisecheck.setSelected(noise);
if (settings.containsKey(FuzzyClusterNodeModel.DELTAVALUE_KEY)) {
double delta = settings.getDouble(FuzzyClusterNodeModel.DELTAVALUE_KEY);
if (delta > 0) {
m_providedeltaRB.setEnabled(true);
m_notprovidedeltaRB.setEnabled(true);
m_providedeltaRB.setSelected(true);
m_deltaSpinner.setEnabled(true);
m_deltaSpinner.setValue(delta);
}
}
if (settings.containsKey(FuzzyClusterNodeModel.LAMBDAVALUE_KEY)) {
double lambda = settings.getDouble(FuzzyClusterNodeModel.LAMBDAVALUE_KEY);
if (lambda > 0) {
m_notprovidedeltaRB.setEnabled(true);
m_providedeltaRB.setEnabled(true);
m_notprovidedeltaRB.setSelected(true);
m_lambdaSpinner.setEnabled(true);
m_lambdaSpinner.setValue(lambda);
}
}
}
} catch (InvalidSettingsException e) {
LOGGER.debug("Invalid Settings", e);
}
} else {
m_providedeltaRB.setEnabled(false);
m_notprovidedeltaRB.setEnabled(false);
}
if (specs[FuzzyClusterNodeModel.INPORT] == null) {
// settings can't be evaluated against the spec
return;
}
ColumnFilterPanel p = (ColumnFilterPanel) getTab(TAB2);
if (settings.containsKey(FuzzyClusterNodeModel.INCLUDELIST_KEY)) {
String[] columns = settings.getStringArray(FuzzyClusterNodeModel.INCLUDELIST_KEY, new String[0]);
HashSet<String> list = new HashSet<String>();
for (int i = 0; i < columns.length; i++) {
if (specs[FuzzyClusterNodeModel.INPORT].containsName(columns[i])) {
list.add(columns[i]);
}
}
// set include list on the panel
p.update(specs[FuzzyClusterNodeModel.INPORT], false, list);
} else {
p.update(specs[FuzzyClusterNodeModel.INPORT], true, new String[] {});
}
p.setKeepAllSelected(settings.getBoolean(FuzzyClusterNodeModel.CFGKEY_KEEPALL, false));
if (settings.containsKey(FuzzyClusterNodeModel.MEMORY_KEY)) {
try {
boolean memory = settings.getBoolean(FuzzyClusterNodeModel.MEMORY_KEY);
m_memoryCB.setSelected(memory);
} catch (InvalidSettingsException e) {
// nothing to do here.
}
}
if (settings.containsKey(FuzzyClusterNodeModel.MEASURES_KEY)) {
try {
boolean measures = settings.getBoolean(FuzzyClusterNodeModel.MEASURES_KEY);
m_measuresCB.setSelected(measures);
} catch (InvalidSettingsException e) {
// nothing to do here.
}
}
boolean useSeed = settings.getBoolean(FuzzyClusterNodeModel.USE_SEED_KEY, false);
m_useRandomSeed.setSelected(useSeed);
int seed = settings.getInt(FuzzyClusterNodeModel.SEED_KEY, (int) (2 * (Math.random() - 0.5) * Integer.MAX_VALUE));
m_randomSeed.setValue(seed);
m_randomSeed.setEnabled(useSeed);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class ColumnSelectionComboxBox method update.
/**
* Updates this filter panel by removing all current items and adding the
* columns according to the content of the argument <code>spec</code>. If
* a column name is provided and it is not filtered out the corresponding
* item in the combo box will be selected.
*
* @param spec To get the column names, types and the current index from.
* @param selColName The column name to be set as chosen.
* @param suppressEvents <code>true</code> if events caused by adding
* items to the combo box should be suppressed,
* <code>false</code> otherwise.
* @param filter a filter that filters the columns that should be shown in
* the combo box; this overrides the value classes given in the
* constructor
* @throws NotConfigurableException If the spec does not contain any column
* compatible to the target value class(es) as given in
* constructor.
*/
public final void update(final DataTableSpec spec, final String selColName, final boolean suppressEvents, final ColumnFilter filter) throws NotConfigurableException {
m_spec = spec;
m_columnFilter = filter;
ItemListener[] itemListeners = null;
ActionListener[] actionListeners = null;
if (suppressEvents) {
itemListeners = getListeners(ItemListener.class);
for (final ItemListener il : itemListeners) {
removeItemListener(il);
}
actionListeners = getListeners(ActionListener.class);
for (final ActionListener al : actionListeners) {
removeActionListener(al);
}
}
removeAllItems();
DataColumnSpec selectMe = null;
if (m_spec != null) {
for (int c = 0; c < m_spec.getNumColumns(); c++) {
final DataColumnSpec current = m_spec.getColumnSpec(c);
if (m_columnFilter.includeColumn(current)) {
addItem(current);
if (current.getName().equals(selColName)) {
selectMe = current;
}
}
}
setSelectedItem(null);
}
if (suppressEvents) {
for (final ItemListener il : itemListeners) {
addItemListener(il);
}
for (final ActionListener al : actionListeners) {
addActionListener(al);
}
}
if (selectMe != null) {
setSelectedItem(selectMe);
} else {
// select last element
final int size = getItemCount();
if (size > 0) {
setSelectedIndex(size - 1);
}
}
if (getItemCount() == 0) {
throw new NotConfigurableException(m_columnFilter.allFilteredMsg());
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class ColumnAutoTypeCasterNodeDialogPane method loadSettingsFrom.
/**
* Calls the update method of the underlying filter panel.
* @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 {
final DataTableSpec spec = specs[0];
if (spec == null || spec.getNumColumns() == 0) {
throw new NotConfigurableException("No columns available for " + "selection.");
}
DataColumnSpecFilterConfiguration config = ColumnAutoTypeCasterNodeModel.createDCSFilterConfiguration();
config.loadConfigurationInDialog(settings, specs[0]);
m_filterPanel.loadConfiguration(config, specs[0]);
m_dateBox.setSelectedItem(settings.getString(CFGKEY_DATEFORMAT, "dd.MM.yy"));
m_missValueChooser.setSelectedItem(settings.getString(CFGKEY_MISSVALPAT, "<none>"));
m_quickScanCheckBox.setSelected(settings.getBoolean(CFGKEY_QUICKSANBOOLEAN, false));
m_numberOfRowsSpinner.setValue(settings.getInt(CFGKEY_QUICKSCANROWS, 1000));
}
Aggregations