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

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 18 15:04:35 CEST 2012


Author: mojays
Date: 2012-04-18 15:04:35 +0200 (Wed, 18 Apr 2012)
New Revision: 1958

Added:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/WarningException.java
Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
   trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java
Log:
LangUtil.parseDate(.): improvement/workaround to handle "yyyy-mm-dd" and "dd-mm-yyyy" correctly
CSVPreviewPanel: maximum for first preview line increased from 1000 to 9999
new WarningException

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-04-18 10:01:44 UTC (rev 1957)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-04-18 13:04:35 UTC (rev 1958)
@@ -473,6 +473,16 @@
 			dateStr = dateStr.trim();
 			for (DateFormat format : formats)
 				try {
+				    if ( format instanceof SimpleDateFormat ) {
+				      // Datum im Format "dd-mm-yyyy" verursacht fuer Format 
+				      // "yyyy-mm-dd" KEINE Exception sondern fuehrt zu falschem Datum
+				      // --> Pruefen, ob (erste) Position des "-" in Pattern mit (erster)
+				      //     Position des "-" im Datums-String uebereinstimmt.
+				      String pattern = ((SimpleDateFormat)format).toPattern();
+				      if ( pattern.indexOf('-') != dateStr.indexOf('-') ||
+				           pattern.indexOf('.') != dateStr.indexOf('.') )
+				        continue;
+				    }
 					Date date = format.parse(dateStr);
 					return date;
 				} catch (Exception err) {

Added: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/WarningException.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/WarningException.java	                        (rev 0)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/WarningException.java	2012-04-18 13:04:35 UTC (rev 1958)
@@ -0,0 +1,54 @@
+/**
+ * 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.lang;
+
+/**
+ * {@link Exception} to indicate a warning. This exception can be caught
+ * to not cancel a process (e.g. an import) completely but only partly (e.g.
+ * for one record).
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class WarningException extends RuntimeException {
+
+  /**
+   * Creates a new exception.
+   */
+  public WarningException() {
+    super();
+  }
+
+  /**
+   * Creates a new exception.
+   */
+  public WarningException(String message) {
+    super(message);
+  }
+}

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	2012-04-18 10:01:44 UTC (rev 1957)
+++ trunk/schmitzm-excelcsv/src/main/java/de/schmitzm/csv/gui/CSVPreviewPanel.java	2012-04-18 13:04:35 UTC (rev 1958)
@@ -123,7 +123,7 @@
     limitCaption       = new JLabel( CsvUtil.R("CSVPreviewPanel.preview.limit.label")+":" );
     limit              = SwingUtil.createIntSpinner(-1, 1000, preview.getPreviewLimit());
     firstLineCaption   = new JLabel( CsvUtil.R("CSVPreviewPanel.preview.firstLine.label")+":" );
-    firstLine          = SwingUtil.createIntSpinner(1, 1000, 1);
+    firstLine          = SwingUtil.createIntSpinner(1, 9999, 1);
     csvSource          = new JTextArea();
     csvSource.setEditable(false);
     csvSource.setLineWrap(false);



More information about the Schmitzm-commits mailing list