diff flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java @ 233:137daff2c732

Prepared UI elements for the location and distance input tables. flys-client/trunk@1777 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 29 Apr 2011 10:12:02 +0000
parents b92281182c6b
children 234c78a91c15
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java	Thu Apr 28 12:50:42 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java	Fri Apr 29 10:12:02 2011 +0000
@@ -20,6 +20,7 @@
     /** The message class that provides i18n strings.*/
     protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
 
+    protected TextItem ti;
 
     /** The constant input field name.*/
     public static final String FIELD_NAME = "doublearray";
@@ -39,7 +40,7 @@
         double[] values,
         BlurHandler handler)
     {
-        TextItem ti        = new TextItem(FIELD_NAME);
+        ti                 = new TextItem(FIELD_NAME);
         StaticTextItem sti = new StaticTextItem("staticarray");
 
         ti.setShowTitle(false);
@@ -76,6 +77,32 @@
 
 
     /**
+     * This method takes the double array to set the values to the textbox.
+     *
+     * @param values The double values.
+     */
+    public void setValues(double[] values) {
+        NumberFormat f = NumberFormat.getDecimalFormat();
+
+        StringBuilder text = new StringBuilder();
+        boolean firstItem  = true;
+
+        for (double val: values) {
+            if (!firstItem) {
+                text.append(" ");
+            }
+
+            text.append(f.format(val));
+
+            firstItem = false;
+        }
+
+        ti.clearValue();
+        ti.setValue(text.toString());
+    }
+
+
+    /**
      * This method validates the entered text in the location input field. If
      * there are values that doesn't represent a valid location, an error is
      * displayed.

http://dive4elements.wald.intevation.org