[PATCH] (issue1608) Determine field type with the first non empty element

Wald Commits scm-commit at wald.intevation.org
Thu Mar 26 17:34:12 CET 2015


# HG changeset patch
# User Andre Heinecke <andre.heinecke at intevation.de>
# Date 1427387635 -3600
# Node ID 5533aa8f8b73ccb08cf8eb45990fc87ace8eea95
# Parent  b30068e92757caa82c889a9101d87c6719e52818
(issue1608) Determine field type with the first non empty element

diff -r b30068e92757 -r 5533aa8f8b73 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java	Thu Mar 26 17:11:36 2015 +0100
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/TableDataPanel.java	Thu Mar 26 17:33:55 2015 +0100
@@ -141,7 +141,6 @@
         }
 
         String[] header      = list.get(0);
-        String[] firstValues = list.get(1);
         String[] displayField = new String[header.length];
 
         ListGridField[] fields = new ListGridField[header.length];
@@ -152,16 +151,20 @@
             f.setTitle(header[i]);
 
             try {
-                nf.parse(firstValues[i]);
-                f.setType(ListGridFieldType.FLOAT);
+                /* Try to determine the type with the first
+                 * non empty element. */
+                for (int j = 1; j < list.size(); j++) {
+                    if (!list.get(j)[i].isEmpty()) {
+                        nf.parse(list.get(j)[i]);
+                        f.setType(ListGridFieldType.FLOAT);
+                        break;
+                    }
+                }
             }
             catch (NumberFormatException nfe) {
                 f.setType(ListGridFieldType.TEXT);
             }
 
-            // TODO Numerical sorting still does not work if the first values are empty (then
-            // it defaults to TEXT, currently. Shall be fixed.
-
             // To keep server-side formatting and i18n also of
             // float values, we will store the value once formatted 'as is'
             // to be displayed and once as e.g. float to allow functions like


More information about the Dive4Elements-commits mailing list