Search in sources :

Example 11 with NotConfigurableException

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

the class TreeOptionsPanel method newTargetSelected.

/**
 */
private void newTargetSelected() {
    DataTableSpec filtered = m_attributePanel.getCurrentAttributeSpec();
    String prevSelected = m_hardCodedRootColumnBox.getSelectedColumn();
    try {
        m_hardCodedRootColumnBox.update(filtered, prevSelected);
    } catch (NotConfigurableException nfe) {
        LOGGER.coding("Unable to update column list upon target " + "selection change", nfe);
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec)

Example 12 with NotConfigurableException

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

the class RuleEngineNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    if (specs == null || specs.length == 0 || specs[0] == null || specs[0].getNumColumns() == 0) {
        throw new NotConfigurableException("No columns available!");
    }
    m_ruleEditor.setText("");
    m_spec = specs[0];
    m_variableModel.clear();
    for (DataColumnSpec s : getVariables()) {
        m_variableModel.addElement(s);
    }
    m_operatorModel.clear();
    for (String op : getOperators()) {
        m_operatorModel.addElement(op);
    }
    RuleEngineSettings ruleSettings = new RuleEngineSettings();
    ruleSettings.loadSettingsForDialog(settings);
    String defaultLabel = ruleSettings.getDefaultLabel();
    m_defaultLabelEditor.setText(defaultLabel);
    m_defaultLabelIsColumn.setSelected(ruleSettings.getDefaultLabelIsColumn());
    String newColName = ruleSettings.getNewColName();
    m_newColumnName.setText(newColName);
    m_ruleModel.clear();
    for (String rs : ruleSettings.rules()) {
        try {
            Rule r = new Rule(rs, m_spec);
            m_ruleModel.addElement(r);
        } catch (ParseException e) {
            LOGGER.warn("Rule '" + rs + "' removed, because of " + e.getMessage());
        }
    }
    m_lastUsedTextfield = null;
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec) ParseException(java.text.ParseException)

Example 13 with NotConfigurableException

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

the class LinRegLinePlotterProperties method update.

/**
 * Updates the selection boxes with the new
 * {@link org.knime.core.data.DataTableSpec} and selects the passed indices.
 * Takes care, that the x column selection box only contains the columns
 * used for model calculation. For this purpose the ItemListeners of this
 * box are removed and afterwards added again in order to avoid event loops.
 *
 * @param spec the new data table spec.
 * @param xPreSelect the x column index (-1 if unknown)
 * @param yPreSelect the y column (-1 if unknown)
 */
@Override
public void update(final DataTableSpec spec, final int xPreSelect, final int yPreSelect) {
    try {
        m_xSelector.update(spec, spec.getColumnSpec(xPreSelect).getName(), true);
        m_ySelector.update(spec, spec.getColumnSpec(yPreSelect).getName(), true);
        // store the old selected one
        Object oldSelected = m_xSelector.getSelectedItem();
        // suppress events
        ItemListener[] listeners = m_xSelector.getItemListeners();
        for (ItemListener listener : listeners) {
            m_xSelector.removeItemListener(listener);
        }
        if (m_includs != null) {
            // cleanup -> remove all items and add only the included
            m_xSelector.removeAllItems();
            List<String> survivors = Arrays.asList(m_includs);
            for (DataColumnSpec colSpec : spec) {
                if (!colSpec.getName().equals(m_targetColumn) && survivors.contains(colSpec.getName())) {
                    m_xSelector.addItem(colSpec);
                }
            }
            // restore the previously selected
            m_xSelector.setSelectedItem(oldSelected);
            for (ItemListener listener : listeners) {
                m_xSelector.addItemListener(listener);
            }
        }
    } catch (NotConfigurableException e) {
        LOGGER.warn(e.getMessage(), e);
    }
    DataColumnSpec x = (DataColumnSpec) m_xSelector.getSelectedItem();
    DataColumnSpec y = (DataColumnSpec) m_ySelector.getSelectedItem();
    m_ySelector.setEnabled(false);
    updateRangeSpinner(x, y);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec) ItemListener(java.awt.event.ItemListener)

Example 14 with NotConfigurableException

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

the class PolyRegLineScatterPlotter method modelChanged.

/**
 * This method must be called if the model has changed. It updates the
 * plotter to show the new model's values.
 */
public void modelChanged() {
    DataTable data = m_model.getDataArray(0);
    m_viewData = m_model.getViewData();
    if (data != null) {
        final DataTableSpec origSpec = data.getDataTableSpec();
        final MyProperties props = (MyProperties) getProperties();
        DataColumnSpec[] colSpecs = new DataColumnSpec[origSpec.getNumColumns() - 1];
        int i = 0;
        for (DataColumnSpec cs : origSpec) {
            if (!m_viewData.targetColumn.equals(cs.getName())) {
                colSpecs[i++] = cs;
            } else {
                m_yColumnSpec = cs;
                getYAxis().setCoordinate(Coordinate.createCoordinate(cs));
            }
        }
        m_xColumnSpec = colSpecs[0];
        getXAxis().setCoordinate(Coordinate.createCoordinate(colSpecs[0]));
        m_filteredSpec = new DataTableSpec(colSpecs);
        try {
            props.m_xColumn.update(m_filteredSpec, colSpecs[0].getName());
        } catch (NotConfigurableException ex) {
            // cannot happen
            assert false : ex.getMessage();
        }
        reset();
        updatePaintModel();
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTable(org.knime.core.data.DataTable) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Example 15 with NotConfigurableException

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

the class GradientBoostingLearnerConfiguration method loadInDialog.

/**
 * {@inheritDoc}
 */
@Override
public void loadInDialog(final NodeSettingsRO settings, final DataTableSpec inSpec) throws NotConfigurableException {
    super.loadInDialog(settings, inSpec);
    String colSamplingModeString = settings.getString(KEY_COLUMN_SAMPLING_MODE, null);
    if (colSamplingModeString == null) {
        try {
            setColumnSamplingMode(ColumnSamplingMode.None);
        } catch (InvalidSettingsException e) {
            throw new NotConfigurableException("Loading column sampling mode failed", e);
        }
    }
    setDataSelectionWithReplacement(settings.getBoolean(KEY_IS_DATA_SELECTION_WITH_REPLACEMENT, false));
    try {
        setMaxLevels(settings.getInt(KEY_MAX_LEVELS, 4));
    } catch (InvalidSettingsException e) {
        throw new NotConfigurableException("Loading the maximal tree depth failed.", e);
    }
    setUseDifferentAttributesAtEachNode(settings.getBoolean(KEY_IS_USE_DIFFERENT_ATTRIBUTES_AT_EACH_NODE, false));
    m_learningRate = settings.getDouble(KEY_LEARNINGRATE, DEF_LEARNINGRATE);
    m_alphaFraction = settings.getDouble(KEY_ALPHA_FRACTION, DEF_ALPHA_FRACTION);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

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