changeset 794:40269a176cd2

Set default values in the BooleanPanel, TextProvider and AutoIntegerPanel. flys-client/trunk@2303 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 07 Jul 2011 14:46:55 +0000 (2011-07-07)
parents 4497d19c22fd
children 68b8770af6c5
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/TextProvider.java
diffstat 4 files changed, 42 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Jul 07 14:12:21 2011 +0000
+++ b/flys-client/ChangeLog	Thu Jul 07 14:46:55 2011 +0000
@@ -1,3 +1,11 @@
+2011-07-07  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/TextProvider.java,
+	  src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java:
+	  Default values provided by the data list used to create the panels are
+	  set now.
+
 2011-07-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java	Thu Jul 07 14:12:21 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/AutoIntegerPanel.java	Thu Jul 07 14:46:55 2011 +0000
@@ -45,6 +45,8 @@
         layout.addMember(submit);
         layout.setMembersMargin(10);
 
+        initDefaultValues(dataList);
+
         return layout;
     }
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java	Thu Jul 07 14:12:21 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java	Thu Jul 07 14:46:55 2011 +0000
@@ -48,6 +48,8 @@
         layout.addMember(getNextButton());
         layout.setMembersMargin(10);
 
+        initDefaultValues(dataList);
+
         return layout;
     }
 
@@ -58,6 +60,20 @@
 
 
     @Override
+    protected void initDefaultValues(DataList dataList) {
+        Data     data = dataList.get(0);
+        DataItem item = data.getDefault();
+
+        String value = item.getStringValue();
+        Boolean bool = Boolean.valueOf(value);
+
+        if (bool) {
+            form.setValue(getFieldName(), bool);
+        }
+    }
+
+
+    @Override
     protected FieldType getFieldType() {
         return FieldType.BOOLEAN;
     }
@@ -79,7 +95,7 @@
     protected String getValueAsString() {
         Boolean aBool = (Boolean) form.getValue(getFieldName());
 
-        return aBool.toString();
+        return aBool != null ? aBool.toString() : "false";
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TextProvider.java	Thu Jul 07 14:12:21 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TextProvider.java	Thu Jul 07 14:46:55 2011 +0000
@@ -47,7 +47,11 @@
 
     @Override
     public Canvas create(DataList dataList) {
-        return createForm();
+        Canvas form = createForm();
+
+        initDefaultValues(dataList);
+
+        return form;
     }
 
 
@@ -83,6 +87,16 @@
     }
 
 
+    protected void initDefaultValues(DataList dataList) {
+        Data     data = dataList.get(0);
+        DataItem item = data.getDefault();
+
+        String value = item.getStringValue();
+
+        form.setValue(getFieldName(), value);
+    }
+
+
     protected DataSourceField createField() {
         return new DataSourceField(getFieldName(), getFieldType());
     }

http://dive4elements.wald.intevation.org