comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterList.java @ 9071:a561b882436d

create module bundu (Betrieb & Unterhaltung) incl. original Fixierungsanalyse+Ausgelagerte Wasserspiegellage
author gernotbelger
date Wed, 16 May 2018 11:08:56 +0200
parents 8c3e5682cb60
children 02739b8c010d
comparison
equal deleted inserted replaced
9070:611a523fc42f 9071:a561b882436d
6 * documentation coming with Dive4Elements River for details. 6 * documentation coming with Dive4Elements River for details.
7 */ 7 */
8 8
9 package org.dive4elements.river.client.client.ui; 9 package org.dive4elements.river.client.client.ui;
10 10
11 import com.google.gwt.core.client.GWT; 11 import java.util.ArrayList;
12 import com.google.gwt.user.client.rpc.AsyncCallback; 12 import java.util.List;
13 13 import java.util.Map;
14 import com.smartgwt.client.types.Overflow; 14 import java.util.Set;
15 import com.smartgwt.client.types.VerticalAlignment; 15 import java.util.TreeMap;
16 import com.smartgwt.client.types.VisibilityMode;
17 import com.smartgwt.client.util.SC;
18 import com.smartgwt.client.widgets.Canvas;
19 import com.smartgwt.client.widgets.layout.HLayout;
20 import com.smartgwt.client.widgets.layout.SectionStack;
21 import com.smartgwt.client.widgets.layout.SectionStackSection;
22 import com.smartgwt.client.widgets.layout.VLayout;
23 import com.smartgwt.client.widgets.tab.Tab;
24 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
25 16
26 import org.dive4elements.river.client.client.Config; 17 import org.dive4elements.river.client.client.Config;
27 import org.dive4elements.river.client.client.FLYS; 18 import org.dive4elements.river.client.client.FLYS;
28 import org.dive4elements.river.client.client.FLYSConstants; 19 import org.dive4elements.river.client.client.FLYSConstants;
29 import org.dive4elements.river.client.client.event.AdvanceHandler; 20 import org.dive4elements.river.client.client.event.AdvanceHandler;
51 import org.dive4elements.river.client.client.ui.stationinfo.GaugePanel; 42 import org.dive4elements.river.client.client.ui.stationinfo.GaugePanel;
52 import org.dive4elements.river.client.client.ui.stationinfo.InfoPanel; 43 import org.dive4elements.river.client.client.ui.stationinfo.InfoPanel;
53 import org.dive4elements.river.client.client.ui.stationinfo.MeasurementStationPanel; 44 import org.dive4elements.river.client.client.ui.stationinfo.MeasurementStationPanel;
54 import org.dive4elements.river.client.shared.model.Artifact; 45 import org.dive4elements.river.client.shared.model.Artifact;
55 import org.dive4elements.river.client.shared.model.ArtifactDescription; 46 import org.dive4elements.river.client.shared.model.ArtifactDescription;
47 import org.dive4elements.river.client.shared.model.BUNDUArtifact;
56 import org.dive4elements.river.client.shared.model.Collection; 48 import org.dive4elements.river.client.shared.model.Collection;
57 import org.dive4elements.river.client.shared.model.Data; 49 import org.dive4elements.river.client.shared.model.Data;
58 import org.dive4elements.river.client.shared.model.DataItem; 50 import org.dive4elements.river.client.shared.model.DataItem;
59 import org.dive4elements.river.client.shared.model.DataList; 51 import org.dive4elements.river.client.shared.model.DataList;
60 import org.dive4elements.river.client.shared.model.DefaultData; 52 import org.dive4elements.river.client.shared.model.DefaultData;
67 import org.dive4elements.river.client.shared.model.River; 59 import org.dive4elements.river.client.shared.model.River;
68 import org.dive4elements.river.client.shared.model.SINFOArtifact; 60 import org.dive4elements.river.client.shared.model.SINFOArtifact;
69 import org.dive4elements.river.client.shared.model.UINFOArtifact; 61 import org.dive4elements.river.client.shared.model.UINFOArtifact;
70 import org.dive4elements.river.client.shared.model.WINFOArtifact; 62 import org.dive4elements.river.client.shared.model.WINFOArtifact;
71 63
72 import java.util.ArrayList; 64 import com.google.gwt.core.client.GWT;
73 import java.util.List; 65 import com.google.gwt.user.client.rpc.AsyncCallback;
74 import java.util.Map; 66 import com.smartgwt.client.types.Overflow;
75 import java.util.Set; 67 import com.smartgwt.client.types.VerticalAlignment;
76 import java.util.TreeMap; 68 import com.smartgwt.client.types.VisibilityMode;
77 69 import com.smartgwt.client.util.SC;
78 70 import com.smartgwt.client.widgets.Canvas;
79 public class ParameterList 71 import com.smartgwt.client.widgets.layout.HLayout;
80 extends Tab 72 import com.smartgwt.client.widgets.layout.SectionStack;
81 implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, 73 import com.smartgwt.client.widgets.layout.SectionStackSection;
82 HasParameterChangeHandler, CollectionChangeHandler, 74 import com.smartgwt.client.widgets.layout.VLayout;
83 OutputModesChangeHandler, AdvanceHandler 75 import com.smartgwt.client.widgets.tab.Tab;
84 { 76 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
77
78 public class ParameterList extends Tab implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, HasParameterChangeHandler, CollectionChangeHandler, OutputModesChangeHandler, AdvanceHandler {
85 private static final long serialVersionUID = 5204784727239299980L; 79 private static final long serialVersionUID = 5204784727239299980L;
86 80
87 public static final String STYLENAME_OLD_PARAMETERS = "oldParameters"; 81 public static final String STYLENAME_OLD_PARAMETERS = "oldParameters";
88 82
89 /** The message class that provides i18n strings. */ 83 /** The message class that provides i18n strings. */
90 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 84 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
91 85
92 /** The ArtifactService used to communicate with the Artifact server. */ 86 /** The ArtifactService used to communicate with the Artifact server. */
93 protected ArtifactServiceAsync artifactService = 87 protected ArtifactServiceAsync artifactService = GWT.create(ArtifactService.class);
94 GWT.create(ArtifactService.class);
95 88
96 /** The StepForwardService used to put data into an existing artifact. */ 89 /** The StepForwardService used to put data into an existing artifact. */
97 protected StepForwardServiceAsync forwardService = 90 protected StepForwardServiceAsync forwardService = GWT.create(StepForwardService.class);
98 GWT.create(StepForwardService.class);
99 91
100 /** The StepForwardService used to put data into an existing artifact. */ 92 /** The StepForwardService used to put data into an existing artifact. */
101 protected AdvanceServiceAsync advanceService = 93 protected AdvanceServiceAsync advanceService = GWT.create(AdvanceService.class);
102 GWT.create(AdvanceService.class); 94
103 95 protected ReportServiceAsync reportService = GWT.create(ReportService.class);
104
105 protected ReportServiceAsync reportService =
106 GWT.create(ReportService.class);
107
108 96
109 /** The list of ParameterizationChangeHandler. */ 97 /** The list of ParameterizationChangeHandler. */
110 protected List<ParameterChangeHandler> parameterHandlers; 98 protected List<ParameterChangeHandler> parameterHandlers;
111 99
112 protected FLYS flys; 100 protected FLYS flys;
115 103
116 protected Artifact artifact; 104 protected Artifact artifact;
117 105
118 protected List<DataList> old; 106 protected List<DataList> old;
119 protected Map<String, Canvas> oldStorage; 107 protected Map<String, Canvas> oldStorage;
120 protected DataList current; 108 protected DataList current;
121 109
122 protected UIProvider uiProvider; 110 protected UIProvider uiProvider;
123 111
124 protected VLayout topLayout; 112 protected VLayout topLayout;
125 protected VLayout oldItems; 113 protected VLayout oldItems;
127 protected VLayout exportModes; 115 protected VLayout exportModes;
128 protected VLayout report; 116 protected VLayout report;
129 protected VLayout helperPanel; 117 protected VLayout helperPanel;
130 protected VLayout tablePanel; 118 protected VLayout tablePanel;
131 protected InfoPanel infoPanel; 119 protected InfoPanel infoPanel;
132 protected Canvas reportPanel; 120 protected Canvas reportPanel;
133 121
134 private SectionStack stack; 122 private SectionStack stack;
135 123
136 public ParameterList(FLYS flys, CollectionView cView, String title) { 124 public ParameterList(final FLYS flys, final CollectionView cView, final String title) {
137 super(title); 125 super(title);
138 126
139 this.cView = cView; 127 this.cView = cView;
140 this.flys = flys; 128 this.flys = flys;
141 129
142 parameterHandlers = new ArrayList<ParameterChangeHandler>(); 130 this.parameterHandlers = new ArrayList<ParameterChangeHandler>();
143 old = new ArrayList<DataList>(); 131 this.old = new ArrayList<DataList>();
144 oldStorage = new TreeMap<String, Canvas>(); 132 this.oldStorage = new TreeMap<String, Canvas>();
145 topLayout = new VLayout(); 133 this.topLayout = new VLayout();
146 oldItems = new VLayout(); 134 this.oldItems = new VLayout();
147 currentItems = new VLayout(); 135 this.currentItems = new VLayout();
148 exportModes = new VLayout(); 136 this.exportModes = new VLayout();
149 report = new VLayout(); 137 this.report = new VLayout();
150 138
151 addParameterChangeHandler(this); 139 addParameterChangeHandler(this);
152 140
153 init(); 141 init();
154 } 142 }
155 143
156 144 public ParameterList(final FLYS flys, final CollectionView cView, final String title, final Artifact artifact) {
157 public ParameterList(
158 FLYS flys,
159 CollectionView cView,
160 String title,
161 Artifact artifact)
162 {
163 super(title); 145 super(title);
164 146
165 this.cView = cView; 147 this.cView = cView;
166 this.flys = flys; 148 this.flys = flys;
167 this.artifact = artifact; 149 this.artifact = artifact;
168 150
169 parameterHandlers = new ArrayList<ParameterChangeHandler>(); 151 this.parameterHandlers = new ArrayList<ParameterChangeHandler>();
170 old = new ArrayList<DataList>(); 152 this.old = new ArrayList<DataList>();
171 oldStorage = new TreeMap<String, Canvas>(); 153 this.oldStorage = new TreeMap<String, Canvas>();
172 topLayout = new VLayout(); 154 this.topLayout = new VLayout();
173 oldItems = new VLayout(); 155 this.oldItems = new VLayout();
174 currentItems = new VLayout(); 156 this.currentItems = new VLayout();
175 exportModes = new VLayout(); 157 this.exportModes = new VLayout();
176 report = new VLayout(); 158 this.report = new VLayout();
177 159
178 init(); 160 init();
179 161
180 addParameterChangeHandler(this); 162 addParameterChangeHandler(this);
181 163
182 setArtifact(artifact, false); 164 setArtifact(artifact, false);
183 } 165 }
184 166
185
186 protected void init() { 167 protected void init() {
187 HLayout rootLayout = new HLayout(); 168 final HLayout rootLayout = new HLayout();
188 rootLayout.setMembersMargin(20); 169 rootLayout.setMembersMargin(20);
189 170
190 VLayout left = new VLayout(); 171 final VLayout left = new VLayout();
191 172
192 if (old == null || old.size() == 0) { 173 if (this.old == null || this.old.size() == 0) {
193 oldItems.setHeight(1); 174 this.oldItems.setHeight(1);
194 } 175 }
195 176
196 oldItems.setMembersMargin(10); 177 this.oldItems.setMembersMargin(10);
197 oldItems.setStyleName(STYLENAME_OLD_PARAMETERS); 178 this.oldItems.setStyleName(STYLENAME_OLD_PARAMETERS);
198 currentItems.setAlign(VerticalAlignment.TOP); 179 this.currentItems.setAlign(VerticalAlignment.TOP);
199 180
200 left.setMembersMargin(20); 181 left.setMembersMargin(20);
201 left.setWidth(300); 182 left.setWidth(300);
202 183
203 left.addMember(oldItems); 184 left.addMember(this.oldItems);
204 left.addMember(currentItems); 185 left.addMember(this.currentItems);
205 left.addMember(exportModes); 186 left.addMember(this.exportModes);
206 left.addMember(report); 187 left.addMember(this.report);
207 188
208 reportPanel = new Canvas(); 189 this.reportPanel = new Canvas();
209 reportPanel.setHeight("*"); 190 this.reportPanel.setHeight("*");
210 report.addMember(reportPanel); 191 this.report.addMember(this.reportPanel);
211 192
212 rootLayout.addMember(left); 193 rootLayout.addMember(left);
213 rootLayout.addMember(createSectionStack()); 194 rootLayout.addMember(createSectionStack());
214 195
215 topLayout.addMember(rootLayout); 196 this.topLayout.addMember(rootLayout);
216 if (artifact == null) { 197 if (this.artifact == null) {
217 Canvas moduleSelection = renderNew(); 198 final Canvas moduleSelection = renderNew();
218 moduleSelection.setLayoutAlign(VerticalAlignment.TOP); 199 moduleSelection.setLayoutAlign(VerticalAlignment.TOP);
219 currentItems.addMember(moduleSelection); 200 this.currentItems.addMember(moduleSelection);
220 } 201 }
221 202
222 setPane(topLayout); 203 setPane(this.topLayout);
223 } 204 }
224
225 205
226 protected SectionStack createSectionStack() { 206 protected SectionStack createSectionStack() {
227 stack = new SectionStack(); 207 this.stack = new SectionStack();
228 stack.setHeight100(); 208 this.stack.setHeight100();
229 stack.setCanResizeSections(true); 209 this.stack.setCanResizeSections(true);
230 stack.setVisibilityMode(VisibilityMode.MULTIPLE); 210 this.stack.setVisibilityMode(VisibilityMode.MULTIPLE);
231 stack.setOverflow(Overflow.SCROLL); 211 this.stack.setOverflow(Overflow.SCROLL);
232 212
233 // This canvas is used to render helper widgets. 213 // This canvas is used to render helper widgets.
234 final SectionStackSection helperSection = new SectionStackSection(); 214 final SectionStackSection helperSection = new SectionStackSection();
235 helperSection.setExpanded(false); 215 helperSection.setExpanded(false);
236 helperSection.setTitle(MSG.helperPanelTitle()); 216 helperSection.setTitle(this.MSG.helperPanelTitle());
237 helperPanel = new VLayout() { 217 this.helperPanel = new VLayout() {
238 @Override 218 @Override
239 public void addMember(Canvas component) { 219 public void addMember(final Canvas component) {
240 super.addMember(component); 220 super.addMember(component);
241 stack.expandSection(helperSection.getID()); 221 ParameterList.this.stack.expandSection(helperSection.getID());
242 } 222 }
243 223
244 @Override 224 @Override
245 public void removeMembers(Canvas[] components) { 225 public void removeMembers(final Canvas[] components) {
246 super.removeMembers(components); 226 super.removeMembers(components);
247 helperSection.setExpanded(false); 227 helperSection.setExpanded(false);
248 } 228 }
249 }; 229 };
250 helperPanel.setWidth100(); 230 this.helperPanel.setWidth100();
251 helperPanel.setHeight100(); 231 this.helperPanel.setHeight100();
252 helperSection.setItems(helperPanel); 232 helperSection.setItems(this.helperPanel);
253 233
254 // This canvas is used to render calculation results. 234 // This canvas is used to render calculation results.
255 final SectionStackSection tableSection = new SectionStackSection(); 235 final SectionStackSection tableSection = new SectionStackSection();
256 tableSection.setExpanded(false); 236 tableSection.setExpanded(false);
257 tableSection.setTitle(MSG.calcTableTitle()); 237 tableSection.setTitle(this.MSG.calcTableTitle());
258 tablePanel = new VLayout() { 238 this.tablePanel = new VLayout() {
259 @Override 239 @Override
260 public void addMember(Canvas component) { 240 public void addMember(final Canvas component) {
261 super.addMember(component); 241 super.addMember(component);
262 tableSection.setExpanded(true); 242 tableSection.setExpanded(true);
263 if (stack.getSection(InfoPanel.SECTION_ID) != null) { 243 if (ParameterList.this.stack.getSection(InfoPanel.SECTION_ID) != null) {
264 stack.getSection(InfoPanel.SECTION_ID).setExpanded(false); 244 ParameterList.this.stack.getSection(InfoPanel.SECTION_ID).setExpanded(false);
265 } 245 }
266 } 246 }
267 247
268 @Override 248 @Override
269 public void removeMembers(Canvas[] components) { 249 public void removeMembers(final Canvas[] components) {
270 super.removeMembers(components); 250 super.removeMembers(components);
271 tableSection.setExpanded(false); 251 tableSection.setExpanded(false);
272 } 252 }
273 }; 253 };
274 tablePanel.setHeight100(); 254 this.tablePanel.setHeight100();
275 tablePanel.setWidth100(); 255 this.tablePanel.setWidth100();
276 tableSection.setItems(tablePanel); 256 tableSection.setItems(this.tablePanel);
277 257
278 stack.setSections(helperSection, tableSection); 258 this.stack.setSections(helperSection, tableSection);
279 259
280 return stack; 260 return this.stack;
281 } 261 }
282
283 262
284 /** Sets and forwards artifact. */ 263 /** Sets and forwards artifact. */
285 protected void setArtifact(Artifact artifact) { 264 protected void setArtifact(final Artifact artifact) {
286 setArtifact(artifact, true); 265 setArtifact(artifact, true);
287 } 266 }
288 267
289 268 protected void setArtifact(final Artifact artifact, final boolean forward) {
290 protected void setArtifact(Artifact artifact, boolean forward) { 269 final Artifact tmp = this.artifact;
291 Artifact tmp = this.artifact;
292 this.artifact = artifact; 270 this.artifact = artifact;
293 271
294 if (forward) { 272 if (forward) {
295 fireParameterChangeEvent( 273 fireParameterChangeEvent(tmp, this.artifact, ParameterChangeEvent.Type.FORWARD);
296 tmp, this.artifact, ParameterChangeEvent.Type.FORWARD); 274 } else {
297 } 275 fireParameterChangeEvent(tmp, this.artifact, ParameterChangeEvent.Type.BACK);
298 else { 276 }
299 fireParameterChangeEvent( 277 }
300 tmp, this.artifact, ParameterChangeEvent.Type.BACK);
301 }
302 }
303
304 278
305 /** 279 /**
306 * This method registers a new ParameterChangeHandler. 280 * This method registers a new ParameterChangeHandler.
307 * 281 *
308 * @param handler The new ParameterChangeHandler. 282 * @param handler
283 * The new ParameterChangeHandler.
309 */ 284 */
310 @Override 285 @Override
311 public void addParameterChangeHandler(ParameterChangeHandler handler) { 286 public void addParameterChangeHandler(final ParameterChangeHandler handler) {
312 if (handler != null) { 287 if (handler != null) {
313 parameterHandlers.add(handler); 288 this.parameterHandlers.add(handler);
314 } 289 }
315 } 290 }
316
317 291
318 /** 292 /**
319 * This method calls the <code>onParameterChange()</code> method of all 293 * This method calls the <code>onParameterChange()</code> method of all
320 * registered ParameterChangeHandler. 294 * registered ParameterChangeHandler.
321 */ 295 */
322 protected void fireParameterChangeEvent( 296 protected void fireParameterChangeEvent(final Artifact old, final Artifact newArt, final ParameterChangeEvent.Type type) {
323 Artifact old, 297 final ParameterChangeEvent e = new ParameterChangeEvent(old, newArt, type);
324 Artifact newArt, 298
325 ParameterChangeEvent.Type type) 299 for (final ParameterChangeHandler handler : this.parameterHandlers) {
326 {
327 ParameterChangeEvent e = new ParameterChangeEvent(old, newArt, type);
328
329 for (ParameterChangeHandler handler: parameterHandlers) {
330 handler.onParameterChange(e); 300 handler.onParameterChange(e);
331 } 301 }
332 } 302 }
333
334 303
335 /** 304 /**
336 * This method creates a Canvas displaying the plugins of FLYS combined with 305 * This method creates a Canvas displaying the plugins of FLYS combined with
337 * a widget to select a river. 306 * a widget to select a river.
338 * 307 *
339 * @return a Canvas that displays the supported plugins and rivers of FLYS. 308 * @return a Canvas that displays the supported plugins and rivers of FLYS.
340 */ 309 */
341 protected Canvas renderNew() { 310 protected Canvas renderNew() {
342 River[] rivers = flys.getRivers(); 311 final River[] rivers = this.flys.getRivers();
343 DataItem[] items = new DataItem[rivers.length]; 312 final DataItem[] items = new DataItem[rivers.length];
344 313
345 int i = 0; 314 int i = 0;
346 for (River river: rivers) { 315 for (final River river : rivers) {
347 String name = river.getName(); 316 final String name = river.getName();
348 String mUuid = river.getModelUuid(); 317 final String mUuid = river.getModelUuid();
349 items[i++] = new DefaultDataItem(name, null, mUuid); 318 items[i++] = new DefaultDataItem(name, null, mUuid);
350 } 319 }
351 320
352 Data data = new DefaultData( 321 final Data data = new DefaultData("river", this.MSG.river_selection(), null, items);
353 "river", 322
354 MSG.river_selection(), 323 final LinkSelection widget = new LinkSelection();
355 null, 324 final HasStepForwardHandlers handler = widget;
356 items); 325
357 326 widget.setContainer(this.helperPanel);
358 LinkSelection widget = new LinkSelection();
359 HasStepForwardHandlers handler = widget;
360
361 widget.setContainer(helperPanel);
362 327
363 handler.addStepForwardHandler(new StepForwardHandler() { 328 handler.addStepForwardHandler(new StepForwardHandler() {
364 private static final long serialVersionUID = -6210719844707004860L; 329 private static final long serialVersionUID = -6210719844707004860L;
365 330
366 @Override 331 @Override
367 public void onStepForward(StepForwardEvent event) { 332 public void onStepForward(final StepForwardEvent event) {
368 lockUI(); 333 lockUI();
369 Data[] data = event.getData(); 334 final Data[] data = event.getData();
370 335
371 DataItem[] moduleItems = data[0].getItems(); 336 final DataItem[] moduleItems = data[0].getItems();
372 DataItem[] riversItems = data[1].getItems(); 337 final DataItem[] riversItems = data[1].getItems();
373 338
374 String module = moduleItems[0].getStringValue(); 339 final String module = moduleItems[0].getStringValue();
375 String river = riversItems[0].getStringValue(); 340 final String river = riversItems[0].getStringValue();
376 341
377 if (module == null || river == null) { 342 if (module == null || river == null) {
378 GWT.log("ParameterList.renderNew(): module == null " 343 GWT.log("ParameterList.renderNew(): module == null " + "|| river == null");
379 + "|| river == null");
380 unlockUI(); 344 unlockUI();
381 return; 345 return;
382 } 346 }
383 final String newTitle = moduleItems[0].getLabel(); 347 final String newTitle = moduleItems[0].getLabel();
384 setTitle(newTitle); 348 setTitle(newTitle);
385 349
386 Config config = Config.getInstance(); 350 final Config config = Config.getInstance();
387 final String locale = config.getLocale(); 351 final String locale = config.getLocale();
388 352
389 final Data[] feedData = new Data[] { data[1] }; 353 final Data[] feedData = new Data[] { data[1] };
390 354
391 artifactService.create( 355 ParameterList.this.artifactService.create(locale, module.toLowerCase(), null, new AsyncCallback<Artifact>() {
392 locale, module.toLowerCase(), null, 356 @Override
393 new AsyncCallback<Artifact>() { 357 public void onFailure(final Throwable caught) {
394 @Override 358 unlockUI();
395 public void onFailure(Throwable caught) { 359 GWT.log("Could not create the new artifact.");
396 unlockUI(); 360 SC.warn(FLYS.getExceptionString(ParameterList.this.MSG, caught));
397 GWT.log("Could not create the new artifact."); 361 }
398 SC.warn(FLYS.getExceptionString(MSG, caught)); 362
399 } 363 @Override
400 364 public void onSuccess(final Artifact artifact) {
401 @Override 365 GWT.log("Successfully created a new artifact.");
402 public void onSuccess(Artifact artifact) { 366
403 GWT.log("Successfully created a new artifact."); 367 ParameterList.this.forwardService.go(locale, artifact, feedData, new AsyncCallback<Artifact>() {
404 368 @Override
405 forwardService.go(locale, artifact, feedData, 369 public void onFailure(final Throwable caught) {
406 new AsyncCallback<Artifact>() { 370 unlockUI();
407 @Override 371 GWT.log("Could not feed the artifact.");
408 public void onFailure(Throwable caught) { 372 SC.warn(caught.getMessage());
409 unlockUI(); 373 }
410 GWT.log("Could not feed the artifact."); 374
411 SC.warn(caught.getMessage()); 375 @Override
412 } 376 public void onSuccess(final Artifact artifact) {
413 377 GWT.log("Successfully feed the artifact.");
414 @Override 378 ParameterList.this.old.clear();
415 public void onSuccess(Artifact artifact) { 379 ParameterList.this.cView.addArtifactToCollection(artifact);
416 GWT.log("Successfully feed the artifact."); 380 setArtifact(artifact);
417 old.clear(); 381 unlockUI();
418 cView.addArtifactToCollection(artifact); 382 }
419 setArtifact(artifact); 383 });
420 unlockUI(); 384 }
421 }
422 });
423 }
424 }); 385 });
425 } 386 }
426 }); 387 });
427 388
428 DataList list = new DataList(); 389 final DataList list = new DataList();
429 list.add(data); 390 list.add(data);
430 391
431 return widget.create(list); 392 return widget.create(list);
432 } 393 }
433 394
434
435 protected void clearOldData() { 395 protected void clearOldData() {
436 old.clear(); 396 this.old.clear();
437 } 397 }
438 398
439 399 public void addOldData(final DataList old) {
440 public void addOldData(DataList old) {
441 addOldData(old, true); 400 addOldData(old, true);
442 } 401 }
443 402
444 403 public void addOldData(final DataList old, final boolean redraw) {
445 public void addOldData(DataList old, boolean redraw) {
446 if (old != null) { 404 if (old != null) {
447 this.old.add(old); 405 this.old.add(old);
448 } 406 }
449 407
450 refreshOld(redraw); 408 refreshOld(redraw);
451 } 409 }
452 410
453 411 public void addOldDatas(final DataList[] old) {
454 public void addOldDatas(DataList[] old) {
455 addOldDatas(old, true); 412 addOldDatas(old, true);
456 } 413 }
457 414
458 415 public void addOldDatas(final DataList[] old, final boolean redraw) {
459 public void addOldDatas(DataList[] old, boolean redraw) {
460 if (old != null && old.length > 0) { 416 if (old != null && old.length > 0) {
461 for (DataList o: old) { 417 for (final DataList o : old) {
462 if (o == null) { 418 if (o == null) {
463 continue; 419 continue;
464 } 420 }
465 421
466 if (!exists(o)) { 422 if (!exists(o)) {
477 } 433 }
478 434
479 addOldData(null, true); 435 addOldData(null, true);
480 } 436 }
481 437
482 438 public boolean exists(final DataList data) {
483 public boolean exists(DataList data) {
484 if (data == null) { 439 if (data == null) {
485 return false; 440 return false;
486 } 441 }
487 442
488 String stateName = data.getState(); 443 final String stateName = data.getState();
489 444
490 for (DataList o: old) { 445 for (final DataList o : this.old) {
491 if (stateName.equals(o.getState())) { 446 if (stateName.equals(o.getState())) {
492 return true; 447 return true;
493 } 448 }
494 } 449 }
495 450
496 return false; 451 return false;
497 } 452 }
498 453
499 454 public void setCurrentData(final DataList current, final UIProvider uiProvider) {
500 public void setCurrentData(DataList current, UIProvider uiProvider) { 455 this.current = current;
501 this.current = current;
502 this.uiProvider = uiProvider; 456 this.uiProvider = uiProvider;
503 457
504 refreshCurrent(); 458 refreshCurrent();
505 } 459 }
506 460
507 461 public void refreshOld(final boolean redrawAll) {
508 public void refreshOld(boolean redrawAll) {
509 if (redrawAll) { 462 if (redrawAll) {
510 refreshAllOld(); 463 refreshAllOld();
511 } 464 } else {
512 else { 465 final DataList dataList = this.old.get(this.old.size() - 1);
513 DataList dataList = old.get(old.size()-1); 466 final String state = dataList.getState();
514 String state = dataList.getState(); 467
515 468 if (this.oldStorage.get(state) == null) {
516 if (oldStorage.get(state) == null) { 469 final String provider = dataList.getUIProvider();
517 String provider = dataList.getUIProvider(); 470 final UIProvider uiprovider = UIProviderFactory.getProvider(provider, this.flys.getCurrentUser());
518 UIProvider uiprovider = UIProviderFactory.getProvider(
519 provider,
520 flys.getCurrentUser());
521 ((HasStepBackHandlers) uiprovider).addStepBackHandler(this); 471 ((HasStepBackHandlers) uiprovider).addStepBackHandler(this);
522 472
523 Canvas c = uiprovider.createOld(dataList); 473 final Canvas c = uiprovider.createOld(dataList);
524 if (c != null) { 474 if (c != null) {
525 oldStorage.put(dataList.getState(), c); 475 this.oldStorage.put(dataList.getState(), c);
526 oldItems.addMember(c); 476 this.oldItems.addMember(c);
527 } 477 }
528 } 478 }
529 } 479 }
530 480
531 updateOldHeight(); 481 updateOldHeight();
532 } 482 }
533 483
534
535 protected void refreshAllOld() { 484 protected void refreshAllOld() {
536 List<String> not = new ArrayList<String>(); 485 final List<String> not = new ArrayList<String>();
537 486
538 for (DataList data: old) { 487 for (final DataList data : this.old) {
539 String state = data.getState(); 488 final String state = data.getState();
540 489
541 Canvas c = oldStorage.get(state); 490 final Canvas c = this.oldStorage.get(state);
542 491
543 if (c != null) { 492 if (c != null) {
544 not.add(state); 493 not.add(state);
545 } 494 }
546 } 495 }
547 496
548 Map<String, Canvas> newOld = new TreeMap<String, Canvas>(); 497 final Map<String, Canvas> newOld = new TreeMap<String, Canvas>();
549 498
550 Set<Map.Entry<String, Canvas>> entries = oldStorage.entrySet(); 499 final Set<Map.Entry<String, Canvas>> entries = this.oldStorage.entrySet();
551 for (Map.Entry<String, Canvas> entry: entries) { 500 for (final Map.Entry<String, Canvas> entry : entries) {
552 String state = entry.getKey(); 501 final String state = entry.getKey();
553 Canvas value = entry.getValue(); 502 final Canvas value = entry.getValue();
554 503
555 if (not.indexOf(state) < 0) { 504 if (not.indexOf(state) < 0) {
556 oldItems.removeMember(value); 505 this.oldItems.removeMember(value);
557 } 506 } else {
558 else {
559 newOld.put(state, value); 507 newOld.put(state, value);
560 } 508 }
561 } 509 }
562 510
563 oldStorage = newOld; 511 this.oldStorage = newOld;
564 } 512 }
565
566 513
567 protected void updateOldHeight() { 514 protected void updateOldHeight() {
568 int minHeight = oldItems.getMinHeight(); 515 final int minHeight = this.oldItems.getMinHeight();
569 if (minHeight <= 20) { 516 if (minHeight <= 20) {
570 oldItems.setHeight(20); 517 this.oldItems.setHeight(20);
571 } 518 } else {
572 else { 519 this.oldItems.setHeight(minHeight);
573 oldItems.setHeight(minHeight); 520 }
574 } 521 }
575 }
576
577 522
578 /** 523 /**
579 * Refreshes the part displaying the data of the current state. 524 * Refreshes the part displaying the data of the current state.
580 * The UI is created using the UIProvider stored in the Data object. 525 * The UI is created using the UIProvider stored in the Data object.
581 */ 526 */
582 public void refreshCurrent() { 527 public void refreshCurrent() {
583 currentItems.removeMembers(currentItems.getMembers()); 528 this.currentItems.removeMembers(this.currentItems.getMembers());
584 529
585 if (current != null && uiProvider != null) { 530 if (this.current != null && this.uiProvider != null) {
586 Canvas c = uiProvider.create(current); 531 final Canvas c = this.uiProvider.create(this.current);
587 Canvas h = uiProvider.createHelpLink(current, null, this.flys); 532 final Canvas h = this.uiProvider.createHelpLink(this.current, null, this.flys);
588 533
589 HLayout wrapper = new HLayout(); 534 final HLayout wrapper = new HLayout();
590 wrapper.addMember(h); 535 wrapper.addMember(h);
591 wrapper.addMember(c); 536 wrapper.addMember(c);
592 537
593 currentItems.addMember(wrapper); 538 this.currentItems.addMember(wrapper);
594 } 539 } else if (this.uiProvider != null) {
595 else if (uiProvider != null) { 540 final Canvas c = this.uiProvider.create(null);
596 Canvas c = uiProvider.create(null);
597 c.setLayoutAlign(VerticalAlignment.TOP); 541 c.setLayoutAlign(VerticalAlignment.TOP);
598 542
599 currentItems.addMember(c); 543 this.currentItems.addMember(c);
600 } 544 } else {
601 else { 545 this.currentItems.setHeight(1);
602 currentItems.setHeight(1); 546 }
603 } 547
604 548 final Canvas[] members = this.currentItems.getMembers();
605 Canvas[] members = currentItems.getMembers();
606 if (members == null || members.length == 0) { 549 if (members == null || members.length == 0) {
607 currentItems.setHeight(1); 550 this.currentItems.setHeight(1);
608 } 551 } else {
609 else {
610 int height = 0; 552 int height = 0;
611 553
612 for (Canvas member: members) { 554 for (final Canvas member : members) {
613 height += member.getHeight(); 555 height += member.getHeight();
614 } 556 }
615 557
616 currentItems.setHeight(height); 558 this.currentItems.setHeight(height);
617 } 559 }
618 } 560 }
619
620 561
621 /** 562 /**
622 * This method is called if the user clicks on the 'next' button to advance 563 * This method is called if the user clicks on the 'next' button to advance
623 * to the next state. 564 * to the next state.
624 * 565 *
625 * @param event The StepForwardEvent. 566 * @param event
567 * The StepForwardEvent.
626 */ 568 */
627 @Override 569 @Override
628 public void onStepForward(StepForwardEvent event) { 570 public void onStepForward(final StepForwardEvent event) {
629 GWT.log("CollectionView - onStepForward()"); 571 GWT.log("CollectionView - onStepForward()");
630 lockUI(); 572 lockUI();
631 573
632 Config config = Config.getInstance(); 574 final Config config = Config.getInstance();
633 String locale = config.getLocale(); 575 final String locale = config.getLocale();
634 576
635 forwardService.go(locale, artifact, event.getData(), 577 this.forwardService.go(locale, this.artifact, event.getData(), new AsyncCallback<Artifact>() {
636 new AsyncCallback<Artifact>() { 578 @Override
637 @Override 579 public void onFailure(final Throwable caught) {
638 public void onFailure(Throwable caught) { 580 unlockUI();
639 unlockUI(); 581 GWT.log("Could not feed the artifact.");
640 GWT.log("Could not feed the artifact."); 582 SC.warn(FLYS.getExceptionString(ParameterList.this.MSG, caught));
641 SC.warn(FLYS.getExceptionString(MSG, caught)); 583 }
642 } 584
643 585 @Override
644 @Override 586 public void onSuccess(final Artifact artifact) {
645 public void onSuccess(Artifact artifact) { 587 GWT.log("Successfully feed the artifact.");
646 GWT.log("Successfully feed the artifact."); 588 ParameterList.this.old.clear();
647 old.clear(); 589
648 590 setArtifact(artifact, true);
649 setArtifact(artifact, true); 591 unlockUI();
650 unlockUI(); 592 }
651 }
652 }); 593 });
653 } 594 }
654
655 595
656 /** 596 /**
657 * This method is used to remove all old items from this list after the user 597 * This method is used to remove all old items from this list after the user
658 * has clicked the step back button. 598 * has clicked the step back button.
659 * 599 *
660 * @param e The StepBackEvent that holds the identifier of the target state. 600 * @param e
601 * The StepBackEvent that holds the identifier of the target state.
661 */ 602 */
662 @Override 603 @Override
663 public void onStepBack(StepBackEvent e) { 604 public void onStepBack(final StepBackEvent e) {
664 lockUI(); 605 lockUI();
665 final String target = e.getTarget(); 606 final String target = e.getTarget();
666 607
667 Config config = Config.getInstance(); 608 final Config config = Config.getInstance();
668 final String locale = config.getLocale(); 609 final String locale = config.getLocale();
669 610
670 advanceService.advance(locale, artifact, target, 611 this.advanceService.advance(locale, this.artifact, target, new AsyncCallback<Artifact>() {
671 new AsyncCallback<Artifact>() { 612 @Override
672 @Override 613 public void onFailure(final Throwable caught) {
673 public void onFailure(Throwable caught) { 614 unlockUI();
674 unlockUI(); 615 GWT.log("Could not go back to '" + target + "'");
675 GWT.log("Could not go back to '" + target + "'"); 616 SC.warn(FLYS.getExceptionString(ParameterList.this.MSG, caught));
676 SC.warn(FLYS.getExceptionString(MSG, caught)); 617 }
677 } 618
678 619 @Override
679 @Override 620 public void onSuccess(final Artifact artifact) {
680 public void onSuccess(Artifact artifact) { 621 GWT.log("Successfully step back to '" + target + "'");
681 GWT.log("Successfully step back to '" + target + "'"); 622
682 623 ParameterList.this.old.clear();
683 old.clear(); 624
684 625 setArtifact(artifact, false);
685 setArtifact(artifact, false); 626 unlockUI();
686 unlockUI(); 627 }
687 } 628 });
688 } 629 }
689 );
690 }
691
692 630
693 @Override 631 @Override
694 public void onAdvance(final String target) { 632 public void onAdvance(final String target) {
695 Config config = Config.getInstance(); 633 final Config config = Config.getInstance();
696 final String locale = config.getLocale(); 634 final String locale = config.getLocale();
697 635
698 advanceService.advance(locale, artifact, target, 636 this.advanceService.advance(locale, this.artifact, target, new AsyncCallback<Artifact>() {
699 new AsyncCallback<Artifact>() { 637 @Override
700 @Override 638 public void onFailure(final Throwable caught) {
701 public void onFailure(Throwable caught) { 639 GWT.log("Could not go to '" + target + "'");
702 GWT.log("Could not go to '" + target + "'"); 640 SC.warn(FLYS.getExceptionString(ParameterList.this.MSG, caught));
703 SC.warn(FLYS.getExceptionString(MSG, caught)); 641 }
704 } 642
705 643 @Override
706 @Override 644 public void onSuccess(final Artifact artifact) {
707 public void onSuccess(Artifact artifact) { 645 GWT.log("Successfully advanced to '" + target + "'");
708 GWT.log("Successfully advanced to '" + target + "'"); 646
709 647 ParameterList.this.old.clear();
710 old.clear(); 648
711 649 setArtifact(artifact, true);
712 setArtifact(artifact, true); 650 }
713 } 651 });
714 } 652 }
715 );
716 }
717
718 653
719 /** 654 /**
720 * Implements the onCollectionChange() method to do update the GUI after the 655 * Implements the onCollectionChange() method to do update the GUI after the
721 * parameterization has changed. 656 * parameterization has changed.
722 * 657 *
723 * @param event The ParameterChangeEvent. 658 * @param event
659 * The ParameterChangeEvent.
724 */ 660 */
725 @Override 661 @Override
726 public void onParameterChange(ParameterChangeEvent event) { 662 public void onParameterChange(final ParameterChangeEvent event) {
727 GWT.log("ParameterList.onParameterChange"); 663 GWT.log("ParameterList.onParameterChange");
728 664
729 Canvas[] c = helperPanel.getMembers(); 665 final Canvas[] c = this.helperPanel.getMembers();
730 if (c != null && c.length > 0) { 666 if (c != null && c.length > 0) {
731 helperPanel.removeMembers(c); 667 this.helperPanel.removeMembers(c);
732 } 668 }
733 669
734 Artifact art = event.getNewValue(); 670 final Artifact art = event.getNewValue();
735 ArtifactDescription desc = art.getArtifactDescription(); 671 final ArtifactDescription desc = art.getArtifactDescription();
736 672
737 DataList currentData = desc.getCurrentData(); 673 final DataList currentData = desc.getCurrentData();
738 if (currentData != null) { 674 if (currentData != null) {
739 // the user has to enter some attributes 675 // the user has to enter some attributes
740 String uiProvider = currentData.getUIProvider(); 676 final String uiProvider = currentData.getUIProvider();
741 UIProvider provider = UIProviderFactory.getProvider( 677 final UIProvider provider = UIProviderFactory.getProvider(uiProvider, this.flys.getCurrentUser());
742 uiProvider, 678
743 flys.getCurrentUser()); 679 provider.setContainer(this.helperPanel);
744
745 provider.setContainer(helperPanel);
746 provider.setArtifact(art); 680 provider.setArtifact(art);
747 provider.setCollection(cView.getCollection()); 681 provider.setCollection(this.cView.getCollection());
748 provider.setParameterList(this); 682 provider.setParameterList(this);
749 683
750 ((HasStepForwardHandlers) provider).addStepForwardHandler(this); 684 ((HasStepForwardHandlers) provider).addStepForwardHandler(this);
751 ((HasStepBackHandlers) provider).addStepBackHandler(this); 685 ((HasStepBackHandlers) provider).addStepBackHandler(this);
752 686
753 setCurrentData(currentData, provider); 687 setCurrentData(currentData, provider);
754 } 688 } else {
755 else { 689 final String[] reachable = desc.getReachableStates();
756 String[] reachable = desc.getReachableStates();
757 if (reachable != null && reachable.length > 0) { 690 if (reachable != null && reachable.length > 0) {
758 // We have reached a final state with the option to step to 691 // We have reached a final state with the option to step to
759 // further to a next state. But in the current state, no user 692 // further to a next state. But in the current state, no user
760 // data is required. 693 // data is required.
761 UIProvider ui = UIProviderFactory.getProvider("continue", null); 694 final UIProvider ui = UIProviderFactory.getProvider("continue", null);
762 ui.setArtifact(art); 695 ui.setArtifact(art);
763 ui.setCollection(cView.getCollection()); 696 ui.setCollection(this.cView.getCollection());
764 ui.setParameterList(this); 697 ui.setParameterList(this);
765 698
766 ((ContinuePanel) ui).addAdvanceHandler(this); 699 ((ContinuePanel) ui).addAdvanceHandler(this);
767 700
768 setCurrentData(null, ui); 701 setCurrentData(null, ui);
769 } 702 } else {
770 else {
771 // we have reached a final state with no more user input 703 // we have reached a final state with no more user input
772 setCurrentData(null, null); 704 setCurrentData(null, null);
773 } 705 }
774 } 706 }
775 707
776 // FIXME: we got a whole artifact framework to separate ui and backend stuff, but in the end.... we have switches over specific datatypes here... 708 // FIXME: we got a whole artifact framework to separate ui and backend stuff, but in the end.... we have switches over
777 if (art instanceof WINFOArtifact 709 // specific datatypes here...
778 || art instanceof SINFOArtifact 710 if (art instanceof WINFOArtifact || art instanceof SINFOArtifact || art instanceof UINFOArtifact || art instanceof FixAnalysisArtifact
779 || art instanceof UINFOArtifact 711 || art instanceof BUNDUArtifact) {
780 || art instanceof FixAnalysisArtifact) {
781 createGaugePanel(); 712 createGaugePanel();
782 renderInfo(desc.getRiver(), desc.getOldData()); 713 renderInfo(desc.getRiver(), desc.getOldData());
783 } 714 } else if (art instanceof MINFOArtifact) {
784 else if (art instanceof MINFOArtifact) {
785 createMeasurementStationPanel(); 715 createMeasurementStationPanel();
786 renderInfo(desc.getRiver(), desc.getOldData()); 716 renderInfo(desc.getRiver(), desc.getOldData());
787 } 717 } else {
788 else {
789 removeInfoPanel(); 718 removeInfoPanel();
790 } 719 }
791 720
792 addOldDatas( 721 addOldDatas(desc.getOldData(), event.getType() == ParameterChangeEvent.Type.BACK);
793 desc.getOldData(), 722 }
794 event.getType() == ParameterChangeEvent.Type.BACK);
795 }
796
797 723
798 @Override 724 @Override
799 public void onCollectionChange(CollectionChangeEvent event) { 725 public void onCollectionChange(final CollectionChangeEvent event) {
800 Collection c = event.getNewValue(); 726 final Collection c = event.getNewValue();
801 Map<String, OutputMode> outs = c.getOutputModes(); 727 final Map<String, OutputMode> outs = c.getOutputModes();
802 Set<String> keys = outs.keySet(); 728 final Set<String> keys = outs.keySet();
803 729
804 OutputMode[] outputs = new OutputMode[outs.size()]; 730 final OutputMode[] outputs = new OutputMode[outs.size()];
805 731
806 int idx = 0; 732 int idx = 0;
807 for (String outname: keys) { 733 for (final String outname : keys) {
808 outputs[idx++] = outs.get(outname); 734 outputs[idx++] = outs.get(outname);
809 } 735 }
810 736
811 updateExportModes(c, getExportModes(outputs)); 737 updateExportModes(c, getExportModes(outputs));
812 updateReportModes(c, getReportModes(outputs)); 738 updateReportModes(c, getReportModes(outputs));
813 } 739 }
814 740
815
816 @Override 741 @Override
817 public void onOutputModesChange(OutputModesChangeEvent event) { 742 public void onOutputModesChange(final OutputModesChangeEvent event) {
818 743
819 Collection c = cView.getCollection(); 744 final Collection c = this.cView.getCollection();
820 745
821 if (c != null) { 746 if (c != null) {
822 OutputMode [] outs = event.getOutputModes(); 747 final OutputMode[] outs = event.getOutputModes();
823 updateExportModes(c, getExportModes(outs)); 748 updateExportModes(c, getExportModes(outs));
824 updateReportModes(c, getReportModes(outs)); 749 updateReportModes(c, getReportModes(outs));
825 } 750 }
826 } 751 }
827 752
828 753 protected List<ReportMode> getReportModes(final OutputMode[] outs) {
829 protected List<ReportMode> getReportModes(OutputMode [] outs) { 754
830 755 final List<ReportMode> reports = new ArrayList<ReportMode>();
831 List<ReportMode> reports = new ArrayList<ReportMode>();
832 756
833 if (outs == null || outs.length == 0) { 757 if (outs == null || outs.length == 0) {
834 return reports; 758 return reports;
835 } 759 }
836 760
837 for (OutputMode out: outs) { 761 for (final OutputMode out : outs) {
838 if (out instanceof ReportMode) { 762 if (out instanceof ReportMode) {
839 reports.add((ReportMode)out); 763 reports.add((ReportMode) out);
840 } 764 }
841 } 765 }
842 766
843 return reports; 767 return reports;
844 } 768 }
845 769
846 770 protected List<ExportMode> getExportModes(final OutputMode[] outs) {
847 protected List<ExportMode> getExportModes(OutputMode[] outs) { 771 final List<ExportMode> exports = new ArrayList<ExportMode>();
848 List<ExportMode> exports = new ArrayList<ExportMode>();
849 772
850 if (outs == null || outs.length == 0) { 773 if (outs == null || outs.length == 0) {
851 return exports; 774 return exports;
852 } 775 }
853 776
854 for (OutputMode out: outs) { 777 for (final OutputMode out : outs) {
855 if (out instanceof ExportMode) { 778 if (out instanceof ExportMode) {
856 exports.add((ExportMode) out); 779 exports.add((ExportMode) out);
857 } 780 }
858 } 781 }
859 782
860 return exports; 783 return exports;
861 } 784 }
862 785
863 786 protected void updateExportModes(final Collection c, final List<ExportMode> exports) {
864 protected void updateExportModes(Collection c, List<ExportMode> exports) { 787 final int num = exports != null ? exports.size() : 0;
865 int num = exports != null ? exports.size() : 0;
866 GWT.log("Update export modes: " + num); 788 GWT.log("Update export modes: " + num);
867 789
868 exportModes.removeMembers(exportModes.getMembers()); 790 this.exportModes.removeMembers(this.exportModes.getMembers());
869 791
870 if (exports.size() > 0) { 792 if (exports.size() > 0) {
871 exportModes.addMember(new ExportPanel(c, exports)); 793 this.exportModes.addMember(new ExportPanel(c, exports));
872 } 794 } else {
873 else { 795 this.exportModes.setHeight(1);
874 exportModes.setHeight(1); 796 }
875 } 797 }
876 } 798
877 799 protected void updateReportModes(final Collection c, final List<ReportMode> reports) {
878 protected void updateReportModes(Collection c, List<ReportMode> reports) { 800 final int num = reports != null ? reports.size() : 0;
879 int num = reports != null ? reports.size() : 0;
880 GWT.log("Update report modes: " + num); 801 GWT.log("Update report modes: " + num);
881 802
882 if (num == 0) { 803 if (num == 0) {
883 reportPanel.setContents(""); 804 this.reportPanel.setContents("");
884 return; 805 return;
885 } 806 }
886 807
887 Config config = Config.getInstance(); 808 final Config config = Config.getInstance();
888 String locale = config.getLocale(); 809 final String locale = config.getLocale();
889 810
890 String cid = c.identifier(); 811 final String cid = c.identifier();
891 812
892 for (ReportMode report: reports) { 813 for (final ReportMode report : reports) {
893 GWT.log("report '" + report.toString() + "'"); 814 GWT.log("report '" + report.toString() + "'");
894 815
895 reportService.report(cid, locale, report.getName(), 816 this.reportService.report(cid, locale, report.getName(), new AsyncCallback<String>() {
896 new AsyncCallback<String>() { 817 @Override
897 @Override 818 public void onFailure(final Throwable caught) {
898 public void onFailure(Throwable caught) { 819 SC.warn(FLYS.getExceptionString(ParameterList.this.MSG, caught));
899 SC.warn(FLYS.getExceptionString(MSG, caught)); 820 }
900 } 821
901 822 @Override
902 @Override 823 public void onSuccess(final String msg) {
903 public void onSuccess(String msg) { 824 setReportMessage(msg);
904 setReportMessage(msg); 825 }
905 } 826 });
906 }); 827 }
907 } 828 }
908 }
909
910 829
911 /** Sets content of reportPanel. */ 830 /** Sets content of reportPanel. */
912 protected void setReportMessage(String msg) { 831 protected void setReportMessage(String msg) {
913 GWT.log("returned from service: " + msg); 832 GWT.log("returned from service: " + msg);
914 if (msg == null) { 833 if (msg == null) {
915 msg = ""; 834 msg = "";
916 } 835 }
917 reportPanel.setContents(msg); 836 this.reportPanel.setContents(msg);
918 } 837 }
919
920 838
921 /** 839 /**
922 * Adds a table to the parameterlist to show calculated data. 840 * Adds a table to the parameterlist to show calculated data.
923 * 841 *
924 * @param table The table data panel. 842 * @param table
843 * The table data panel.
925 */ 844 */
926 public void setTable(TableDataPanel table) { 845 public void setTable(final TableDataPanel table) {
927 removeTable(); 846 removeTable();
928 847
929 Canvas c = table.create(); 848 final Canvas c = table.create();
930 c.setHeight100(); 849 c.setHeight100();
931 c.setWidth100(); 850 c.setWidth100();
932 851
933 tablePanel.addMember(c); 852 this.tablePanel.addMember(c);
934 } 853 }
935
936 854
937 public boolean hasTable() { 855 public boolean hasTable() {
938 Canvas[] members = tablePanel.getMembers(); 856 final Canvas[] members = this.tablePanel.getMembers();
939 857
940 return members != null && members.length > 0; 858 return members != null && members.length > 0;
941 } 859 }
942
943 860
944 /** 861 /**
945 * Removes the table from the parameter list. 862 * Removes the table from the parameter list.
946 */ 863 */
947 public void removeTable() { 864 public void removeTable() {
948 Canvas[] members = tablePanel.getMembers(); 865 final Canvas[] members = this.tablePanel.getMembers();
949 866
950 if (members != null && members.length > 0) { 867 if (members != null && members.length > 0) {
951 tablePanel.removeMembers(members); 868 this.tablePanel.removeMembers(members);
952 } 869 }
953 } 870 }
954 871
955 872 public void registerCollectionViewTabHandler(final TabSelectedHandler tsh) {
956 public void registerCollectionViewTabHandler(TabSelectedHandler tsh) {
957 this.cView.registerTabHandler(tsh); 873 this.cView.registerTabHandler(tsh);
958 } 874 }
959 875
960
961 protected void lockUI() { 876 protected void lockUI() {
962 cView.lockUI(); 877 this.cView.lockUI();
963 } 878 }
964
965 879
966 protected void unlockUI() { 880 protected void unlockUI() {
967 cView.unlockUI(); 881 this.cView.unlockUI();
968 } 882 }
969
970 883
971 private void createGaugePanel() { 884 private void createGaugePanel() {
972 GWT.log("ParameterList - createGaugePanel"); 885 GWT.log("ParameterList - createGaugePanel");
973 if (infoPanel == null) { 886 if (this.infoPanel == null) {
974 infoPanel = new GaugePanel(flys); 887 this.infoPanel = new GaugePanel(this.flys);
975 infoPanel.setWidth100(); 888 this.infoPanel.setWidth100();
976 infoPanel.setHeight100(); 889 this.infoPanel.setHeight100();
977 } 890 }
978 } 891 }
979 892
980 private void createMeasurementStationPanel() { 893 private void createMeasurementStationPanel() {
981 GWT.log("ParameterList - createMeasurementStationPanel"); 894 GWT.log("ParameterList - createMeasurementStationPanel");
982 if (infoPanel == null) { 895 if (this.infoPanel == null) {
983 infoPanel = new MeasurementStationPanel(flys); 896 this.infoPanel = new MeasurementStationPanel(this.flys);
984 infoPanel.setWidth100(); 897 this.infoPanel.setWidth100();
985 infoPanel.setHeight100(); 898 this.infoPanel.setHeight100();
986 } 899 }
987 } 900 }
988 901
989 private void showInfoPanel() { 902 private void showInfoPanel() {
990 GWT.log("ParameterList - showInfoPanel"); 903 GWT.log("ParameterList - showInfoPanel");
991 904
992 /* Don't add InfoPanel twice */ 905 /* Don't add InfoPanel twice */
993 SectionStackSection info = stack.getSection(InfoPanel.SECTION_ID); 906 SectionStackSection info = this.stack.getSection(InfoPanel.SECTION_ID);
994 if (info == null) { 907 if (info == null) {
995 info = new SectionStackSection(); 908 info = new SectionStackSection();
996 info.setTitle(infoPanel.getSectionTitle()); 909 info.setTitle(this.infoPanel.getSectionTitle());
997 info.setID(InfoPanel.SECTION_ID); 910 info.setID(InfoPanel.SECTION_ID);
998 info.setName(InfoPanel.SECTION_ID); 911 info.setName(InfoPanel.SECTION_ID);
999 info.setItems(infoPanel); 912 info.setItems(this.infoPanel);
1000 stack.addSection(info, 0); 913 this.stack.addSection(info, 0);
1001 } 914 }
1002 915
1003 info.setExpanded(true); 916 info.setExpanded(true);
1004 } 917 }
1005 918
1006 private void hideInfoPanel() { 919 private void hideInfoPanel() {
1007 GWT.log("ParameterList - hideInfoPanel"); 920 GWT.log("ParameterList - hideInfoPanel");
1008 921
1009 if (infoPanel != null) { 922 if (this.infoPanel != null) {
1010 infoPanel.hide(); 923 this.infoPanel.hide();
1011 } 924 }
1012 } 925 }
1013 926
1014 private void removeInfoPanel() { 927 private void removeInfoPanel() {
1015 GWT.log("ParameterList - removeInfoPanel"); 928 GWT.log("ParameterList - removeInfoPanel");
1016 SectionStackSection exists = stack.getSection(InfoPanel.SECTION_ID); 929 final SectionStackSection exists = this.stack.getSection(InfoPanel.SECTION_ID);
1017 if (exists != null) { 930 if (exists != null) {
1018 stack.removeSection(InfoPanel.SECTION_ID); 931 this.stack.removeSection(InfoPanel.SECTION_ID);
1019 } 932 }
1020 } 933 }
1021 934
1022 935 private void renderInfo(final String river, final DataList[] data) {
1023 private void renderInfo(String river, DataList[] data) {
1024 GWT.log("ParameterList - renderInfo"); 936 GWT.log("ParameterList - renderInfo");
1025 937
1026 if (river != null) { 938 if (river != null) {
1027 showInfoPanel(); 939 showInfoPanel();
1028 infoPanel.setRiver(river); 940 this.infoPanel.setRiver(river);
1029 infoPanel.setData(data); 941 this.infoPanel.setData(data);
1030 } 942 } else {
1031 else {
1032 GWT.log("ParameterList - renderInfo no river"); 943 GWT.log("ParameterList - renderInfo no river");
1033 hideInfoPanel(); 944 hideInfoPanel();
1034 } 945 }
1035 } 946 }
1036 } 947 }

http://dive4elements.wald.intevation.org