use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class DBSamplingNodeDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@SuppressWarnings("null")
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] ports) throws NotConfigurableException {
DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) ports[0];
final DataTableSpec[] specs;
if (dbSpec == null) {
specs = new DataTableSpec[] { null };
} else {
specs = new DataTableSpec[] { dbSpec.getDataTableSpec() };
}
boolean random;
try {
random = dbSpec.getConnectionSettings(getCredentialsProvider()).getUtility().supportsRandomSampling();
} catch (InvalidSettingsException e) {
throw new NotConfigurableException(e.getMessage());
}
m_countComp.loadSettingsFrom(settings, specs);
m_absoluteComp.loadSettingsFrom(settings, specs);
m_relativeComp.loadSettingsFrom(settings, specs);
m_samplingComp.loadSettingsFrom(settings, specs);
m_stratifiedComp.loadSettingsFrom(settings, specs);
m_columnComp.loadSettingsFrom(settings, specs);
if (!random) {
m_samplingComp.setToolTipText("Connected database does not support random sampling");
m_samplingMethod.setStringValue(DBSamplingNodeModel.SamplingMethod.FIRST.getActionCommand());
} else {
m_samplingComp.setToolTipText(null);
}
m_samplingMethod.setEnabled(random);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class DBTableCreatorConfiguration method loadSettingsForDialog.
/**
* Load settings for NodeDialog
*
* @param settings NodeSettingsRO instance to load from
* @param specs PortObjectSpec array to load from
* @throws NotConfigurableException
*/
public void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
try {
loadSettingsForModel(settings);
final String dbIdentifier = ((DatabaseConnectionPortObjectSpec) specs[0]).getDatabaseIdentifier();
loadSettingsForSqlEditor(dbIdentifier);
m_tableSpec = (DataTableSpec) specs[1];
if (m_tableSpec != null && (useDynamicSettings() || getColumns().isEmpty())) {
loadColumnSettingsFromTableSpec(m_tableSpec);
if (useDynamicSettings()) {
updateKeysWithDynamicSettings();
}
} else {
loadSettingsForRowElements(CFG_COLUMNS_SETTINGS, settings);
loadSettingsForRowElements(CFG_KEYS_SETTINGS, settings);
}
} catch (InvalidSettingsException e) {
throw new NotConfigurableException(e.getMessage());
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class FeatureSelectionLoopEndNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
final FeatureSelectionLoopEndSettings cfg = new FeatureSelectionLoopEndSettings();
cfg.loadInDialog(settings);
final Collection<FlowVariable> flowVars = getAvailableFlowVariables().values();
m_scoreVariableComboBox.removeAllItems();
FlowVariable selected = null;
final String scoreVariableName = cfg.getScoreVariableName();
boolean compatibleFVexists = false;
for (FlowVariable flowVar : flowVars) {
FlowVariable.Type flowvarType = flowVar.getType();
if (flowvarType == FlowVariable.Type.DOUBLE) {
if (flowVar.getName().equals(scoreVariableName)) {
selected = flowVar;
}
m_scoreVariableComboBox.addItem(flowVar);
compatibleFVexists = true;
}
}
if (!compatibleFVexists) {
throw new NotConfigurableException("There is no compatible Flow Variable (Double) at the inport.");
}
m_scoreVariableComboBox.setSelectedItem(selected);
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class AggregationSettingsButtonCellRenderer method openSettingsDialog.
private void openSettingsDialog() {
final JTable table = m_rootPanel.getTable();
final int rowIdx = table.convertRowIndexToModel(table.getEditingRow());
fireEditingStopped();
final AggregationFunctionRow<?> row = m_rootPanel.getTableModel().getRow(rowIdx);
if (!row.getFunction().hasOptionalSettings()) {
// the operator has no additional settings
return;
}
// figure out the parent to be able to make the dialog modal
Frame f = null;
Container c = m_rootPanel.getComponentPanel().getParent();
final Component root = SwingUtilities.getRoot(c);
if (root instanceof Frame) {
f = (Frame) root;
}
while (f == null && c != null) {
if (c instanceof Frame) {
f = (Frame) c;
break;
}
c = c.getParent();
}
try {
final AggregationSettingsDialog dialog = new AggregationSettingsDialog(f, row.getFunction(), m_rootPanel.getInputTableSpec());
// center the dialog
dialog.setLocationRelativeTo(c);
dialog.pack();
// show it
dialog.setVisible(true);
} catch (NotConfigurableException e) {
// show the error message
JOptionPane.showMessageDialog(m_rootPanel.getComponentPanel(), e.getMessage(), "Unable to open dialog", JOptionPane.ERROR_MESSAGE);
return;
}
}
use of org.knime.core.node.NotConfigurableException in project knime-core by knime.
the class DialogComponentAggregationMethod method actionPerformed.
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
// the user has pressed the additional parameters button
Frame f = null;
Container c = getComponentPanel().getParent();
while (c != null) {
if (c instanceof Frame) {
f = (Frame) c;
break;
}
c = c.getParent();
}
try {
int specIdx = getMethodModel().getInputPortIndex();
final DataTableSpec spec;
if (specIdx < 0 || getLastTableSpecs() == null) {
spec = new DataTableSpec();
} else {
spec = (DataTableSpec) getLastTableSpec(specIdx);
}
final AggregationSettingsDialog dialog = new AggregationSettingsDialog(f, getSelectedAggregationMethod(), spec);
// center the dialog
dialog.setLocationRelativeTo(c);
// show it
dialog.setVisible(true);
} catch (NotConfigurableException ex) {
// show the error message
final String erroMessage = ex.getMessage();
JOptionPane.showMessageDialog(getComponentPanel(), erroMessage, "Unable to open dialog", JOptionPane.ERROR_MESSAGE);
return;
}
}
Aggregations