Search in sources :

Example 11 with Delimiter

use of org.knime.core.util.tokenizer.Delimiter in project knime-core by knime.

the class IgnoreDelimsPanel method overrideSettings.

/**
 * Transfers the current settings from the panel in the passed object.
 * Overwriting the corresponding values in the object.
 *
 * @param settings the settings object to fill in the currently set values
 * @return true if the new settings are different from the one passed in.
 */
boolean overrideSettings(final FileReaderNodeSettings settings) {
    boolean ignoreEm = m_ignoreThem.isSelected();
    if (ignoreEm != settings.ignoreDelimsAtEORUserValue()) {
        // set the user set value - only if he changed it.
        settings.setIgnoreDelimsAtEndOfRowUserValue(ignoreEm);
        // (!)
        for (Delimiter delim : settings.getAllDelimiters()) {
            String delStr = delim.getDelimiter();
            if (!settings.isRowDelimiter(delStr, false)) {
                if (delStr.equals(" ") || delStr.equals("\t")) {
                    settings.setIgnoreEmptyTokensAtEndOfRow(ignoreEm);
                    break;
                }
            }
        }
        // also fix the delimiter settings
        // I guess that is what they would expect...?
        settings.setDelimiterUserSet(true);
        // need to re-analyze file with settings changed
        return true;
    }
    // no need to re-analyze, no settings changed here.
    return false;
}
Also used : Delimiter(org.knime.core.util.tokenizer.Delimiter)

Aggregations

Delimiter (org.knime.core.util.tokenizer.Delimiter)11 DefaultComboBoxModel (javax.swing.DefaultComboBoxModel)4 Dimension (java.awt.Dimension)2 GridLayout (java.awt.GridLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 Box (javax.swing.Box)2 BoxLayout (javax.swing.BoxLayout)2 JButton (javax.swing.JButton)2 JCheckBox (javax.swing.JCheckBox)2 JComboBox (javax.swing.JComboBox)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JTextField (javax.swing.JTextField)2 DocumentEvent (javax.swing.event.DocumentEvent)2 DocumentListener (javax.swing.event.DocumentListener)2 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1