Search in sources :

Example 66 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class ColumnHeaderInsertConfig method loadConfigurationInDialog.

void loadConfigurationInDialog(final NodeSettingsRO settings, final DataTableSpec dictionaryTable) throws NotConfigurableException {
    m_lookupColumn = settings.getString("lookupColumn", null);
    String firstStringCol = null;
    String fallbackCol = null;
    for (DataColumnSpec col : dictionaryTable) {
        if (col.getType().isCompatible(StringValue.class)) {
            fallbackCol = col.getName();
        }
        if (col.getType().equals(StringCell.TYPE)) {
            // exclude sdf etc
            firstStringCol = col.getName();
            break;
        }
    }
    if (fallbackCol == null) {
        throw new NotConfigurableException("Not configuration possible: " + "No string compatible column in dictionary table");
    }
    String defCol = firstStringCol != null ? firstStringCol : fallbackCol;
    m_valueColumn = settings.getString("valueColumn", defCol);
    m_failIfNoMatch = settings.getBoolean("failIfNoMatch", true);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Example 67 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class ColumnAggregatorNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    assert (specs.length == 1);
    m_spec = (DataTableSpec) specs[0];
    for (final DialogComponent component : m_components) {
        component.loadSettingsFrom(settings, specs);
    }
    try {
        m_aggrMethodsPanel.loadSettingsFrom(settings.getNodeSettings(ColumnAggregatorNodeModel.CFG_AGGREGATION_METHODS), getSuperType(), m_spec);
        m_version.loadSettingsFrom(settings);
    } catch (final InvalidSettingsException e) {
        throw new NotConfigurableException(e.getMessage(), e);
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DialogComponent(org.knime.core.node.defaultnodesettings.DialogComponent)

Example 68 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class EditNumericDomainNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    if (specs[0].getNumColumns() == 0) {
        throw new NotConfigurableException("No data at input.");
    }
    EditNumericDomainConfiguration forConfig = new EditNumericDomainConfiguration();
    forConfig.loadConfigurationInDialog(settings, specs[0]);
    m_filterPanel.loadConfiguration(forConfig.getColumnspecFilterConfig(), specs[0]);
    m_upperBField.setText(Double.isNaN(forConfig.getUpperBound()) ? "1.0" : Double.toString(forConfig.getUpperBound()));
    m_lowerBField.setText(Double.isNaN(forConfig.getLowerBound()) ? "0.0" : Double.toString(forConfig.getLowerBound()));
    m_handler = forConfig.getDomainOverflowPolicy();
    Enumeration<AbstractButton> elements = m_buttonGrp.getElements();
    while (elements.hasMoreElements()) {
        AbstractButton abstractButton = elements.nextElement();
        if (abstractButton.getActionCommand().equals(m_handler.toString())) {
            abstractButton.setSelected(true);
        }
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) AbstractButton(javax.swing.AbstractButton)

Example 69 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class MissingValueColumnFilterNodeDialogPane 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 = MissingValueColumnFilterNodeModel.createDCSFilterConfiguration();
    config.loadConfigurationInDialog(settings, specs[0]);
    m_filterPanel.loadConfiguration(config, specs[0]);
    m_percentage.loadSettingsFrom(settings, specs);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)

Example 70 with NotConfigurableException

use of org.knime.core.node.NotConfigurableException in project knime-core by knime.

the class RowFilterNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    if ((specs[0] == null) || (specs[0].getNumColumns() < 1)) {
        throw new NotConfigurableException("Cannot be configured without" + " input table");
    }
    // remove the old filter panels, if any
    if (m_rangePanel != null) {
        m_filterPanel.remove(m_rangePanel);
    }
    if (m_rowIDPanel != null) {
        m_filterPanel.remove(m_rowIDPanel);
    }
    if (m_colValPanel != null) {
        m_filterPanel.remove(m_colValPanel);
    }
    // now create new filter panels
    m_rangePanel = new RowNoRowFilterPanel();
    m_rowIDPanel = new RowIDRowFilterPanel();
    m_colValPanel = new ColumnRowFilterPanel(this, specs[0]);
    /*
         * now read the filters. We support three different filters:
         * RowIDFilter, AttrValfilter, and RowNumberFilter. But only one at a
         * time.
         */
    IRowFilter filter = null;
    try {
        // get the filter
        filter = RowFilterFactory.createRowFilter(settings.getNodeSettings(RowFilterNodeModel.CFGFILTER));
    } catch (InvalidSettingsException ise) {
    // silently ignore invalid filters.
    }
    String actionCommand = "colval";
    if (filter == null) {
        // set the default
        m_colValInclRadio.setSelected(true);
        filterSelectionChanged("colval");
        return;
    }
    if (filter instanceof ColValFilterOldObsolete) {
        // support the obsolete filter for backward compatibility
        ColValFilterOldObsolete f = (ColValFilterOldObsolete) filter;
        actionCommand = "colval";
        // activate the corresponding radio button
        if (f.includeMatchingLines()) {
            m_colValInclRadio.setSelected(true);
        } else {
            m_colValExclRadio.setSelected(true);
        }
        try {
            m_colValPanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else if (filter instanceof AttrValueRowFilter) {
        // this covers all the attribute value filters:
        // range, string compare, missing value filter
        AttrValueRowFilter f = (AttrValueRowFilter) filter;
        actionCommand = "colval";
        // activate the corresponding radio button
        if (f.getInclude()) {
            m_colValInclRadio.setSelected(true);
        } else {
            m_colValExclRadio.setSelected(true);
        }
        try {
            m_colValPanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else if (filter instanceof RowIDRowFilter) {
        RowIDRowFilter f = (RowIDRowFilter) filter;
        actionCommand = "id";
        // activate the corresponding radio button
        if (f.getInclude()) {
            m_rowIDInclRadio.setSelected(true);
        } else {
            m_rowIDExclRadio.setSelected(true);
        }
        try {
            m_rowIDPanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else if (filter instanceof RowNoRowFilter) {
        RowNoRowFilter f = (RowNoRowFilter) filter;
        actionCommand = "range";
        // activate the corresponding radio button
        if (f.getInclude()) {
            m_rangeInclRadio.setSelected(true);
        } else {
            m_rangeExclRadio.setSelected(true);
        }
        try {
            m_rangePanel.loadSettingsFromFilter(f);
        } catch (InvalidSettingsException ise) {
        // ignore failure
        }
    } else {
    // we silently ignore unsupported filter and leave default settings.
    }
    filterSelectionChanged(actionCommand);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) RowNoRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RowNoRowFilter) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) RowIDRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RowIDRowFilter) ColValFilterOldObsolete(org.knime.base.node.preproc.filter.row.rowfilter.ColValFilterOldObsolete) AttrValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter) IRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.IRowFilter)

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