changeset 792:696e3404e991

Finished the panel to activate/deactivate optional parameters. flys-client/trunk@2299 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 07 Jul 2011 12:10:50 +0000
parents 9b1499a65aaa
children 4497d19c22fd
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java
diffstat 2 files changed, 41 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Jul 07 10:33:29 2011 +0000
+++ b/flys-client/ChangeLog	Thu Jul 07 12:10:50 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:
+	  This panel is a sublcass of TextProvider now. The difference to the
+	  TextProvider is, that there is the option to active/deactivate a
+	  checkbox. So, the valid values returned by this panel are "true" and
+	  "false".
+
 2011-07-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/TextProvider.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java	Thu Jul 07 10:33:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/BooleanPanel.java	Thu Jul 07 12:10:50 2011 +0000
@@ -2,6 +2,7 @@
 
 import com.google.gwt.core.client.GWT;
 
+import com.smartgwt.client.types.FieldType;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
@@ -19,11 +20,10 @@
 /**
  * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
-public class BooleanPanel extends AbstractUIProvider {
+public class BooleanPanel extends TextProvider {
 
-    public static final String FIELD_NAME = "boolean_field";
-
-    protected DynamicForm form;
+    public static final String FIELD_NAME  = "boolean_field";
+    public static final int    TITLE_WIDTH = 0;
 
     protected String dataName;
 
@@ -37,75 +37,55 @@
 
         VLayout layout = new VLayout();
         Label   label  = new Label(data.getDescription());
+        Canvas  form   = createForm(getTitle(items[0]));
 
         layout.setMembersMargin(10);
         layout.setHeight(35);
         label.setHeight(35);
 
         layout.addMember(label);
-        layout.addMember(createForm(items[0].getLabel()));
+        layout.addMember(form);
         layout.addMember(getNextButton());
+        layout.setMembersMargin(10);
 
         return layout;
     }
 
 
-    protected Canvas createForm() {
-        return createForm(null);
-    }
-
-
-    protected Canvas createForm(String title) {
-        HLayout layout = new HLayout();
-        layout.setMembersMargin(10);
-
-        if (title != null && title.length() > 0) {
-            Label label = new Label(title);
-            label.setHeight(25);
-            layout.addMember(label);
-        }
-
-        form = new DynamicForm();
-        layout.addMember(form);
-
-        CheckboxItem item = new CheckboxItem(FIELD_NAME);
-        item.setShowTitle(false);
-        item.setShowLabel(false);
-
-        form.setFields(item);
-
-        return layout;
+    protected String getTitle(DataItem item) {
+        return item.getLabel();
     }
 
 
     @Override
-    public Canvas createOld(DataList dataList) {
-        Data       data  = dataList.get(0);
-        DataItem[] items = data.getItems();
-
-        HLayout layout = new HLayout();
-        Label   label  = new Label(dataList.getLabel());
-        Label   value  = new Label(items[0].getLabel());
-
-        layout.setHeight(35);
-        layout.setWidth(400);
-        label.setWidth(200);
-
-        layout.addMember(label);
-        layout.addMember(value);
-        layout.addMember(getBackButton(dataList.getState()));
-
-        return layout;
+    protected FieldType getFieldType() {
+        return FieldType.BOOLEAN;
     }
 
 
     @Override
-    protected Data[] getData() {
-        GWT.log("+++ RETURN DATA FOR STATE: " + dataName + " +++");
-        String value  = "TODO:FIND VALUE";
-        DataItem item = new DefaultDataItem(dataName, dataName, value);
-        return new Data[] { new DefaultData(
-            dataName, null, null, new DataItem[] { item }) };
+    protected String getFieldName() {
+        return FIELD_NAME;
+    }
+
+
+    @Override
+    protected String getDataName() {
+        return dataName;
+    }
+
+
+    @Override
+    protected String getValueAsString() {
+        Boolean aBool = (Boolean) form.getValue(getFieldName());
+
+        return aBool.toString();
+    }
+
+
+    @Override
+    protected int getTitleWidth() {
+        return TITLE_WIDTH;
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org