Search in sources :

Example 26 with NotConfigurableException

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

the class ColumnResorterNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    // Check input spec
    if (specs[0] == null || specs[0].getNumColumns() == 0) {
        throw new NotConfigurableException("No input table found or no columns found in input table! " + "Please connect the node first or check input table.");
    }
    DataTableSpec spec = specs[0];
    boolean addedDummy = false;
    try {
        // get settings
        m_order = settings.getStringArray(ColumnResorterConfigKeys.COLUMN_ORDER);
        m_listModel.removeAllElements();
        m_origColOrder.clear();
        // get available col names
        List<String> colNames = new ArrayList<String>();
        List<String> additionalColNames = new ArrayList<String>();
        for (int i = 0; i < spec.getNumColumns(); i++) {
            colNames.add(spec.getColumnSpec(i).getName());
            additionalColNames.add(spec.getColumnSpec(i).getName());
            m_origColOrder.add(spec.getColumnSpec(i));
        }
        // Get all column names which are in spec but not in order
        additionalColNames.removeAll(Arrays.asList(m_order));
        // cols are already sorter
        if (m_order.length > 0) {
            for (String col : m_order) {
                if (DataColumnSpecListDummyCellRenderer.UNKNOWN_COL_DUMMY.getName().equals(col)) {
                    // add place holder
                    m_listModel.addElement(DataColumnSpecListDummyCellRenderer.UNKNOWN_COL_DUMMY);
                    addedDummy = true;
                    // now all new columns need to be added
                    for (String newCol : additionalColNames) {
                        m_listModel.addElement(spec.getColumnSpec(newCol));
                        colNames.remove(newCol);
                    }
                // add "old" columns
                } else {
                    DataColumnSpec colSpec = spec.getColumnSpec(col);
                    if (colSpec != null) {
                        m_listModel.addElement(colSpec);
                        colNames.remove(col);
                    }
                }
            }
            // any cols left?
            for (String col : colNames) {
                m_listModel.addElement(spec.getColumnSpec(col));
            }
        // cols are not sorted, available cols have to be added initially
        } else {
            for (String col : colNames) {
                m_listModel.addElement(spec.getColumnSpec(col));
            }
        }
        if (!addedDummy) {
            // add dummy element "<any unknown new column>".
            m_listModel.addElement(DataColumnSpecListDummyCellRenderer.UNKNOWN_COL_DUMMY);
        }
    } catch (InvalidSettingsException e) {
    // Nothing to do ...
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ArrayList(java.util.ArrayList)

Example 27 with NotConfigurableException

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

the class NominalValueRowFilterNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
    if (specs.length == 0 || specs[0] == null) {
        throw new NotConfigurableException("No incoming columns found. " + "Please connect the node with input table!");
    }
    // get selected column
    m_selectedColumn = settings.getString(CFG_SELECTED_COL, "");
    // clear old values
    m_colAttributes.clear();
    m_columns.removeAllElements();
    // disable item state change listener while adding values
    m_columnSelection.removeItemListener(this);
    // fill the models
    for (DataColumnSpec colSpec : specs[0]) {
        if (colSpec.getType().isCompatible(NominalValue.class) && colSpec.getDomain().hasValues()) {
            m_columns.addElement(colSpec.getName());
            // create column - possible values mapping
            m_colAttributes.put(colSpec.getName(), colSpec.getDomain().getValues());
        }
    }
    // set selection
    if (m_selectedColumn != null) {
        m_columnSelection.setSelectedItem(m_selectedColumn);
        // enable item change listener again
        m_columnSelection.addItemListener(this);
    } else {
        m_columnSelection.addItemListener(this);
        m_columnSelection.setSelectedIndex(-1);
        m_columnSelection.setSelectedItem(m_columnSelection.getItemAt(0));
    }
    NominalValueFilterConfiguration config = new NominalValueFilterConfiguration(CFG_CONFIGROOTNAME);
    Set<DataCell> domain = m_colAttributes.get(m_selectedColumn);
    if (settings.containsKey(CFG_CONFIGROOTNAME)) {
        config.loadConfigurationInDialog(settings, domain);
    } else {
        // backwards compatibility
        String[] selectedAttributes = settings.getStringArray(CFG_SELECTED_ATTR, "");
        Set<String> includedAttr = new HashSet<String>();
        for (String s : selectedAttributes) {
            includedAttr.add(s);
        }
        ArrayList<String> m_included = new ArrayList<String>();
        ArrayList<String> m_excluded = new ArrayList<String>();
        if (domain != null) {
            for (DataCell dc : domain) {
                // if possible value was in the settings...
                if (includedAttr.contains(dc.toString())) {
                    // ... put it to included ...
                    m_included.add(dc.toString());
                } else {
                    // ... else to excluded
                    m_excluded.add(dc.toString());
                }
            }
        }
        config.loadDefaults(m_included.toArray(new String[m_included.size()]), m_excluded.toArray(new String[m_excluded.size()]), EnforceOption.EnforceInclusion);
    }
    m_filterPanel.loadConfiguration(config, domain);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec) NominalValueFilterConfiguration(org.knime.core.node.util.filter.nominal.NominalValueFilterConfiguration) NominalValue(org.knime.core.data.NominalValue) ArrayList(java.util.ArrayList) DataCell(org.knime.core.data.DataCell) HashSet(java.util.HashSet)

Example 28 with NotConfigurableException

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

the class LowVarFilter2NodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@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.");
    }
    List<String> defIncludes = new ArrayList<String>();
    for (DataColumnSpec s : specs[0]) {
        if (s.getType().isCompatible(DoubleValue.class)) {
            defIncludes.add(s.getName());
        }
    }
    double threshold = settings.getDouble(LowVarFilter2NodeModel.CFG_KEY_MAX_VARIANCE, 0.0);
    m_varianceSpinner.setValue(threshold);
    DataColumnSpecFilterConfiguration config = createColFilterConf();
    config.loadConfigurationInDialog(settings, spec);
    m_colFilterPanel.loadConfiguration(config, spec);
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) ArrayList(java.util.ArrayList)

Example 29 with NotConfigurableException

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

the class RegexSplitSettings method loadSettingsInDialog.

/**
 * Load model for dialog.
 * @param settings To load from.
 * @param spec Input spec
 * @throws NotConfigurableException If no matching col found
 */
void loadSettingsInDialog(final NodeSettingsRO settings, final DataTableSpec spec) throws NotConfigurableException {
    String defColumn = null;
    for (DataColumnSpec s : spec) {
        if (s.getType().isCompatible(StringValue.class)) {
            defColumn = s.getName();
        }
    }
    m_column = settings.getString("column", defColumn);
    DataColumnSpec col = spec.getColumnSpec(m_column);
    if (col == null || !col.getType().isCompatible(StringValue.class)) {
        m_column = defColumn;
    }
    m_pattern = settings.getString("pattern", "(.*)");
    m_isUnixLines = settings.getBoolean("isUnixLines", false);
    m_isCaseInsensitive = settings.getBoolean("isCaseInsensitive", false);
    m_isComments = settings.getBoolean("isComments", false);
    m_isMultiLine = settings.getBoolean("isMultiLine", false);
    m_isLiteral = settings.getBoolean("isLiteral", false);
    m_isDotAll = settings.getBoolean("isDotAll", false);
    m_isUniCodeCase = settings.getBoolean("isUniCodeCase", false);
    m_isCanonEQ = settings.getBoolean("isCanonEQ", false);
    if (m_column == null) {
        throw new NotConfigurableException("No string compatible column in input table");
    }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataColumnSpec(org.knime.core.data.DataColumnSpec)

Example 30 with NotConfigurableException

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

the class InteractiveHistogramProperties method updateColumnSelection.

/**
 * {@inheritDoc}
 */
@Override
public void updateColumnSelection(final DataTableSpec spec, final String xColName, final Collection<ColorColumn> aggrColumns, final AggregationMethod aggrMethod) {
    try {
        if (xColName == null) {
            final String er = "No binning column available";
            LOGGER.warn(er);
            throw new IllegalArgumentException(er);
        }
        // remove all action listener to avoid unnecessary calls
        final ActionListener[] listeners = m_xCol.getActionListeners();
        for (ActionListener listener : listeners) {
            m_xCol.removeActionListener(listener);
        }
        m_xCol.setEnabled(true);
        m_xCol.update(spec, xColName);
        for (ActionListener listener : listeners) {
            m_xCol.addActionListener(listener);
        }
    } catch (final NotConfigurableException e) {
        m_xCol.setEnabled(false);
    }
    m_aggrCol.update(spec, aggrColumns);
    // set the values for the y axis select box
    if (m_aggrCol.getNoOfColumns() < 1) {
        // if we have no aggregation columns disable it
        m_aggrCol.setEnabled(false);
    } else {
        // enable the select box only if it contains at least one value
        m_aggrCol.setEnabled(true);
    }
// enable or disable the aggregation method buttons depending if
// aggregation columns available or not
// for (final Enumeration<AbstractButton> buttons = m_aggrMethButtonGrp
// .getElements(); buttons.hasMoreElements();) {
// final AbstractButton button = buttons.nextElement();
// button.setEnabled(m_aggrCol.getModel().getSize() > 0);
// }
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) ActionListener(java.awt.event.ActionListener)

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