Search in sources :

Example 1 with MVIndividualSettings

use of org.knime.base.node.preproc.pmml.missingval.MVIndividualSettings in project knime-core by knime.

the class MissingValueHandlerFactorySelectionPanel method getSettings.

/**
 * Creates and returns a new settings object for the settings made by the user.
 * @return the settings made by the user
 * @throws InvalidSettingsException if a user defined panel throws an error while saving its settings.
 */
public MVIndividualSettings getSettings() throws InvalidSettingsException {
    MissingCellHandlerFactory currentFactory = getSelectedFactory();
    MVIndividualSettings settings = new MVIndividualSettings(currentFactory, m_handlerFactoryManager);
    if (m_valueHandlerPanels.containsKey(currentFactory.getID())) {
        m_valueHandlerPanels.get(currentFactory.getID()).saveSettingsTo(settings.getSettings());
    }
    return settings;
}
Also used : MissingCellHandlerFactory(org.knime.base.node.preproc.pmml.missingval.MissingCellHandlerFactory) MVIndividualSettings(org.knime.base.node.preproc.pmml.missingval.MVIndividualSettings)

Example 2 with MVIndividualSettings

use of org.knime.base.node.preproc.pmml.missingval.MVIndividualSettings in project knime-core by knime.

the class MissingValueHandlerNodeDialog method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    MVSettings mvSettings = createEmptySettings();
    m_specs = specs;
    DataTableSpec spec = (DataTableSpec) specs[0];
    StringBuffer warning = new StringBuffer();
    if (spec.getNumColumns() == 0) {
        throw new NotConfigurableException("There are no columns for missing value replacement available.");
    }
    m_searchableListModifier = m_searchableListPanel.update(spec);
    try {
        mvSettings.loadSettings(settings, true);
    } catch (Exception e) {
        if (warning.length() > 0) {
            warning.append("\n");
        }
        warning.append("The settings are malformed and had to be reset");
        mvSettings = new MVSettings(spec);
    }
    m_warnings.setText(warning.toString());
    m_types = new LinkedHashMap<DataType, MissingValueHandlerFactorySelectionPanel>();
    for (int i = 0; i < spec.getNumColumns(); i++) {
        m_types.put(spec.getColumnSpec(i).getType(), null);
    }
    m_individualsPanel.removeAll();
    for (MVColumnSettings colSetting : mvSettings.getColumnSettings()) {
        ColumnHandlingFactorySelectionPanel p = new ColumnHandlingFactorySelectionPanel(colSetting, specs, 0, getHandlerFactoryManager());
        addToIndividualPanel(p);
    }
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    m_typeSettingsPanel.removeAll();
    for (DataType type : m_types.keySet()) {
        gbc.gridx = 0;
        gbc.ipadx = 10;
        JLabel l = new JLabel(type.toPrettyString());
        m_typeSettingsPanel.add(l, gbc);
        gbc.gridx = 1;
        gbc.ipadx = 0;
        MVIndividualSettings s = mvSettings.getSettingsForDataType(type);
        // but check anyways and fall back to do nothing factory
        if (s == null) {
            s = new MVIndividualSettings(getHandlerFactoryManager());
        }
        MissingValueHandlerFactorySelectionPanel p = new MissingValueHandlerFactorySelectionPanel(type, s, getHandlerFactoryManager(), specs);
        p.setBorder(BorderFactory.createBevelBorder(1));
        p.addPropertyChangeListener(new FactoryChangedListener());
        m_typeSettingsPanel.add(p, gbc);
        m_types.put(type, p);
        gbc.gridy++;
    }
    m_scrollPane.setPreferredSize(new Dimension(m_defaultsPanel.getPreferredSize().width + 20, 500));
    updatePMMLLabelColor();
}
Also used : NotConfigurableException(org.knime.core.node.NotConfigurableException) DataTableSpec(org.knime.core.data.DataTableSpec) GridBagConstraints(java.awt.GridBagConstraints) MVIndividualSettings(org.knime.base.node.preproc.pmml.missingval.MVIndividualSettings) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NotConfigurableException(org.knime.core.node.NotConfigurableException) MVColumnSettings(org.knime.base.node.preproc.pmml.missingval.MVColumnSettings) DataType(org.knime.core.data.DataType) MVSettings(org.knime.base.node.preproc.pmml.missingval.MVSettings)

Aggregations

MVIndividualSettings (org.knime.base.node.preproc.pmml.missingval.MVIndividualSettings)2 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 JLabel (javax.swing.JLabel)1 MVColumnSettings (org.knime.base.node.preproc.pmml.missingval.MVColumnSettings)1 MVSettings (org.knime.base.node.preproc.pmml.missingval.MVSettings)1 MissingCellHandlerFactory (org.knime.base.node.preproc.pmml.missingval.MissingCellHandlerFactory)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 DataType (org.knime.core.data.DataType)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NotConfigurableException (org.knime.core.node.NotConfigurableException)1