# HG changeset patch # User Raimund Renkert # Date 1317744256 0 # Node ID f4deeafa60b3ee924d3d04522fec5c72db1d6e99 # Parent d59dcaf527966987bc783f25695a6c84572ba4db Build up the editor window from CollectionItemAttribute response. flys-client/trunk@2887 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r d59dcaf52796 -r f4deeafa60b3 flys-client/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/flys/client/client/FLYSConstants.java, diff -r d59dcaf52796 -r f4deeafa60b3 flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/StyleEditorWindow.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 : diff -r d59dcaf52796 -r f4deeafa60b3 flys-client/src/main/java/de/intevation/flys/client/shared/model/Style.java --- 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 :