Search in sources :

Example 36 with NotConfigurableException

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);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec)

Example 37 with NotConfigurableException

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());
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) DatabaseConnectionPortObjectSpec(org.knime.core.node.port.database.DatabaseConnectionPortObjectSpec)

Example 38 with NotConfigurableException

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);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 39 with NotConfigurableException

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;
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) Frame(java.awt.Frame) Container(java.awt.Container) JTable(javax.swing.JTable) Component(java.awt.Component)

Example 40 with NotConfigurableException

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;
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) Frame(java.awt.Frame) Container(java.awt.Container) DataTableSpec(org.knime.core.data.DataTableSpec)

Aggregations

NotConfigurableException (org.knime.core.node.NotConfigurableException)79 DataColumnSpec (org.knime.core.data.DataColumnSpec)35 DataTableSpec (org.knime.core.data.DataTableSpec)35 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)31 DataColumnSpecFilterConfiguration (org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)8 HashSet (java.util.HashSet)6 ArrayList (java.util.ArrayList)5 DataType (org.knime.core.data.DataType)5 NominalValue (org.knime.core.data.NominalValue)5 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)5 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 Container (java.awt.Container)3 Frame (java.awt.Frame)3 GridBagConstraints (java.awt.GridBagConstraints)3 ActionListener (java.awt.event.ActionListener)3 ItemListener (java.awt.event.ItemListener)3 AbstractButton (javax.swing.AbstractButton)3 DefaultListModel (javax.swing.DefaultListModel)3 LinkedHashMap (java.util.LinkedHashMap)2 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)2