use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class ColumnResorterNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
if (specs[0] == null || specs[0].getNumColumns() == 0) {
throw new NotConfigurableException("No input table found or no columns found in input table! " + "Please connect the node first or check input table.");
}
try {
List<DataColumnSpec> columnNames = new ArrayList<DataColumnSpec>();
for (DataColumnSpec colSpec : specs[0]) {
columnNames.add(colSpec);
}
m_columnNames = columnNames.toArray(new DataColumnSpec[] {});
if (m_model.size() > 0) {
m_model.removeAllElements();
}
m_order = settings.getStringArray(ColumnResorterNodeModel.CFG_NEW_ORDER);
Set<String> alreadyInList = new HashSet<String>();
if (m_order.length > 0) {
for (String cur : m_order) {
// is column in new spec?
if (specs[0].containsName(cur)) {
alreadyInList.add(cur);
m_model.addElement(specs[0].getColumnSpec(cur));
}
}
// add new columns at the end
for (DataColumnSpec cur : specs[0]) {
if (!alreadyInList.contains(cur.getName())) {
m_model.addElement(cur);
}
}
} else {
for (DataColumnSpec cur : m_columnNames) {
m_model.addElement(cur);
}
}
} catch (InvalidSettingsException is) {
// do nothing here - its the dialog
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class ScorerNodeDialog 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.
*
* @see NodeDialogPane#loadSettingsFrom(NodeSettingsRO, DataTableSpec[])
*/
@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[ScorerNodeModel.INPORT];
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++) {
String c = spec.getColumnSpec(i).getName();
m_firstColumns.addItem(c);
m_secondColumns.addItem(c);
}
// if at least two columns available
String col2 = (numCols > 0) ? spec.getColumnSpec(numCols - 1).getName() : null;
String col1 = (numCols > 1) ? spec.getColumnSpec(numCols - 2).getName() : col2;
col1 = settings.getString(ScorerNodeModel.FIRST_COMP_ID, col1);
col2 = settings.getString(ScorerNodeModel.SECOND_COMP_ID, col2);
m_firstColumns.setSelectedItem(col1);
m_secondColumns.setSelectedItem(col2);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class JavaScriptingPanel method loadSettingsFrom.
/**
* Load settings from arg.
* @param s To load from.
* @param spec The input spec.
*/
public void loadSettingsFrom(final JavaScriptingSettings s, final DataTableSpec spec) {
String exp = s.getExpression();
String header = s.getHeader();
String rType = s.getReturnType().getName();
boolean isArrayReturn = s.isArrayReturn();
String defaultNewName = m_customizer.getOutputIsVariable() ? "new variable" : "new column";
String newName = s.getColName();
boolean isReplace = s.isReplace();
boolean isTestCompilation = s.isTestCompilationOnDialogClose();
boolean isInsertMissingAsNull = s.isInsertMissingAsNull();
m_currentVersion = s.getExpressionVersion();
m_newNameField.setText("");
// will select newColName only if it is in the spec list
try {
m_replaceColumnCombo.update(spec, newName);
} catch (NotConfigurableException e1) {
NodeLogger.getLogger(getClass()).coding("Combo box throws " + "exception although content is not required", e1);
}
DefaultComboBoxModel cmbModel = (DefaultComboBoxModel) m_replaceVariableCombo.getModel();
cmbModel.removeAllElements();
final Map<String, FlowVariable> availableFlowVariables = m_varProvider.getAvailableFlowVariables();
for (FlowVariable v : availableFlowVariables.values()) {
switch(v.getScope()) {
case Flow:
cmbModel.addElement(v);
break;
default:
}
}
if (isReplace && availableFlowVariables.containsKey(newName)) {
m_replaceVariableCombo.setSelectedItem(availableFlowVariables.get(newName));
}
m_currentSpec = spec;
// whether there are variables or columns available
// -- which of two depends on the customizer
boolean fieldsAvailable;
if (m_customizer.getOutputIsVariable()) {
fieldsAvailable = m_replaceVariableCombo.getModel().getSize() > 0;
} else {
fieldsAvailable = m_replaceColumnCombo.getNrItemsInList() > 0;
}
if (isReplace && fieldsAvailable) {
m_replaceRadio.doClick();
} else {
m_appendRadio.doClick();
String newNameString = (newName != null ? newName : defaultNewName);
m_newNameField.setText(newNameString);
}
m_replaceRadio.setEnabled(fieldsAvailable);
m_headerEdit.setText(header);
m_expEdit.setText(exp);
m_expEdit.requestFocus();
ButtonModel firstButton = null;
for (Enumeration<?> e = m_returnTypeButtonGroup.getElements(); e.hasMoreElements(); ) {
AbstractButton b = (AbstractButton) e.nextElement();
if (firstButton == null) {
firstButton = b.getModel();
}
if (b.getActionCommand().equals(rType)) {
m_returnTypeButtonGroup.setSelected(b.getModel(), true);
}
}
if (m_returnTypeButtonGroup.getSelection() == null) {
m_returnTypeButtonGroup.setSelected(firstButton, true);
}
m_isArrayReturnChecker.setSelected(isArrayReturn);
DefaultListModel listModel = (DefaultListModel) m_colList.getModel();
listModel.removeAllElements();
if (m_currentVersion == Expression.VERSION_1X) {
listModel.addElement(Expression.ROWKEY);
listModel.addElement(Expression.ROWNUMBER);
} else {
listModel.addElement(Expression.ROWID);
listModel.addElement(Expression.ROWINDEX);
listModel.addElement(Expression.ROWCOUNT);
}
for (int i = 0; i < spec.getNumColumns(); i++) {
DataColumnSpec colSpec = spec.getColumnSpec(i);
listModel.addElement(colSpec);
}
DefaultListModel fvListModel = (DefaultListModel) m_flowVarsList.getModel();
fvListModel.removeAllElements();
for (FlowVariable v : availableFlowVariables.values()) {
fvListModel.addElement(v);
}
m_compileOnCloseChecker.setSelected(isTestCompilation);
m_insertMissingAsNullChecker.setSelected(isInsertMissingAsNull);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class DialogComponentColumnSelection method loadSettingsFrom.
/**
* Reads values for this dialog component from configuration object.
*
* @param settings the <code>NodeSettings</code> to read from
* @param specs the input specs
* @throws InvalidSettingsException if the settings could not be read
* @throws NotConfigurableException If the spec does not contain at least
* one column which is compatible to the value list as given in the
* constructor.
*/
@Override
public void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws InvalidSettingsException, NotConfigurableException {
String classCol = "** Unknown column **";
try {
classCol = settings.getString(m_configName);
} catch (Exception e) {
// do nothing here, since its the dialog
// catch it that the DefaultNodeDialogPane doesn't
// interrupt the for loop (loadSettings)
} finally {
// update JComboBox with list of column names
DataTableSpec spec = specs[m_specIndex];
m_chooser.update(spec, classCol);
}
}
Aggregations