[Schmitzm-commits] r2349 - in trunk: schmitzm-core/src/main/java/de/schmitzm/swing schmitzm-excelcsv/src/main/java/de/schmitzm/csv schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Fri Jun 21 16:59:57 CEST 2013


Author: mojays
Date: 2013-06-21 16:59:57 +0200 (Fri, 21 Jun 2013)
New Revision: 2349

Added:
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvImportSettings.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVSettingsPanel.java
Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingWorker.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvSettings.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java
Log:
- CsvSettings: split in general settings and CsvImportSettings
- CSVPreviewPanel: CSV parameter components moved to CSVSettingsPanel
- SwingWorker: restriction to Frame as parent component changed to Component

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingWorker.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingWorker.java	2013-06-13 13:55:17 UTC (rev 2348)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/SwingWorker.java	2013-06-21 14:59:57 UTC (rev 2349)
@@ -29,6 +29,7 @@
  ******************************************************************************/
 package de.schmitzm.swing;
 
+import java.awt.Component;
 import java.awt.Frame;
 
 import javax.swing.JProgressBar;
@@ -105,7 +106,7 @@
    * @param parent     uebergeordnete GUI (kann <code>null</code> sein!)
    * @param statusMess Meldung, die im Dialog angezeigt wird
    */
-  public SwingWorker(Work work, Frame parent, String statusMess) {
+  public SwingWorker(Work work, Component parent, String statusMess) {
     this(work,parent,statusMess,0.5,0.5);
   }
 
@@ -119,7 +120,7 @@
    * @param relX       horizontale Positionierung des Dialogs relativ zum uebergeordneten Fenster
    * @param relY       vertikale Positionierung des Dialogs relativ zum uebergeordneten Fenster
    */
-  public SwingWorker(Work work, Frame parent, String statusMess, double relX, double relY) {
+  public SwingWorker(Work work, Component parent, String statusMess, double relX, double relY) {
     this(work,
          new StatusDialog(
            parent,

Added: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvImportSettings.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvImportSettings.java	                        (rev 0)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvImportSettings.java	2013-06-21 14:59:57 UTC (rev 2349)
@@ -0,0 +1,32 @@
+package de.schmitzm.csv;
+
+import java.nio.charset.Charset;
+import java.util.Map;
+
+/**
+ * This class provides parameters (in one object) which are needed for
+ * import and interpret a CSV file. 
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class CsvImportSettings extends CsvSettings {
+  protected Map<String,String> mappingFieldToCsv = null;
+  
+  /**
+   * Returns a mapping from a destination field to a CSV column name,
+   * which should be imported to the field.
+   */
+  public Map<String, String> getMappingFieldToCsv() {
+    return mappingFieldToCsv;
+  }
+
+  /**
+   * Sets a mapping from a destination field to a CSV column name,
+   * which should be imported to the field.
+   */
+  public void setMappingFieldToCsv(Map<String, String> mappingFieldToCsv) {
+    this.mappingFieldToCsv = mappingFieldToCsv;
+  }
+  
+  
+}

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvSettings.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvSettings.java	2013-06-13 13:55:17 UTC (rev 2348)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/CsvSettings.java	2013-06-21 14:59:57 UTC (rev 2349)
@@ -4,8 +4,8 @@
 import java.util.Map;
 
 /**
- * This class provides parameters (in one object) which are needed for
- * import and interprete a CSV file. 
+ * This class provides parameters (in one object) which are generally for
+ * import or export a CSV file. 
  * @author Martin O.J. Schmitz
  *
  */
@@ -25,9 +25,7 @@
   protected char decimal = DEFAULT_CSV_DECIMAL_CHAR;
   protected String nodata = DEFAULT_CSV_NODATA_VALUE;
   protected Charset charset = Charset.defaultCharset();
-  protected Map<String,String> mappingFieldToCsv = null;
   
-  
   /**
    * Returns the column delimiter.
    */
@@ -100,22 +98,4 @@
   public void setCharset(Charset charset) {
     this.charset = charset;
   }
-  
-  /**
-   * Returns a mapping from a destination field to a CSV column name,
-   * which should be imported to the field.
-   */
-  public Map<String, String> getMappingFieldToCsv() {
-    return mappingFieldToCsv;
-  }
-
-  /**
-   * Sets a mapping from a destination field to a CSV column name,
-   * which should be imported to the field.
-   */
-  public void setMappingFieldToCsv(Map<String, String> mappingFieldToCsv) {
-    this.mappingFieldToCsv = mappingFieldToCsv;
-  }
-  
-  
 }

Modified: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java	2013-06-13 13:55:17 UTC (rev 2348)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java	2013-06-21 14:59:57 UTC (rev 2349)
@@ -52,7 +52,6 @@
 import net.miginfocom.swing.MigLayout;
 import de.schmitzm.csv.CsvSettings;
 import de.schmitzm.csv.CsvUtil;
-import de.schmitzm.csv.gui.CSVPreviewPanel.ParameterChangeListener;
 import de.schmitzm.swing.JPanel;
 import de.schmitzm.swing.SwingUtil;
 import de.schmitzm.swing.TextLineNumber;
@@ -73,16 +72,18 @@
   protected JPanel  configTab;
   protected JPanel  csvSourceTab;
   
-  protected JLabel delimiterCaption;
-  protected SelectionInputOption.Combo<String> delimiter;
-  protected JLabel decimalSignCaption;
-  protected SelectionInputOption.Combo<String> decimalSign;
-  protected JLabel quoteSignCaption;
-  protected SelectionInputOption.Combo<String> quoteSign;
-  protected JLabel charsetCaption;
-  protected SelectionInputOption.Combo<Charset> charset;
-  protected JLabel noDataCaption;
-  protected ManualInputOption.Text noData;
+//  protected JLabel delimiterCaption;
+//  protected SelectionInputOption.Combo<String> delimiter;
+//  protected JLabel decimalSignCaption;
+//  protected SelectionInputOption.Combo<String> decimalSign;
+//  protected JLabel quoteSignCaption;
+//  protected SelectionInputOption.Combo<String> quoteSign;
+//  protected JLabel charsetCaption;
+//  protected SelectionInputOption.Combo<Charset> charset;
+//  protected JLabel noDataCaption;
+//  protected ManualInputOption.Text noData;
+  protected CSVSettingsPanel csvSettings;
+  
   protected JLabel previewCaption;
   protected CSVPreviewTable preview;
   protected JLabel limitCaption;
@@ -102,25 +103,26 @@
     
     
     
-    // create input options to specify the CSV parameters
-    List<InputOption<?>> csvParameterList = CsvUtil.createCSVDialogOptions(
-                                                false,
-                                                null,
-                                                CsvUtil.DEFAULT_CSV_DELIMITER,
-                                                CsvUtil.DEFAULT_CSV_QUOTESIGN,
-                                                CsvUtil.DEFAULT_CSV_DECIMALSIGN,
-                                                CsvUtil.DEFAULT_CSV_CHARSET,
-                                                CsvUtil.DEFAULT_CSV_NODATA);
-    delimiterCaption   = new JLabel( CsvUtil.R("CSVDialogOptions.delim.label")+":" );
-    delimiter          = (SelectionInputOption.Combo<String>)csvParameterList.get(1);
-    decimalSignCaption = new JLabel( CsvUtil.R("CSVDialogOptions.decimal.label")+":" );
-    decimalSign        = (SelectionInputOption.Combo<String>)csvParameterList.get(2);
-    quoteSignCaption   = new JLabel( CsvUtil.R("CSVDialogOptions.quote.label")+":" );
-    quoteSign          = (SelectionInputOption.Combo<String>)csvParameterList.get(3);
-    charsetCaption     = new JLabel( CsvUtil.R("CSVDialogOptions.charset.label")+":" );
-    charset            = (SelectionInputOption.Combo<Charset>)csvParameterList.get(4);
-    noDataCaption      = new JLabel( CsvUtil.R("CSVDialogOptions.nodata.label")+":" );
-    noData             = (ManualInputOption.Text)csvParameterList.get(5);
+//    // create input options to specify the CSV parameters
+//    List<InputOption<?>> csvParameterList = CsvUtil.createCSVDialogOptions(
+//                                                false,
+//                                                null,
+//                                                CsvUtil.DEFAULT_CSV_DELIMITER,
+//                                                CsvUtil.DEFAULT_CSV_QUOTESIGN,
+//                                                CsvUtil.DEFAULT_CSV_DECIMALSIGN,
+//                                                CsvUtil.DEFAULT_CSV_CHARSET,
+//                                                CsvUtil.DEFAULT_CSV_NODATA);
+//    delimiterCaption   = new JLabel( CsvUtil.R("CSVDialogOptions.delim.label")+":" );
+//    delimiter          = (SelectionInputOption.Combo<String>)csvParameterList.get(1);
+//    decimalSignCaption = new JLabel( CsvUtil.R("CSVDialogOptions.decimal.label")+":" );
+//    decimalSign        = (SelectionInputOption.Combo<String>)csvParameterList.get(2);
+//    quoteSignCaption   = new JLabel( CsvUtil.R("CSVDialogOptions.quote.label")+":" );
+//    quoteSign          = (SelectionInputOption.Combo<String>)csvParameterList.get(3);
+//    charsetCaption     = new JLabel( CsvUtil.R("CSVDialogOptions.charset.label")+":" );
+//    charset            = (SelectionInputOption.Combo<Charset>)csvParameterList.get(4);
+//    noDataCaption      = new JLabel( CsvUtil.R("CSVDialogOptions.nodata.label")+":" );
+//    noData             = (ManualInputOption.Text)csvParameterList.get(5);
+    csvSettings        = new CSVSettingsPanel();
     previewCaption     = new JLabel( CsvUtil.R("CSVPreviewPanel.preview.label")+":" );
     preview            = new CSVPreviewTable(10);
     limitCaption       = new JLabel( CsvUtil.R("CSVPreviewPanel.preview.limit.label")+":" );
@@ -136,25 +138,34 @@
     // InputOptionListener reacts only on focus lost, so we use
     // ActionListener for ComboBoxes
     this.changeListener = new ParameterChangeListener();
-    ((JComboBox)delimiter.getInputComponent()).addActionListener(changeListener);
-    ((JComboBox)quoteSign.getInputComponent()).addActionListener(changeListener);
-    ((JComboBox)decimalSign.getInputComponent()).addActionListener(changeListener);
-    ((JComboBox)charset.getInputComponent()).addActionListener(changeListener);
-    ((JTextField)noData.getInputComponent()).getDocument().addDocumentListener(changeListener);
+//    ((JComboBox)delimiter.getInputComponent()).addActionListener(changeListener);
+//    ((JComboBox)quoteSign.getInputComponent()).addActionListener(changeListener);
+//    ((JComboBox)decimalSign.getInputComponent()).addActionListener(changeListener);
+//    ((JComboBox)charset.getInputComponent()).addActionListener(changeListener);
+//    ((JTextField)noData.getInputComponent()).getDocument().addDocumentListener(changeListener);
+    ((JComboBox)csvSettings.delimiter.getInputComponent()).addActionListener(changeListener);
+    ((JComboBox)csvSettings.quoteSign.getInputComponent()).addActionListener(changeListener);
+    ((JComboBox)csvSettings.decimalSign.getInputComponent()).addActionListener(changeListener);
+    ((JComboBox)csvSettings.charset.getInputComponent()).addActionListener(changeListener);
+    ((JTextField)csvSettings.noData.getInputComponent()).getDocument().addDocumentListener(changeListener);
+    
+    
     limit.addChangeListener(changeListener);
     firstLine.addChangeListener(changeListener);
     
     configTab = new JPanel(new MigLayout("wrap 2","[]20[grow]","[grow]"));
-    configTab.add(delimiterCaption,"");
-    configTab.add(delimiter,"w 100::");
-    configTab.add(decimalSignCaption,"");
-    configTab.add(decimalSign,"w 100::");
-    configTab.add(quoteSignCaption,"");
-    configTab.add(quoteSign,"w 100::");
-    configTab.add(noDataCaption,"");
-    configTab.add(noData,"w 100::");
-    configTab.add(charsetCaption,"");
-    configTab.add(charset,"w 100::");
+//    configTab.add(delimiterCaption,"");
+//    configTab.add(delimiter,"w 100::");
+//    configTab.add(decimalSignCaption,"");
+//    configTab.add(decimalSign,"w 100::");
+//    configTab.add(quoteSignCaption,"");
+//    configTab.add(quoteSign,"w 100::");
+//    configTab.add(noDataCaption,"");
+//    configTab.add(noData,"w 100::");
+//    configTab.add(charsetCaption,"");
+//    configTab.add(charset,"w 100::");
+    configTab.add(csvSettings,"span 2");
+    
     configTab.add(previewCaption,"span 2");
     configTab.add(new JScrollPane(preview),"span 2, growx, growy");
     configTab.add(limitCaption,"");//"span 2, split 2");
@@ -287,16 +298,17 @@
    */
   public void setCsvParameters(Character delimiter, Character decimalSign, Character quoteSign, Charset charset, String noData) {
     changeListener.setValueIsAdjusting(true);
-    if ( delimiter != null )
-      this.delimiter.setValue(delimiter.toString());
-    if ( decimalSign != null )
-      this.decimalSign.setValue(decimalSign.toString());
-    if ( quoteSign != null )
-      this.quoteSign.setValue(quoteSign.toString());
-    if ( charset != null )
-      this.charset.setValue(charset);
-    if ( noData != null )
-      this.noData.setValue(noData);
+//    if ( delimiter != null )
+//      this.delimiter.setValue(delimiter.toString());
+//    if ( decimalSign != null )
+//      this.decimalSign.setValue(decimalSign.toString());
+//    if ( quoteSign != null )
+//      this.quoteSign.setValue(quoteSign.toString());
+//    if ( charset != null )
+//      this.charset.setValue(charset);
+//    if ( noData != null )
+//      this.noData.setValue(noData);
+    csvSettings.setCsvParameters(delimiter, decimalSign, quoteSign, charset, noData);
     preview.setCsvParameters(delimiter, decimalSign, quoteSign, charset, noData);
     updateSourceTab();
     changeListener.setValueIsAdjusting(false);
@@ -349,11 +361,16 @@
       SwingUtilities.invokeLater( new Runnable() {
         @Override
         public void run() {
-          preview.setCsvParameters(((String)delimiter.getValue()).charAt(0),
-                                   ((String)decimalSign.getValue()).charAt(0),
-                                   ((String)quoteSign.getValue()).charAt(0),
-                                   (Charset)charset.getValue(),
-                                   (String)noData.getValue());
+//          preview.setCsvParameters(((String)delimiter.getValue()).charAt(0),
+//                                   ((String)decimalSign.getValue()).charAt(0),
+//                                   ((String)quoteSign.getValue()).charAt(0),
+//                                   (Charset)charset.getValue(),
+//                                   (String)noData.getValue());
+          preview.setCsvParameters(csvSettings.getCsvDelimiter(),
+                                   csvSettings.getCsvDecimalSign(),
+                                   csvSettings.getCsvQuoteSign(),
+                                   csvSettings.getCsvCharset(),
+                                   csvSettings.getNoDataValue());
           updateSourceTab();
         }
       });
@@ -382,10 +399,10 @@
      */
     @Override
     public void actionPerformed(ActionEvent e) {
-      if ( e.getSource() == delimiter.getInputComponent() ||
-           e.getSource() == decimalSign.getInputComponent() || 
-           e.getSource() == quoteSign.getInputComponent() ||
-           e.getSource() == charset.getInputComponent() )
+      if ( e.getSource() == csvSettings.delimiter.getInputComponent() ||
+           e.getSource() == csvSettings.decimalSign.getInputComponent() || 
+           e.getSource() == csvSettings.quoteSign.getInputComponent() ||
+           e.getSource() == csvSettings.charset.getInputComponent() )
         invokeLaterCsvParametersUpdate();
     }
 
@@ -410,13 +427,13 @@
 
     @Override
     public void insertUpdate(DocumentEvent e) {
-      if ( e.getDocument() == ((JTextField)noData.getInputComponent()).getDocument() )
+      if ( e.getDocument() == ((JTextField)csvSettings.noData.getInputComponent()).getDocument() )
         invokeLaterCsvParametersUpdate();
     }
 
     @Override
     public void removeUpdate(DocumentEvent e) {
-      if ( e.getDocument() == ((JTextField)noData.getInputComponent()).getDocument() )
+      if ( e.getDocument() == ((JTextField)csvSettings.noData.getInputComponent()).getDocument() )
         invokeLaterCsvParametersUpdate();
     }
 

Added: trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVSettingsPanel.java
===================================================================
--- trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVSettingsPanel.java	                        (rev 0)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVSettingsPanel.java	2013-06-21 14:59:57 UTC (rev 2349)
@@ -0,0 +1,189 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.csv.gui;
+
+import java.nio.charset.Charset;
+import java.util.List;
+
+import javax.swing.JLabel;
+
+import net.miginfocom.swing.MigLayout;
+import de.schmitzm.csv.CsvSettings;
+import de.schmitzm.csv.CsvUtil;
+import de.schmitzm.swing.JPanel;
+import de.schmitzm.swing.input.InputOption;
+import de.schmitzm.swing.input.ManualInputOption;
+import de.schmitzm.swing.input.SelectionInputOption;
+
+/**
+ * Panel to specify CSV parameters (delimiter, decimal sign, text quote sign and
+ * Charset).
+ * @author Martin O.J. Schmitz
+ */
+public class CSVSettingsPanel extends JPanel {
+  protected JLabel delimiterCaption;
+  protected SelectionInputOption.Combo<String> delimiter;
+  protected JLabel decimalSignCaption;
+  protected SelectionInputOption.Combo<String> decimalSign;
+  protected JLabel quoteSignCaption;
+  protected SelectionInputOption.Combo<String> quoteSign;
+  protected JLabel charsetCaption;
+  protected SelectionInputOption.Combo<Charset> charset;
+  protected JLabel noDataCaption;
+  protected ManualInputOption.Text noData;
+
+  /**
+   * Creates a new panel.
+   */
+  public CSVSettingsPanel() {
+    super( new MigLayout("wrap 2","[]20[grow]","[grow]") );
+    
+    // create input options to specify the CSV parameters
+    List<InputOption<?>> csvParameterList = CsvUtil.createCSVDialogOptions(
+                                                false,
+                                                null,
+                                                CsvUtil.DEFAULT_CSV_DELIMITER,
+                                                CsvUtil.DEFAULT_CSV_QUOTESIGN,
+                                                CsvUtil.DEFAULT_CSV_DECIMALSIGN,
+                                                CsvUtil.DEFAULT_CSV_CHARSET,
+                                                CsvUtil.DEFAULT_CSV_NODATA);
+    delimiterCaption   = new JLabel( CsvUtil.R("CSVDialogOptions.delim.label")+":" );
+    delimiter          = (SelectionInputOption.Combo<String>)csvParameterList.get(1);
+    decimalSignCaption = new JLabel( CsvUtil.R("CSVDialogOptions.decimal.label")+":" );
+    decimalSign        = (SelectionInputOption.Combo<String>)csvParameterList.get(2);
+    quoteSignCaption   = new JLabel( CsvUtil.R("CSVDialogOptions.quote.label")+":" );
+    quoteSign          = (SelectionInputOption.Combo<String>)csvParameterList.get(3);
+    charsetCaption     = new JLabel( CsvUtil.R("CSVDialogOptions.charset.label")+":" );
+    charset            = (SelectionInputOption.Combo<Charset>)csvParameterList.get(4);
+    noDataCaption      = new JLabel( CsvUtil.R("CSVDialogOptions.nodata.label")+":" );
+    noData             = (ManualInputOption.Text)csvParameterList.get(5);
+
+    add(delimiterCaption,"");
+    add(delimiter,"w 100::");
+    add(decimalSignCaption,"");
+    add(decimalSign,"w 100::");
+    add(quoteSignCaption,"");
+    add(quoteSign,"w 100::");
+    add(noDataCaption,"");
+    add(noData,"w 100::");
+    add(charsetCaption,"");
+    add(charset,"w 100::");
+  }
+
+  /**
+   * Returns the CSV delimiter.
+   */
+  public char getCsvDelimiter() {
+    return ((String)delimiter.getValue()).charAt(0);
+  }
+
+  /**
+   * Returns the CSV decimal sign.
+   */
+  public char getCsvDecimalSign() {
+    return ((String)decimalSign.getValue()).charAt(0);
+  }
+
+
+  /**
+   * Returns the CSV text quote sign.
+   */
+  public char getCsvQuoteSign() {
+    return ((String)quoteSign.getValue()).charAt(0);
+  }
+
+  /**
+   * Returns the CSV {@link Charset}.
+   */
+  public Charset getCsvCharset() {
+    return (Charset)charset.getValue();
+  }
+
+  /**
+   * Returns the "no data" value.
+   */
+  public String getNoDataValue() {
+    return (String)noData.getValue();
+  }
+
+
+  /**
+   * Sets the CSV parameter. If a method parameter is {@code null}, the respective
+   * parameter remains unchanged.
+   * @param delimiter CSV delimiter.
+   * @param decimalSign decimal sign
+   * @param quoteSign CSV text quote sign
+   * @param charset {@link Charset}
+   * @param noData value indicating no data value
+   */
+  public void setCsvParameters(Character delimiter, Character decimalSign, Character quoteSign, Charset charset, String noData) {
+    if ( delimiter != null )
+      this.delimiter.setValue(delimiter.toString());
+    if ( decimalSign != null )
+      this.decimalSign.setValue(decimalSign.toString());
+    if ( quoteSign != null )
+      this.quoteSign.setValue(quoteSign.toString());
+    if ( charset != null )
+      this.charset.setValue(charset);
+    if ( noData != null )
+      this.noData.setValue(noData);
+  }
+
+  /**
+   * Sets the CSV parameter. If a method parameter is {@code null}, the respective
+   * parameter remains unchanged.
+   */
+  public void setCsvParameters(CsvSettings settings) {
+    if ( settings == null )
+      return;
+    setCsvParameters( settings.getDelimiter(),
+                      settings.getDecimal(),
+                      settings.getQuoteChar(),
+                      settings.getCharset(),
+                      settings.getNodata() );
+  }
+  
+  /**
+   * Puts the settings specified in the panel to {@link CsvSettings} object.
+   * @param settings settings object to put the settings in (if {@code null}
+   *                 a new object is created)
+   */
+  public CsvSettings copyToSettings(CsvSettings settings) {
+    if ( settings == null )
+      settings = new CsvSettings();
+    settings.setDelimiter(getCsvDelimiter());
+    settings.setDecimal(getCsvDecimalSign());
+    settings.setQuoteChar(getCsvQuoteSign());
+    settings.setCharset(getCsvCharset());
+    settings.setNodata(getNoDataValue());
+    
+    return settings;
+  }
+}



More information about the Schmitzm-commits mailing list