Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java @ 53:3d5d7788d471
The widgets in the static part of the parameter panel are created using UIProviders now. The ParameterList does not build widgets any longer.
flys-client/trunk@1509 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 17 Mar 2011 18:34:20 +0000 |
parents | a2923d63f530 |
children | c9c19761a449 |
comparison
equal
deleted
inserted
replaced
52:1d0be51ab93b | 53:3d5d7788d471 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | 2 |
3 import java.util.LinkedHashMap; | 3 import java.util.LinkedHashMap; |
4 import java.util.List; | |
4 | 5 |
5 import com.google.gwt.core.client.GWT; | 6 import com.google.gwt.core.client.GWT; |
6 | 7 |
7 import com.smartgwt.client.widgets.Canvas; | 8 import com.smartgwt.client.widgets.Canvas; |
8 import com.smartgwt.client.widgets.IButton; | 9 import com.smartgwt.client.widgets.IButton; |
12 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; | 13 import com.smartgwt.client.widgets.form.fields.RadioGroupItem; |
13 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; | 14 import com.smartgwt.client.widgets.form.fields.events.BlurHandler; |
14 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; | 15 import com.smartgwt.client.widgets.form.fields.events.BlurEvent; |
15 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; | 16 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; |
16 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; | 17 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; |
18 import com.smartgwt.client.widgets.layout.HLayout; | |
17 import com.smartgwt.client.widgets.layout.VLayout; | 19 import com.smartgwt.client.widgets.layout.VLayout; |
18 | 20 |
19 import de.intevation.flys.client.shared.model.Data; | 21 import de.intevation.flys.client.shared.model.Data; |
20 import de.intevation.flys.client.shared.model.DataItem; | 22 import de.intevation.flys.client.shared.model.DataItem; |
21 import de.intevation.flys.client.shared.model.DataList; | 23 import de.intevation.flys.client.shared.model.DataList; |
118 | 120 |
119 return layout; | 121 return layout; |
120 } | 122 } |
121 | 123 |
122 | 124 |
125 public Canvas createOld(DataList dataList) { | |
126 List<Data> items = dataList.getAll(); | |
127 | |
128 Data dMode = getData(items, "wq_mode"); | |
129 Data dFrom = getData(items, "wq_from"); | |
130 Data dTo = getData(items, "wq_to"); | |
131 Data dStep = getData(items, "wq_step"); | |
132 | |
133 DataItem[] mode = dMode.getItems(); | |
134 DataItem[] from = dFrom.getItems(); | |
135 DataItem[] to = dTo.getItems(); | |
136 DataItem[] step = dStep.getItems(); | |
137 | |
138 HLayout layout = new HLayout(); | |
139 Label label = new Label(dataList.getLabel()); | |
140 | |
141 label.setWidth("50%"); | |
142 | |
143 String text = mode[0].getStringValue().equals(FIELD_WQ_W) | |
144 ? createWString(from[0], to[0], step[0]) | |
145 : createQString(from[0], to[0], step[0]); | |
146 | |
147 layout.addMember(label); | |
148 layout.addMember(new Label(text)); | |
149 | |
150 return layout; | |
151 } | |
152 | |
153 | |
154 protected String createWString(DataItem from, DataItem to, DataItem step) { | |
155 StringBuilder sb = new StringBuilder(); | |
156 sb.append(from.getLabel()); | |
157 sb.append(" " + MSG.unitWFrom() + " "); | |
158 sb.append(to.getLabel()); | |
159 sb.append(" " + MSG.unitWTo() + " "); | |
160 sb.append(step.getLabel()); | |
161 sb.append(" " + MSG.unitWStep()); | |
162 | |
163 return sb.toString(); | |
164 } | |
165 | |
166 | |
167 protected String createQString(DataItem from, DataItem to, DataItem step) { | |
168 StringBuilder sb = new StringBuilder(); | |
169 sb.append(from.getLabel()); | |
170 sb.append(" " + MSG.unitQFrom() + " "); | |
171 sb.append(to.getLabel()); | |
172 sb.append(" " + MSG.unitQTo() + " "); | |
173 sb.append(step.getLabel()); | |
174 sb.append(" " + MSG.unitQStep()); | |
175 | |
176 return sb.toString(); | |
177 } | |
178 | |
179 | |
180 /** | |
181 * This method greps the Data with name <i>name</i> from the list and | |
182 * returns it. | |
183 * | |
184 * @param items A list of Data. | |
185 * @param name The name of the Data that we are searching for. | |
186 * | |
187 * @return the Data with the name <i>name</i>. | |
188 */ | |
189 protected Data getData(List<Data> data, String name) { | |
190 for (Data d: data) { | |
191 if (name.equals(d.getLabel())) { | |
192 return d; | |
193 } | |
194 } | |
195 | |
196 return null; | |
197 } | |
198 | |
199 | |
123 /** | 200 /** |
124 * This method creates the whole widget. There is a panel on the left, that | 201 * This method creates the whole widget. There is a panel on the left, that |
125 * allows the user to enter values manually by keyboard. On the right, there | 202 * allows the user to enter values manually by keyboard. On the right, there |
126 * is a table that allows the user to enter values by mouse click. | 203 * is a table that allows the user to enter values by mouse click. |
127 * | 204 * |