changeset 1290:f4deeafa60b3

Build up the editor window from CollectionItemAttribute response. flys-client/trunk@2887 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Tue, 04 Oct 2011 16:04:16 +0000 (2011-10-04)
parents d59dcaf52796
children 1d04f35b2cc0
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/StyleEditorWindow.java flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java
diffstat 3 files changed, 100 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Oct 04 07:55:43 2011 +0000
+++ b/flys-client/ChangeLog	Tue Oct 04 16:04:16 2011 +0000
@@ -1,3 +1,11 @@
+2011-10-04  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/StyleEditorWindow.java:
+	  Build up the editor window from CollectionItemAttribute response.
+
+	* src/main/java/de/intevation/flys/client/shared/model/Style.java:
+	  Added getter for number of settings and settings based on the index.
+
 2011-10-04  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/StyleEditorWindow.java	Tue Oct 04 07:55:43 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/StyleEditorWindow.java	Tue Oct 04 16:04:16 2011 +0000
@@ -6,12 +6,21 @@
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.Button;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.SpinnerItem;
+import com.smartgwt.client.widgets.form.fields.ColorPickerItem;
+import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
 
 import com.smartgwt.client.widgets.events.ClickEvent;
 import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.types.Alignment;
 
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.CollectionItemAttribute;
+import de.intevation.flys.client.shared.model.Style;
+import de.intevation.flys.client.shared.model.StyleSetting;
 import de.intevation.flys.client.client.ui.CollectionView;
 
 import de.intevation.flys.client.client.FLYSConstants;
@@ -54,8 +63,8 @@
 
     protected void init() {
         setTitle(MSG.properties());
-        setWidth(250);
-
+        setWidth(270);
+        setHeight(200);
         setCanDragReposition(true);
         setCanDragResize(true);
         setKeepInParentRect(true);
@@ -71,12 +80,18 @@
         Button accept = new Button(MSG.label_ok());
         Button cancel = new Button(MSG.label_cancel());
         cancel.addClickHandler(this);
+        accept.addClickHandler(new ClickHandler() {
+            public void onClick(ClickEvent e) {
 
+            }
+        });
 
         buttons.addMember(accept);
         buttons.addMember(cancel);
+        buttons.setAlign(Alignment.RIGHT);
+
+        layout.addMember(createPropertyGrid("LongitudinalSectionW"));;
         layout.addMember(buttons);
-
         addItem(layout);
     }
 
@@ -90,4 +105,70 @@
     public void onClick(ClickEvent event) {
         this.hide();
     }
+
+
+    protected VLayout createPropertyGrid(String stylename) {
+        //TODO use the style-(theme-)name from response to get the correct
+        //attribute set.
+
+        VLayout properties = new VLayout();
+
+        // get the correct style using the name.
+        Style s = attributes.getStyle(0);
+
+        for (int i = 0; i < s.getNumSettings(); i ++) {
+            final StyleSetting set = s.getSetting(i);
+            DynamicForm property = createPropertyUI(
+                set.getDisplayName(),
+                set.getName(),
+                set.getType(),
+                set.getDefaultValue());
+            properties.addMember(property);
+        }
+        return properties;
+    }
+
+    protected DynamicForm createPropertyUI(
+        String dname,
+        String name,
+        String type,
+        String value)
+    {
+        DynamicForm df = new DynamicForm();
+
+        FormItem f;
+        if(type.equals("int")) {
+            SpinnerItem s = new SpinnerItem(name, dname);
+            s.setMin(1);
+            s.setMax(10);
+            f = s;
+        }
+        else if (type.equals("boolean")) {
+            CheckboxItem c = new CheckboxItem(name, dname);
+            if(value.equals("true")) {
+                c.setValue(true);
+            }
+            else {
+                c.setValue(false);
+            }
+            c.setLabelAsTitle(true);
+            f = c;
+        }
+        else if (type.equals("Color")) {
+            f = new ColorPickerItem(name, dname);
+        }
+        else if (type.equals("Dash")) {
+            f = new ComboBoxItem(name, dname);
+        }
+        else {
+            f = new FormItem();
+        }
+        f.setValue(value);
+        f.setTitleStyle("color:#000; width:120px");
+        f.setTitleAlign(Alignment.LEFT);
+        df.setFields(f);
+
+        return df;
+    }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java	Tue Oct 04 07:55:43 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java	Tue Oct 04 16:04:16 2011 +0000
@@ -40,5 +40,13 @@
         }
         return null;
     }
+
+    public int getNumSettings () {
+        return settings.size();
+    }
+
+    public StyleSetting getSetting(int i) {
+        return this.settings.get(i);
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org