Mercurial > dive4elements > river
changeset 1465:d0bcf5ba7adf
Create the properties dialog content dynamically based on the properties read
from describe collection document.
flys-client/trunk@3505 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 21 Dec 2011 10:53:02 +0000 |
parents | c899a7ffdc8f |
children | 290e53d21d31 |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java flys-client/src/main/java/de/intevation/flys/client/shared/model/PropertyGroup.java |
diffstat | 7 files changed, 261 insertions(+), 199 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/ChangeLog Wed Dec 21 10:53:02 2011 +0000 @@ -1,3 +1,20 @@ +2011-12-21 Raimund Renkert <raimund.renkert@intevation.de> + + Create the properties dialog dynamically. + + * src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java: + Create the content based on the properties read from describe collection + document. + + * src/main/java/de/intevation/flys/client/shared/model/PropertyGroup.java: + Added getter for single property by name. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added i18n strings. + 2011-12-20 Raimund Renkert <raimund.renkert@intevation.de> * src/main/java/de/intevation/flys/client/shared/model/Collection.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Wed Dec 21 10:53:02 2011 +0000 @@ -635,5 +635,21 @@ String capabilitiesEmail(); String capabilitiesPhone(); + + String visibility(); + + String upper(); + + String lower(); + + String fixation(); + + String font_size(); + + String label(); + + String subtitle(); + + String display_grid(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Wed Dec 21 10:53:02 2011 +0000 @@ -328,3 +328,13 @@ capabilitiesContactInformation = Further Information capabilitiesEmail = Email capabilitiesPhone = Phone + +visibility = Visibility +upper = from +lower = to +fixation = Fix +font_size = Fontsize +label = Title +title = Title +subtitle = Subtitle +display_grid = Display grid
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Wed Dec 21 10:53:02 2011 +0000 @@ -328,3 +328,12 @@ capabilitiesContactInformation = Weitere Informationen capabilitiesEmail = Email capabilitiesPhone = Telefon +visibility = Sichtbarkeit +upper = von +lower = bis +fixation = Fix +font_size = Schriftgröße +label = Titel +title = Titel +subtitle = Untertitel +display_grid = Gitterlinien anzeigen
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Wed Dec 21 10:53:02 2011 +0000 @@ -328,3 +328,12 @@ capabilitiesContactInformation = Further Information capabilitiesEmail = Email capabilitiesPhone = Phone +visibility = Visibility +upper = from +lower = to +fixation = Fix +font_size = Fontsize +label = Title +title = Title +subtitle = Subtitle +display_grid = Display grid
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java Wed Dec 21 10:53:02 2011 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.client.client.ui.chart; +import java.util.List; import com.google.gwt.core.client.GWT; @@ -10,6 +11,8 @@ import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.Canvas; + import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.FormItem; import com.smartgwt.client.widgets.form.fields.CheckboxItem; @@ -17,11 +20,22 @@ import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.types.Alignment; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.ui.OutputTab; +import de.intevation.flys.client.shared.model.Property; +import de.intevation.flys.client.shared.model.PropertyGroup; +import de.intevation.flys.client.shared.model.PropertySetting; +import de.intevation.flys.client.shared.model.BooleanProperty; +import de.intevation.flys.client.shared.model.DoubleProperty; +import de.intevation.flys.client.shared.model.IntegerProperty; +import de.intevation.flys.client.shared.model.StringProperty; +import de.intevation.flys.client.shared.model.Settings; +import de.intevation.flys.client.shared.model.Collection; /** * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> */ @@ -57,12 +71,36 @@ setCanDragReposition(true); setCanDragResize(true); - Tab diagram = new Tab(MSG.diagram()); - Tab axes = new Tab(MSG.axes()); - Tab legend = new Tab(MSG.legend()); - tabs.addTab(diagram); - tabs.addTab(axes); - tabs.addTab(legend); + + Collection c = tab.getCollectionView().getCollection(); + String outputName = tab.getOutputName(); + Settings settings = c.getSettings(outputName); + + if (settings == null) { + return; + } + List<String> list = settings.getCategories(); + + for (int i = 0; i < list.size(); i++) { + Tab t = new Tab(MSG.getString(list.get(i))); + List<Property> props = settings.getSettings(list.get(i)); + VLayout layout = new VLayout(); + for (int j = 0; j < props.size(); j++) { + if (props.get(j) instanceof PropertyGroup) { + layout.addMember(generatePropertyGroup(props.get(j))); + } + else if (props.get(j) instanceof PropertySetting) { + PropertySetting p = (PropertySetting)props.get(j); + + if (p.getAttribute("display").equals("false")) { + continue; + } + layout.addMember(generatePropertySetting(props.get(j))); + } + } + t.setPane(layout); + tabs.addTab(t); + } Button accept = new Button(MSG.label_ok()); Button cancel = new Button(MSG.label_cancel()); @@ -79,10 +117,6 @@ buttons.setAlign(Alignment.CENTER); buttons.setHeight(30); - initChartPropertiesTab(diagram); - initAxesPropertiesTab(axes); - initLegendPropertiesTab(legend); - addItem(tabs); addItem(buttons); setWidth(340); @@ -98,214 +132,172 @@ this.hide(); } - /** - * Initializes the tab for general chart properties. - */ - protected void initChartPropertiesTab(Tab t) { - VLayout properties = new VLayout(); - DynamicForm form = new DynamicForm(); - - TextItem title = new TextItem (); - title.setTitle(MSG.chart_title()); - title.setTitleAlign(Alignment.LEFT); - - TextItem subTitle = new TextItem(); - subTitle.setTitle(MSG.chart_subtitle()); - subTitle.setTitleAlign(Alignment.LEFT); - - CheckboxItem grid = new CheckboxItem("grid", MSG.grid()); - grid.setLabelAsTitle(true); - grid.setTitleStyle("color:#000;"); - grid.setTitleAlign(Alignment.LEFT); - - CheckboxItem antialiasing = new CheckboxItem("antialiasing", - MSG.antialiasing()); - antialiasing.setLabelAsTitle(true); - antialiasing.setTitleStyle("color:#000;"); - antialiasing.setTitleAlign(Alignment.LEFT); - - form.setFields(new FormItem[] {title, subTitle, grid, antialiasing}); - properties.addMember(form); - t.setPane(properties); - } /** - * Initializes the tab for axes properties. + * */ - protected void initAxesPropertiesTab(Tab t) { - VLayout properties = new VLayout(); - Label scale = new Label(MSG.scale() + " :"); - Label scale1 = new Label(MSG.scale() + " :"); - Label scale2 = new Label(MSG.scale() + " :"); - Label scale3 = new Label(MSG.scale() + " :"); - scale.setHeight(25); - scale1.setHeight(25); - scale2.setHeight(25); - scale3.setHeight(25); - - DynamicForm xform1 = new DynamicForm(); - DynamicForm xform2 = new DynamicForm(); - xform2.setNumCols(6); + protected Canvas generatePropertyGroup(Property group) { + PropertyGroup pg = (PropertyGroup)group; + List<Property> list = pg.getProperties(); - Label x_axis = new Label (MSG.x_axis()); - x_axis.setHeight(30); - HLayout x_scale = new HLayout(); - TextItem xname = new TextItem (); - xname.setTitle(MSG.axis_name()); - xname.setTitleAlign(Alignment.LEFT); - - TextItem xrange1 = new TextItem(); - xrange1.setTitle(MSG.chart_start()); - xrange1.setTitleAlign(Alignment.LEFT); - xrange1.setWidth(50); + if (pg.getName().equals("axis")) { + Label scale = new Label(MSG.scale() + " :"); + scale.setHeight(25); + scale.setMargin(2); - TextItem xrange2 = new TextItem(); - xrange2.setTitle(MSG.chart_end()); - xrange2.setTitleAlign(Alignment.LEFT); - xrange2.setWidth(50); + DynamicForm form1 = new DynamicForm(); + DynamicForm form2 = new DynamicForm(); + form2.setNumCols(6); - CheckboxItem xfix = new CheckboxItem("xfix", "Fix"); - xfix.setLabelAsTitle(true); - xfix.setTitleStyle("color:#000;"); - xfix.setTitleAlign(Alignment.LEFT); + StringProperty label = + (StringProperty)pg.getPropertyByName("label"); + FormItem title = createStringProperty(label); + title.setValue(label.getValue()); - xform1.setFields(xname); - xform2.setFields(xrange1, xrange2, xfix); - x_scale.addMember(scale); - x_scale.addMember(xform2); + IntegerProperty fontsize = + (IntegerProperty)pg.getPropertyByName("font-size"); + FormItem fs = createIntegerProperty(fontsize); + fs.setValue(fontsize.getValue()); + + DoubleProperty upper = + (DoubleProperty)pg.getPropertyByName("upper"); + final FormItem range1 = createDoubleProperty(upper); + range1.setValue(upper.getValue()); + range1.setWidth(50); + + DoubleProperty lower = + (DoubleProperty)pg.getPropertyByName("lower"); + final FormItem range2 = createDoubleProperty(lower); + range2.setValue(lower.getValue()); + range2.setWidth(50); + + BooleanProperty fixation = + (BooleanProperty)pg.getPropertyByName("fixation"); + FormItem fix = createBooleanProperty(fixation); + fix.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent e) { + if ((Boolean)e.getValue()) { + range1.enable(); + range2.enable(); + } + else { + range1.disable(); + range2.disable(); + } + } + }); + if (fixation.getValue().equals("true")) { + fix.setValue(true); + range1.enable(); + range2.enable(); + } + else { + fix.setValue(false); + range1.disable(); + range2.disable(); + } + + form1.setFields(title, fs); + form2.setFields(fix, range1, range2); + + HLayout scaleLayout = new HLayout(); + scaleLayout.setHeight(30); + scaleLayout.addMember(scale); + scaleLayout.addMember(form2); + scaleLayout.addStyleName("property-dialog-axis"); + + VLayout root = new VLayout(); + root.addMember(form1); + root.addMember(scaleLayout); + root.setHeight(90); + + return root; + } + return null; + } - DynamicForm y1form1 = new DynamicForm(); - DynamicForm y1form2 = new DynamicForm(); - y1form2.setNumCols(6); - - Label y1_axis = new Label (MSG.y1_axis()); - y1_axis.setHeight(30); - HLayout y1_scale = new HLayout(); - TextItem y1name = new TextItem (); - y1name.setTitle(MSG.axis_name()); - y1name.setTitleAlign(Alignment.LEFT); - - TextItem y1range1 = new TextItem(); - y1range1.setTitle(MSG.chart_start()); - y1range1.setTitleAlign(Alignment.LEFT); - y1range1.setWidth(50); - - TextItem y1range2 = new TextItem(); - y1range2.setTitle(MSG.chart_end()); - y1range2.setTitleAlign(Alignment.LEFT); - y1range2.setWidth(50); - - CheckboxItem y1fix = new CheckboxItem("y1fix", "Fix"); - y1fix.setLabelAsTitle(true); - y1fix.setTitleStyle("color:#000;"); - y1fix.setTitleAlign(Alignment.LEFT); - - y1form1.setFields(y1name); - y1form2.setFields(y1range1, y1range2, y1fix); - y1_scale.addMember(scale1); - y1_scale.addMember(y1form2); - - - DynamicForm y2form1 = new DynamicForm(); - DynamicForm y2form2 = new DynamicForm(); - y2form2.setNumCols(6); - - Label y2_axis = new Label (MSG.y2_axis()); - y2_axis.setHeight(30); - HLayout y2_scale = new HLayout(); - TextItem y2name = new TextItem (); - y2name.setTitle(MSG.axis_name()); - y2name.setTitleAlign(Alignment.LEFT); - - TextItem y2range1 = new TextItem(); - y2range1.setTitle(MSG.chart_start()); - y2range1.setTitleAlign(Alignment.LEFT); - y2range1.setWidth(50); - - TextItem y2range2 = new TextItem(); - y2range2.setTitle(MSG.chart_end()); - y2range2.setTitleAlign(Alignment.LEFT); - y2range2.setWidth(50); - - CheckboxItem y2fix = new CheckboxItem("y2fix", "Fix"); - y2fix.setLabelAsTitle(true); - y2fix.setTitleStyle("color:#000;"); - y2fix.setTitleAlign(Alignment.LEFT); - - y2form1.setFields(y2name); - y2form2.setFields(y2range1, y2range2, y2fix); - y2_scale.addMember(scale2); - y2_scale.addMember(y2form2); + /** + * + */ + protected DynamicForm generatePropertySetting(Property setting) { + DynamicForm form = new DynamicForm(); + if (setting instanceof BooleanProperty) { + form.setFields(createBooleanProperty((BooleanProperty)setting)); + } + else if (setting instanceof DoubleProperty) { + form.setFields(createDoubleProperty((DoubleProperty)setting)); + } + else if (setting instanceof IntegerProperty) { + form.setFields(createIntegerProperty((IntegerProperty)setting)); + } + else if (setting instanceof StringProperty) { + form.setFields(createStringProperty((StringProperty)setting)); + } + return form; + } - DynamicForm y3form1 = new DynamicForm(); - DynamicForm y3form2 = new DynamicForm(); - y3form2.setNumCols(6); - - Label y3_axis = new Label (MSG.y3_axis()); - y3_axis.setHeight(30); - HLayout y3_scale = new HLayout(); - TextItem y3name = new TextItem (); - y3name.setTitle(MSG.axis_name()); - y3name.setTitleAlign(Alignment.LEFT); - - TextItem y3range1 = new TextItem(); - y3range1.setTitle(MSG.chart_start()); - y3range1.setTitleAlign(Alignment.LEFT); - y3range1.setWidth(50); - - TextItem y3range2 = new TextItem(); - y3range2.setTitle(MSG.chart_end()); - y3range2.setTitleAlign(Alignment.LEFT); - y3range2.setWidth(50); - - CheckboxItem y3fix = new CheckboxItem("y3fix", "Fix"); - y3fix.setLabelAsTitle(true); - y3fix.setTitleStyle("color:#000;"); - y3fix.setTitleAlign(Alignment.LEFT); - - y3form1.setFields(y3name); - y3form2.setFields(y3range1, y3range2, y3fix); - y3_scale.addMember(scale3); - y3_scale.addMember(y3form2); + /** + * + */ + protected FormItem createStringProperty(StringProperty sp) { + String name = sp.getName(); + if (name.contains("-")) { + name = name.replace("-", "_"); + } + TextItem item = new TextItem(); + item.setTitle(MSG.getString(name)); + item.setTitleAlign(Alignment.LEFT); + return item; + } - properties.addMember(x_axis); - properties.addMember(xform1); - properties.addMember(x_scale); - properties.addMember(y1_axis); - properties.addMember(y1form1); - properties.addMember(y1_scale); - properties.addMember(y2_axis); - properties.addMember(y2form1); - properties.addMember(y2_scale); - properties.addMember(y3_axis); - properties.addMember(y3form1); - properties.addMember(y3_scale); + /** + * + */ + protected FormItem createBooleanProperty(BooleanProperty bp) { + String name = bp.getName(); + if (name.contains("-")) { + name = name.replace("-", "_"); + } - t.setPane(properties); + CheckboxItem item = new CheckboxItem("item", MSG.getString(name)); + item.setLabelAsTitle(true); + item.setTitleStyle("color:#000;"); + item.setTitleAlign(Alignment.LEFT); + return item; } + /** - * Initializes the tab for legend properties. + * */ - protected void initLegendPropertiesTab(Tab t) { - VLayout properties = new VLayout(); - DynamicForm form = new DynamicForm(); + protected FormItem createDoubleProperty(DoubleProperty dp) { + String name = dp.getName(); + if (name.contains("-")) { + name = name.replace("-", "_"); + } - TextItem name = new TextItem (); - name.setTitle(MSG.legend_name()); - name.setTitleAlign(Alignment.LEFT); - - CheckboxItem show = new CheckboxItem("show", MSG.show_legend()); - show.setLabelAsTitle(true); - show.setTitleStyle("color:#000;"); - show.setTitleAlign(Alignment.LEFT); - - form.setFields(name, show); - properties.addMember(form); - t.setPane(properties); + TextItem item = new TextItem(); + item.setTitle(MSG.getString(name)); + item.setTitleAlign(Alignment.LEFT); + return item; } + + /** + * + */ + protected FormItem createIntegerProperty(IntegerProperty ip) { + String name = ip.getName(); + if (name.contains("-")) { + name = name.replace("-", "_"); + } + + TextItem item = new TextItem(); + item.setTitle(MSG.getString(name)); + item.setTitleAlign(Alignment.LEFT); + return item; + } }
--- a/flys-client/src/main/java/de/intevation/flys/client/shared/model/PropertyGroup.java Tue Dec 20 15:32:08 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/PropertyGroup.java Wed Dec 21 10:53:02 2011 +0000 @@ -40,4 +40,13 @@ public void setProperties(List<Property> properties) { this.properties = properties; } + + public Property getPropertyByName(String name) { + for (int i = 0; i < properties.size(); i++) { + if (properties.get(i).getName().equals(name)) { + return properties.get(i); + } + } + return null; + } }