# HG changeset patch # User Ingo Weinzierl # Date 1300440988 0 # Node ID c9c19761a4491f196a23d4af648078acc47c59af # Parent 4439f642f632d9c449779c7153b9f11f15177176 Read min/max values for the distance modes in WQInputPanel. flys-client/trunk@1513 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 4439f642f632 -r c9c19761a449 flys-client/ChangeLog --- a/flys-client/ChangeLog Fri Mar 18 08:45:25 2011 +0000 +++ b/flys-client/ChangeLog Fri Mar 18 09:36:28 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-18 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java: + Read min/max values and define those values as default values for the + distance modes. + 2011-03-18 Ingo Weinzierl * src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java: diff -r 4439f642f632 -r c9c19761a449 flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java Fri Mar 18 08:45:25 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java Fri Mar 18 09:36:28 2011 +0000 @@ -67,6 +67,18 @@ /** The RadioGroupItem that determines the w/q input mode.*/ protected DynamicForm modes; + /** The min values for the 'from' property in the W-Range input mode.*/ + protected double minW; + + /** The min values for the 'from' property in the Q-Range input mode.*/ + protected double minQ; + + /** The max values for the 'from' property in the W-Range input mode.*/ + protected double maxW; + + /** The max values for the 'from' property in the Q-Range input mode.*/ + protected double maxQ; + /** The 'from' value entered in the range W mode.*/ protected double fromW; @@ -107,6 +119,8 @@ * @return the widget. */ public Canvas create(DataList data) { + initDefaults(data); + Canvas widget = createWidget(data); IButton submit = new IButton(MSG.next(), this); Label label = new Label(MSG.wqTitle()); @@ -151,6 +165,42 @@ } + /** + * This method reads the default values defined in the DataItems of the Data + * objects in list. + * + * @param list The DataList container that stores the Data objects. + */ + protected void initDefaults(DataList list) { + Data f = getData(list.getAll(), "wq_from"); + Data t = getData(list.getAll(), "wq_to"); + Data s = getData(list.getAll(), "wq_step"); + + DataItem fQItem = getDataItem(f.getItems(), "minQ"); + DataItem fWItem = getDataItem(f.getItems(), "minW"); + DataItem tQItem = getDataItem(t.getItems(), "maxQ"); + DataItem tWItem = getDataItem(t.getItems(), "maxW"); + DataItem sQItem = getDataItem(s.getItems(), "stepQ"); + DataItem sWItem = getDataItem(s.getItems(), "stepW"); + + minW = Double.valueOf(fWItem.getStringValue()); + maxW = Double.valueOf(tWItem.getStringValue()); + stepW = Double.valueOf(sWItem.getStringValue()); + + minQ = Double.valueOf(fQItem.getStringValue()); + maxQ = Double.valueOf(tQItem.getStringValue()); + stepQ = Double.valueOf(sQItem.getStringValue()); + + this.fromW = minW; + this.toW = maxW; + this.stepW = stepW; + + this.fromQ = minQ; + this.toQ = maxQ; + this.stepQ = stepQ; + } + + protected String createWString(DataItem from, DataItem to, DataItem step) { StringBuilder sb = new StringBuilder(); sb.append(from.getLabel()); @@ -196,6 +246,25 @@ return null; } + /** + * This method greps the DataItem with name name from the list and + * returns it. + * + * @param items A list of DataItems. + * @param name The name of the DataItem that we are searching for. + * + * @return the DataItem with the name name. + */ + protected DataItem getDataItem(DataItem[] items, String name) { + for (DataItem item: items) { + if (name.equals(item.getLabel())) { + return item; + } + } + + return null; + } + /** * This method creates the whole widget. There is a panel on the left, that