diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleArrayPanel.java @ 9404:bc9a45d2b1fa

common time range for gauges incl. error messages
author gernotbelger
date Wed, 15 Aug 2018 13:59:09 +0200
parents 3141f0e7314e
children c86ae5562e68
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleArrayPanel.java	Wed Aug 15 13:22:00 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleArrayPanel.java	Wed Aug 15 13:59:09 2018 +0200
@@ -28,6 +28,8 @@
 
     protected TextItem ti;
 
+    private final StaticTextItem errorItem = new StaticTextItem("error");
+
     private String title;
 
     /** The constant input field name. */
@@ -52,29 +54,41 @@
      * @param focusHandler
      *            The FocueHandler that is used to valide the input.
      */
+
     public DoubleArrayPanel(final String title, final double[] values, final BlurHandler blurHandler, final FocusHandler focusHandler,
-            final TitleOrientation titleOrientation) {
+            final TitleOrientation titleOrientation, final String errorMsg) {
+
         this.title = title;
         this.ti = new TextItem(FIELD_NAME);
         final StaticTextItem sti = new StaticTextItem("staticarray");
+        sti.setColSpan(2);
+
+        this.errorItem.setTitle("");
+        if (errorMsg != null)
+            this.errorItem.setValue(errorMsg);
+
+        this.errorItem.setShowTitle(false);
+        this.errorItem.setVisible(true);
+        this.errorItem.setColSpan(2);
+        sti.setShowTitle(false);
+        sti.setValue(title);
+        sti.setColSpan(1);
 
         this.ti.setShowTitle(false);
-        sti.setShowTitle(false);
-        sti.setValue(title);
-
+        this.ti.setColSpan(1);
         this.ti.addBlurHandler(blurHandler);
         if (focusHandler != null) {
             this.ti.addFocusHandler(focusHandler);
         }
 
         if (titleOrientation == TitleOrientation.RIGHT) {
-            setFields(this.ti, sti);
+            setFields(this.ti, sti, this.errorItem);
         } else {
-            setFields(sti, this.ti);
+            setFields(sti, this.ti, this.errorItem);
         }
 
         setTitleOrientation(titleOrientation);
-        setNumCols(2);
+        setNumCols(5);
 
         if (values == null) {
             return;
@@ -96,6 +110,12 @@
         }
 
         this.ti.setValue(text.toString());
+
+    }
+
+    public DoubleArrayPanel(final String title, final double[] values, final BlurHandler blurHandler, final FocusHandler focusHandler,
+            final TitleOrientation titleOrientation) {
+        this(title, values, blurHandler, focusHandler, titleOrientation, null);
     }
 
     /**
@@ -149,6 +169,10 @@
         this.ti.setValue(current);
     }
 
+    public void setError(final String error) {
+        this.errorItem.setValue(error);
+    }
+
     public boolean validateForm() {
         return validateForm(this.ti);
     }

http://dive4elements.wald.intevation.org