[Schmitzm-commits] r2308 - trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Sat May 11 15:26:29 CEST 2013


Author: mojays
Date: 2013-05-11 15:26:28 +0200 (Sat, 11 May 2013)
New Revision: 2308

Modified:
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java
Log:
CSVPreviewPanel: value adjusting flag during CSV parameter update (from GUI fields)

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-04-28 18:59:03 UTC (rev 2307)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java	2013-05-11 13:26:28 UTC (rev 2308)
@@ -51,6 +51,7 @@
 
 import net.miginfocom.swing.MigLayout;
 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;
@@ -89,6 +90,7 @@
   protected JSpinner firstLine;
   protected JTextArea csvSource;
   protected JScrollPane csvSourceScrollPane;
+  protected ParameterChangeListener changeListener;
   
 
   /**
@@ -132,7 +134,7 @@
 
     // InputOptionListener reacts only on focus lost, so we use
     // ActionListener for ComboBoxes
-    ParameterChangeListener changeListener = new ParameterChangeListener();
+    this.changeListener = new ParameterChangeListener();
     ((JComboBox)delimiter.getInputComponent()).addActionListener(changeListener);
     ((JComboBox)quoteSign.getInputComponent()).addActionListener(changeListener);
     ((JComboBox)decimalSign.getInputComponent()).addActionListener(changeListener);
@@ -283,6 +285,7 @@
    * @param noData value indicating no data value
    */
   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 )
@@ -295,6 +298,7 @@
       this.noData.setValue(noData);
     preview.setCsvParameters(delimiter, decimalSign, quoteSign, charset, noData);
     updateSourceTab();
+    changeListener.setValueIsAdjusting(false);
   }
 
   /**
@@ -304,7 +308,11 @@
    *
    */
   protected class ParameterChangeListener implements ActionListener, ChangeListener, DocumentListener {
+    protected boolean valueIsAdjusting = false;
+    
     protected void invokeLaterCsvParametersUpdate() {
+      if ( getValueIsAdjusting() )
+        return;
       SwingUtilities.invokeLater( new Runnable() {
         @Override
         public void run() {
@@ -319,6 +327,20 @@
     }
     
     /**
+     * Returns whether listener is currently adjusting.
+     */
+    public boolean getValueIsAdjusting() {
+      return valueIsAdjusting;
+    }
+
+    /**
+     * Sets whether listener is currently adjusting.
+     */
+    public void setValueIsAdjusting(boolean valueIsAdjusting) {
+      this.valueIsAdjusting = valueIsAdjusting;
+    }
+
+    /**
      * Reacts on {@link JComboBox} value changes with update of preview
      * table.
      */



More information about the Schmitzm-commits mailing list