Search in sources :

Example 1 with FileOverwritePolicy

use of org.knime.base.node.io.csvwriter.FileWriterNodeSettings.FileOverwritePolicy in project knime-core by knime.

the class CSVWriterNodeDialog method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    FileWriterNodeSettings values = new FileWriterNodeSettings();
    values.setFileName(m_filePanel.getSelectedFile().trim());
    values.setWriteColumnHeader(m_colHeaderChecker.isSelected());
    values.setSkipColHeaderIfFileExists(m_colHeaderWriteSkipOnAppend.isSelected());
    values.setWriteRowID(m_rowHeaderChecker.isSelected());
    FileOverwritePolicy overwritePolicy;
    if (m_overwritePolicyAppendButton.isSelected()) {
        overwritePolicy = FileOverwritePolicy.Append;
    } else if (m_overwritePolicyOverwriteButton.isSelected()) {
        overwritePolicy = FileOverwritePolicy.Overwrite;
    } else {
        overwritePolicy = FileOverwritePolicy.Abort;
    }
    values.setFileOverwritePolicy(overwritePolicy);
    values.setGzipOutput(m_useGzipChecker.isSelected());
    m_quotePanel.saveValuesFromPanelInto(values);
    m_advancedPanel.saveValuesFromPanelInto(values);
    m_commentPanel.saveValuesFromPanelInto(values);
    m_decSeparatorPanel.saveValuesFromPanelInto(values);
    String errMsg = m_encodingPanel.checkSettings();
    if (errMsg != null) {
        throw new InvalidSettingsException(errMsg);
    }
    FileReaderNodeSettings s = new FileReaderNodeSettings();
    m_encodingPanel.overrideSettings(s);
    values.setCharacterEncoding(s.getCharsetName());
    values.saveSettingsTo(settings);
    m_filePanel.addToHistory();
}
Also used : FileReaderNodeSettings(org.knime.base.node.io.filereader.FileReaderNodeSettings) FileOverwritePolicy(org.knime.base.node.io.csvwriter.FileWriterNodeSettings.FileOverwritePolicy) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Aggregations

FileOverwritePolicy (org.knime.base.node.io.csvwriter.FileWriterNodeSettings.FileOverwritePolicy)1 FileReaderNodeSettings (org.knime.base.node.io.filereader.FileReaderNodeSettings)1 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)1