# HG changeset patch # User Ingo Weinzierl # Date 1316609667 0 # Node ID f98bd9b5ceddf23c0634159a9f31a6b0541f98cc # Parent 0a19a90d40c3512239c1fb448b6270d70cfaa485 #315 Added a new UIProvider for range selection in floodmaps. flys-client/trunk@2797 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 0a19a90d40c3 -r f98bd9b5cedd flys-client/ChangeLog --- a/flys-client/ChangeLog Mon Sep 19 16:51:27 2011 +0000 +++ b/flys-client/ChangeLog Wed Sep 21 12:54:27 2011 +0000 @@ -1,3 +1,26 @@ +2011-09-21 Ingo Weinzierl + + flys/issue315 (Überschwemmungsfläche: String bei Streckenauswahl) + + * src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java: + Little modifications to allow subclassing. + + * src/main/java/de/intevation/flys/client/client/ui/DoubleRangeOnlyPanel.java: + New. A subclass of DoubleRangePanel that does NOT display a "step" + field. + + * src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java: + Set correct title for this panel. + + * src/main/java/de/intevation/flys/client/client/ui/DistanceOnlyPanel.java: + New. A subclass of DistancePanel that instantiates a + DoubleRangeOnlyPanel instead of a DoubleRangePanel. So, there are only + "from" and "to" fields visible. In addition, this panel only returns + Data objects for these two fields. + + * src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java: + Registered the DistanceOnlyPanel. + 2011-09-19 Hans Plum * NEWS for V 2.5.0: diff -r 0a19a90d40c3 -r f98bd9b5cedd flys-client/src/main/java/de/intevation/flys/client/client/ui/DistanceOnlyPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistanceOnlyPanel.java Wed Sep 21 12:54:27 2011 +0000 @@ -0,0 +1,71 @@ +package de.intevation.flys.client.client.ui; + +import java.util.List; + +import de.intevation.flys.client.shared.model.Data; +import de.intevation.flys.client.shared.model.DataItem; +import de.intevation.flys.client.shared.model.DataList; + + +public class DistanceOnlyPanel extends DistancePanel { + + public DistanceOnlyPanel() { + this("right"); + } + + + public DistanceOnlyPanel(String labelOrientation) { + distancePanel = new DoubleRangeOnlyPanel( + labelFrom(), labelTo(), 0d, 0d, 250, this, labelOrientation); + } + + + @Override + protected String getOldSelectionString(DataList dataList) { + List items = dataList.getAll(); + + Data dFrom = getData(items, getLowerField()); + Data dTo = getData(items, getUpperField()); + + DataItem[] from = dFrom.getItems(); + DataItem[] to = dTo.getItems(); + + StringBuilder sb = new StringBuilder(); + sb.append(from[0].getLabel()); + sb.append(" " + getUnitFrom() + " - "); + sb.append(to[0].getLabel()); + sb.append(" " + getUnitTo()); + + return sb.toString(); + } + + + @Override + protected void initDefaultStep(DataList data) { + // do nothing + } + + + @Override + public Data[] getData() { + Data[] data = new Data[2]; + + data[0] = getDataFrom(); + data[1] = getDataTo(); + + return data; + } + + + @Override + protected String labelFrom() { + return getUnitFrom() + " - "; + } + + + @Override + protected String labelTo() { + return getUnitTo(); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 0a19a90d40c3 -r f98bd9b5cedd flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java Mon Sep 19 16:51:27 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java Wed Sep 21 12:54:27 2011 +0000 @@ -82,7 +82,7 @@ VLayout layout = new VLayout(); layout.setMembersMargin(10); - Label label = new Label(d.getDescription()); + Label label = new Label(MSG.distance_state()); Canvas submit = getNextButton(); diff -r 0a19a90d40c3 -r f98bd9b5cedd flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangeOnlyPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangeOnlyPanel.java Wed Sep 21 12:54:27 2011 +0000 @@ -0,0 +1,88 @@ +package de.intevation.flys.client.client.ui; + +import com.google.gwt.i18n.client.NumberFormat; + +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.form.fields.FloatItem; +import com.smartgwt.client.widgets.form.fields.StaticTextItem; +import com.smartgwt.client.widgets.form.fields.events.BlurHandler; + + +public class DoubleRangeOnlyPanel extends DoubleRangePanel { + + public DoubleRangeOnlyPanel( + String titleFrom, + String titleTo, + double from, + double to, + int width, + BlurHandler handler + ) { + this(titleFrom, titleTo, from, to, width, handler, "right"); + } + + + public DoubleRangeOnlyPanel( + String titleFrom, + String titleTo, + double from, + double to, + int width, + BlurHandler handler, + String labelOrientation + ) { + super(); + + fromItem = new FloatItem(FIELD_FROM); + toItem = new FloatItem(FIELD_TO); + stepItem = new FloatItem(FIELD_WIDTH); + + fromItem.addBlurHandler(handler); + toItem.addBlurHandler(handler); + + NumberFormat nf = NumberFormat.getDecimalFormat(); + + fromItem.setValue(nf.format(from)); + toItem.setValue(nf.format(to)); + + StaticTextItem fromText = new StaticTextItem("staticFrom"); + fromText.setValue(titleFrom); + fromText.setShowTitle(false); + fromItem.setShowTitle(false); + + StaticTextItem toText = new StaticTextItem("staticTo"); + toText.setValue(titleTo); + toText.setShowTitle(false); + toItem.setShowTitle(false); + + int itemWidth = width / 4; + fromItem.setWidth(itemWidth); + fromText.setWidth(itemWidth); + toItem.setWidth(itemWidth); + toText.setWidth(itemWidth); + + if (labelOrientation.equals("right")) { + setFields(fromItem, fromText, toItem, toText); + } + else { + setFields(fromText, fromItem, toText, toItem); + } + + setFixedColWidths(false); + setNumCols(4); + setWidth(width); + setAlign(Alignment.CENTER); + } + + + @Override + public boolean validateForm() { + return validateForm(fromItem) && validateForm(toItem); + } + + + @Override + public double getStep() { + return -1; + } +} diff -r 0a19a90d40c3 -r f98bd9b5cedd flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java Mon Sep 19 16:51:27 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleRangePanel.java Wed Sep 21 12:54:27 2011 +0000 @@ -44,6 +44,10 @@ protected FloatItem stepItem; + public DoubleRangePanel() { + } + + /** * Creates a new form with a single input field that displays an array of * double values. diff -r 0a19a90d40c3 -r f98bd9b5cedd flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Mon Sep 19 16:51:27 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java Wed Sep 21 12:54:27 2011 +0000 @@ -24,6 +24,9 @@ else if (uiProvider.equals("distance_panel")) { return new DistancePanel(); } + else if (uiProvider.equals("distance_only_panel")) { + return new DistanceOnlyPanel(); + } else if (uiProvider.equals("waterlevel_ground_panel")) { return new WaterlevelGroundPanel(); }