Search in sources :

Example 1 with MVSettings

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

the class MissingValueHandlerNodeDialog method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    MVSettings mvSettings = createEmptySettings();
    for (DataType type : m_types.keySet()) {
        MissingValueHandlerFactorySelectionPanel panel = m_types.get(type);
        mvSettings.setSettingsForDataType(type, panel.getSettings());
    }
    for (Component panel : m_individualsPanel.getComponents()) {
        mvSettings.getColumnSettings().add(((ColumnHandlingFactorySelectionPanel) panel).getUpdatedSettings());
    }
    mvSettings.saveToSettings(settings);
}
Also used : DataType(org.knime.core.data.DataType) Component(java.awt.Component) MVSettings(org.knime.base.node.preproc.pmml.missingval.MVSettings)

Example 2 with MVSettings

use of org.knime.base.node.preproc.pmml.missingval.MVSettings 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

MVSettings (org.knime.base.node.preproc.pmml.missingval.MVSettings)2 DataType (org.knime.core.data.DataType)2 Component (java.awt.Component)1 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 MVIndividualSettings (org.knime.base.node.preproc.pmml.missingval.MVIndividualSettings)1 DataTableSpec (org.knime.core.data.DataTableSpec)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1 NotConfigurableException (org.knime.core.node.NotConfigurableException)1