use of org.knime.base.node.preproc.pmml.missingval.MVColumnSettings 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();
}
Aggregations