Search in sources :

Example 6 with NotConfigurableException

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

the class ReadPNGFromURLConfig method loadInDialog.

/**
 * Load config in dialog.
 * @param settings To load from
 * @param in Current input spec
 * @throws NotConfigurableException If no configuration possible, e.g.
 */
void loadInDialog(final NodeSettingsRO settings, final DataTableSpec in) throws NotConfigurableException {
    m_urlColName = settings.getString("urlColumn", null);
    DataColumnSpec col = in.getColumnSpec(m_urlColName);
    if (col == null || !col.getType().isCompatible(StringValue.class)) {
        try {
            guessDefaults(in);
        } catch (InvalidSettingsException e) {
            throw new NotConfigurableException("No valid input column available");
        }
    }
    // guessDefaults inits default values, so we can use them as fallback
    m_failOnInvalid = settings.getBoolean("failIfInvalid", m_failOnInvalid);
    m_newColumnName = settings.getString("newColumnName", m_newColumnName);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 7 with NotConfigurableException

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

the class DBGroupByNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    if (specs == null || specs.length < 1 || specs[0] == null) {
        throw new NotConfigurableException("No input spec available");
    }
    final DatabasePortObjectSpec dbspec = (DatabasePortObjectSpec) specs[0];
    final DataTableSpec spec = dbspec.getDataTableSpec();
    try {
        m_columnNamePolicy.loadSettingsFrom(settings);
    } catch (final InvalidSettingsException e) {
        throw new NotConfigurableException(e.getMessage());
    }
    m_aggregationPanel.loadSettingsFrom(settings, dbspec, spec);
    m_groupCol.loadSettingsFrom(settings, new DataTableSpec[] { spec });
    columnsChanged();
}
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 8 with NotConfigurableException

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

the class DBGroupByAggregationPanel method loadSettingsFrom.

/**
 * @param settings The settings to load from
 * @param dbspec {@link DatabasePortObjectSpec} with the database information e.g. the supported
 * {@link DBAggregationFunction}s
 * @param spec The spec containing the available columns
 * @throws NotConfigurableException if the connection settings cannot retrieved from the
 * {@link DatabasePortObjectSpec}.
 */
void loadSettingsFrom(final NodeSettingsRO settings, final DatabasePortObjectSpec dbspec, final DataTableSpec spec) throws NotConfigurableException {
    m_dbspec = dbspec;
    try {
        final DatabaseUtility utility = m_dbspec.getConnectionSettings(null).getUtility();
        final Collection<DBAggregationFunction> aggregationFunctions = utility.getAggregationFunctions();
        setSupportedAggregationFunctions(aggregationFunctions);
    } catch (final InvalidSettingsException e) {
        throw new NotConfigurableException(e.getMessage());
    }
    m_spec = spec;
    m_aggregatedColumnsModel.setRowCount(0);
    String[] columns = settings.getStringArray(DBGroupByNodeModel.CFG_AGGREGATED_COLUMNS, new String[0]);
    String[] methods = settings.getStringArray(DBGroupByNodeModel.CFG_AGGREGATION_METHODS, new String[0]);
    for (int i = 0; i < columns.length; i++) {
        m_aggregatedColumnsModel.addRow(new Object[] { columns[i], methods[i] });
    }
    refreshAvailableColumns();
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DatabaseUtility(org.knime.core.node.port.database.DatabaseUtility) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) DBAggregationFunction(org.knime.core.node.port.database.aggregation.DBAggregationFunction)

Example 9 with NotConfigurableException

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

the class LinRegLearnerNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    // must check if there are at least two numeric columns
    int numColsCount = 0;
    DataTableSpec dts = (DataTableSpec) specs[0];
    for (DataColumnSpec c : dts) {
        if (c.getType().isCompatible(DoubleValue.class)) {
            numColsCount++;
            if (numColsCount >= 2) {
                break;
            }
        }
    }
    if (numColsCount < 2) {
        throw new NotConfigurableException("Too few numeric columns " + "(need at least 2): " + numColsCount);
    }
    boolean includeAll = settings.getBoolean(LinRegLearnerNodeModel.CFG_VARIATES_USE_ALL, false);
    String[] includes = settings.getStringArray(LinRegLearnerNodeModel.CFG_VARIATES, new String[0]);
    String target = settings.getString(LinRegLearnerNodeModel.CFG_TARGET, null);
    boolean isCalcError = settings.getBoolean(LinRegLearnerNodeModel.CFG_CALC_ERROR, true);
    int first = settings.getInt(LinRegLearnerNodeModel.CFG_FROMROW, 1);
    int count = settings.getInt(LinRegLearnerNodeModel.CFG_ROWCNT, 10000);
    m_selectionPanel.update(dts, target);
    m_filterPanel.setKeepAllSelected(includeAll);
    // if includes list is empty, put everything into the include list
    m_filterPanel.update(dts, includes.length == 0, includes);
    // must hide the target from filter panel
    // updating m_filterPanel first does not work as the first
    // element in the spec will always be in the exclude list.
    String selected = m_selectionPanel.getSelectedColumn();
    if (selected != null) {
        DataColumnSpec colSpec = dts.getColumnSpec(selected);
        m_filterPanel.hideColumns(colSpec);
    }
    m_isCalcErrorChecker.setSelected(isCalcError);
    m_firstSpinner.setValue(first);
    m_countSpinner.setValue(count);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Example 10 with NotConfigurableException

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

the class CategoryToNumberNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    m_settings.loadSettingsForDialog(settings);
    String[] included = null != m_settings.getIncludedColumns() ? m_settings.getIncludedColumns() : new String[0];
    m_includedColumns.update((DataTableSpec) specs[0], false, included);
    if (m_includedColumns.getExcludedColumnSet().size() + m_includedColumns.getIncludedColumnSet().size() == 0) {
        throw new NotConfigurableException("No column in " + "the input compatible to \"StringValue\".");
    }
    m_includedColumns.setKeepAllSelected(m_settings.getIncludeAll());
    m_appendColums.setSelected(m_settings.getAppendColumns());
    m_columnSuffix.setText(m_settings.getColumnSuffix());
    m_columnSuffix.setEnabled(m_appendColums.isSelected());
    m_startIndex.setValue(m_settings.getStartIndex());
    m_increment.setValue(m_settings.getIncrement());
    m_maxCategories.setValue(m_settings.getMaxCategories());
    if (!m_settings.getDefaultValue().isMissing()) {
        IntValue value = (IntValue) m_settings.getDefaultValue();
        m_defaultValue.setText(Integer.toString(value.getIntValue()));
    } else {
        m_defaultValue.setText("");
    }
    if (!m_settings.getMapMissingTo().isMissing()) {
        IntValue value = (IntValue) m_settings.getMapMissingTo();
        m_mapMissingTo.setText(Integer.toString(value.getIntValue()));
    } else {
        m_mapMissingTo.setText("");
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) IntValue(org.knime.core.data.IntValue)

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