use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class SettingsModelColumnFilter2 method loadSettingsForDialog.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
// must be set by associated the component
assert m_inputPortIndex >= 0;
if (m_inputPortIndex >= specs.length) {
String msg = "Specified port index is out of bounds";
NodeLogger.getLogger(SettingsModelColumnFilter2.class).coding(msg);
throw new NotConfigurableException(msg);
}
DataColumnSpecFilterConfiguration clone = m_filterConfiguration.clone();
m_filterConfiguration.loadConfigurationInDialog(settings, (DataTableSpec) specs[m_inputPortIndex]);
if (!clone.equals(m_filterConfiguration)) {
notifyChangeListeners();
}
}
use of org.knime.core.node.NotConfigurableException 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.NotConfigurableException in project knime-core by knime.
the class ColumnSelectionPanel 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 addSelColIfInvalid adds the selected column although it does not
* not exist in the given spec or is filtered by the filter.
* The column is added at the end and rendered with a red border.
* @param useRowID set this parameter to <code>true</code> and the
* selColName to <code>null</code> if the the row id option should be
* selected
* @throws NotConfigurableException If the spec does not contain at least
* one compatible type.
* @since 2.10
*/
public final void update(final DataTableSpec spec, final String selColName, final boolean useRowID, final boolean addSelColIfInvalid) throws NotConfigurableException {
m_spec = spec;
m_chooser.removeAllItems();
if (m_addNoneColOption) {
final String noneOption = DataTableSpec.getUniqueColumnName(spec, NONE_OPTION_LABEL);
m_noneColSpec = new DataColumnSpecCreator(noneOption, DataType.getMissingCell().getType()).createSpec();
m_chooser.addItem(m_noneColSpec);
m_chooser.setToolTipText("Select " + noneOption + " for no column");
}
if (m_addRowIDOption) {
final String rowIDOption = DataTableSpec.getUniqueColumnName(spec, ROWID_OPTION_LABEL);
m_rowIDColSpec = new DataColumnSpecCreator(rowIDOption, DataType.getMissingCell().getType()).createSpec();
m_chooser.addItem(m_rowIDColSpec);
m_chooser.setToolTipText("Select " + rowIDOption + " for RowID");
}
DataColumnSpec selectMe = null;
if (spec != null) {
for (DataColumnSpec current : spec) {
if (m_columnFilter.includeColumn(current)) {
m_chooser.addItem(current);
if (current.getName().equals(selColName)) {
selectMe = current;
}
}
}
if (selectMe != null) {
m_chooser.setSelectedItem(selectMe);
} else {
if (addSelColIfInvalid && selColName != null) {
m_chooser.addItem(DataColumnSpecListCellRenderer.createInvalidSpec(selColName));
}
if (m_addNoneColOption && !useRowID) {
m_chooser.setSelectedItem(m_noneColSpec);
} else if (m_addRowIDOption && useRowID) {
m_chooser.setSelectedItem(m_rowIDColSpec);
} else {
// select last element
final int size = m_chooser.getItemCount();
if (size > 0) {
m_chooser.setSelectedIndex(size - 1);
}
}
}
}
if ((m_chooser.getItemCount() == 0 || containsOnlyTheInvalidColumn(addSelColIfInvalid, selectMe)) && m_isRequired) {
throw new NotConfigurableException(m_columnFilter.allFilteredMsg());
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class ShapeManagerNodeDialogPane method loadSettingsFrom.
/**
* Updates this dialog by refreshing all components in the shape settings
* tab. Inits the column name combo box and sets the values for the default
* selected one.
*
* @param settings the settings to load
* @param specs the input table specs
* @throws NotConfigurableException if no column contains domain values
* @see NodeDialogPane#loadSettingsFrom(NodeSettingsRO, DataTableSpec[])
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
// remove all columns and column value to shape mappings
m_columns.removeAllItems();
m_map.clear();
// read settings and write into the map
String target = settings.getString(ShapeManagerNodeModel.SELECTED_COLUMN, null);
// add columns and domain value mapping
int cols = specs[0].getNumColumns();
Shape[] shapes = ShapeFactory.getShapes().toArray(new Shape[] {});
for (int i = 0; i < cols; i++) {
DataColumnSpec cspec = specs[0].getColumnSpec(i);
DataColumnDomain domain = cspec.getDomain();
if (domain.hasValues()) {
LinkedHashMap<DataCell, Shape> domMap = new LinkedHashMap<DataCell, Shape>();
int j = 0;
for (DataCell value : domain.getValues()) {
if (value != null) {
String shape = settings.getString(value.toString(), // no settings -> assign different shapes
null);
if (shape == null) {
// bugfix 1283
domMap.put(value, shapes[j++ % shapes.length]);
} else {
domMap.put(value, ShapeFactory.getShape(shape));
}
}
}
m_map.put(cspec.getName(), domMap);
} else {
continue;
}
m_columns.addItem(cspec);
if (cspec.getName().equals(target)) {
m_columns.setSelectedItem(cspec);
}
}
if (m_map.size() == 0) {
throw new NotConfigurableException("No column in data contains" + " domain values.");
}
columnChanged(getSelectedColumn());
m_columns.addItemListener(this);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class LiftChartNodeDialog method loadAdditionalSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
public void loadAdditionalSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
super.loadAdditionalSettingsFrom(settings, specs);
if (specs == null || specs.length == 0 || specs[0] == null) {
throw new NotConfigurableException("No column specs given.");
}
DataTableSpec specNull = specs[0];
if (specNull.getNumColumns() == 0) {
throw new NotConfigurableException("No column specs given.");
}
boolean foundColumn = false;
for (int col = 0; col < specNull.getNumColumns(); col++) {
DataColumnSpec cs = specNull.getColumnSpec(col);
if (cs.getType().isCompatible(NominalValue.class) && cs.getDomain().hasValues()) {
foundColumn = true;
break;
}
}
if (!foundColumn) {
throw new NotConfigurableException("No nominal column with domain values found." + " Please use the domain calculator first.");
}
m_dataTableSpec = specNull;
m_signDC.replaceListItems(getPossibleLabels(m_responseColumn.getStringValue()), null);
}
Aggregations