comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugeTree.java @ 3865:436eec3be6ff

Allow to create a discharge curve from a gauge info This is only a draft yet. flys-client/trunk@5639 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 28 Sep 2012 08:57:48 +0000
parents f3b821735e39
children 989f6f0d1986
comparison
equal deleted inserted replaced
3864:c434dd2e84cf 3865:436eec3be6ff
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.List; 4 import java.util.List;
5 import java.util.Iterator; 5 import java.util.Iterator;
6 6
7 import com.google.gwt.core.client.GWT; 7 import com.google.gwt.core.client.GWT;
8 import com.google.gwt.event.dom.client.ClickEvent;
9 import com.google.gwt.event.dom.client.ClickHandler;
8 import com.google.gwt.i18n.client.NumberFormat; 10 import com.google.gwt.i18n.client.NumberFormat;
9 import com.google.gwt.user.client.ui.Anchor; 11 import com.google.gwt.user.client.ui.Anchor;
10 import com.google.gwt.user.client.ui.DecoratorPanel; 12 import com.google.gwt.user.client.ui.DecoratorPanel;
11 import com.google.gwt.user.client.ui.Grid; 13 import com.google.gwt.user.client.ui.Grid;
12 import com.google.gwt.user.client.ui.Label; 14 import com.google.gwt.user.client.ui.Label;
14 import com.google.gwt.user.client.ui.Tree; 16 import com.google.gwt.user.client.ui.Tree;
15 import com.google.gwt.user.client.ui.TreeItem; 17 import com.google.gwt.user.client.ui.TreeItem;
16 18
17 import com.smartgwt.client.widgets.layout.HLayout; 19 import com.smartgwt.client.widgets.layout.HLayout;
18 20
21 import de.intevation.flys.client.client.FLYS;
19 import de.intevation.flys.client.client.FLYSConstants; 22 import de.intevation.flys.client.client.FLYSConstants;
20 23
21 import de.intevation.flys.client.shared.model.Data; 24 import de.intevation.flys.client.shared.model.Data;
22 import de.intevation.flys.client.shared.model.DataItem; 25 import de.intevation.flys.client.shared.model.DataItem;
23 import de.intevation.flys.client.shared.model.DataList; 26 import de.intevation.flys.client.shared.model.DataList;
25 import de.intevation.flys.client.shared.model.RiverInfo; 28 import de.intevation.flys.client.shared.model.RiverInfo;
26 29
27 30
28 public class GaugeTree extends ScrollPanel { 31 public class GaugeTree extends ScrollPanel {
29 32
33 private FLYS flys;
30 private Tree tree; 34 private Tree tree;
31 private DataList[] data; 35 private DataList[] data;
32 36
33 /** The message class that provides i18n strings.*/ 37 /** The message class that provides i18n strings.*/
34 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); 38 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
35 39
36 public GaugeTree() { 40 public GaugeTree(FLYS flys) {
41 this.flys = flys;
37 tree = new Tree(); 42 tree = new Tree();
38 setWidget(tree); 43 setWidget(tree);
39 } 44 }
40 45
41 /** 46 /**
80 empty.add(gauge); 85 empty.add(gauge);
81 } 86 }
82 } 87 }
83 88
84 private void addGauge(GaugeInfo gauge) { 89 private void addGauge(GaugeInfo gauge) {
85 GaugeInfoItem gaugeitem = new GaugeInfoItem(gauge); 90 GaugeInfoItem gaugeitem = new GaugeInfoItem(flys, gauge);
86 tree.addItem(gaugeitem); 91 tree.addItem(gaugeitem);
87 } 92 }
88 93
89 public void openAll() { 94 public void openAll() {
90 GWT.log("GaugeTree - openAll"); 95 GWT.log("GaugeTree - openAll");
313 318
314 class GaugeInfoItem extends TreeItem { 319 class GaugeInfoItem extends TreeItem {
315 320
316 private GaugeInfo gauge; 321 private GaugeInfo gauge;
317 322
318 public GaugeInfoItem(GaugeInfo gauge) { 323 public GaugeInfoItem(FLYS flys, GaugeInfo gauge) {
319 GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge); 324 GaugeInfoHead gaugeinfohead = new GaugeInfoHead(flys, gauge);
320 GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge); 325 GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge);
321 setWidget(gaugeinfohead); 326 setWidget(gaugeinfohead);
322 addItem(gaugeinfopanel); 327 addItem(gaugeinfopanel);
323 this.gauge = gauge; 328 this.gauge = gauge;
324 } 329 }
336 } 341 }
337 } 342 }
338 343
339 class GaugeInfoHead extends HLayout { 344 class GaugeInfoHead extends HLayout {
340 345
341 public GaugeInfoHead(GaugeInfo gauge) { 346 public GaugeInfoHead(FLYS flys, GaugeInfo gauge) {
342 setStyleName("gaugeinfohead"); 347 setStyleName("gaugeinfohead");
343 setAutoHeight(); 348 setAutoHeight();
344 setAutoWidth(); 349 setAutoWidth();
345 350
346 NumberFormat nf = NumberFormat.getDecimalFormat(); 351 NumberFormat nf = NumberFormat.getDecimalFormat();
388 String url = number != null ? 393 String url = number != null ?
389 MSG.gauge_url() + number : 394 MSG.gauge_url() + number :
390 MSG.gauge_url(); 395 MSG.gauge_url();
391 Anchor anchor = new Anchor(MSG.gauge_info_link(), url); 396 Anchor anchor = new Anchor(MSG.gauge_info_link(), url);
392 addMember(anchor); 397 addMember(anchor);
398
399 addMember(new GaugeCurveAnchor(flys, gauge));
400 }
401 }
402
403 class GaugeCurveAnchor extends Anchor implements ClickHandler {
404
405 private FLYS flys;
406 private GaugeInfo gauge;
407
408 public GaugeCurveAnchor(FLYS flys, GaugeInfo gauge) {
409 super(MSG.gauge_curve_link());
410 this.flys = flys;
411 this.gauge = gauge;
412
413 addClickHandler(this);
414 }
415
416 public void onClick(ClickEvent ev) {
417 GWT.log("GaugeCurveAnchor - onClick " + gauge.getRiverName() +
418 " " + gauge.getOfficialNumber());
419 flys.newGaugeDischargeCurve(gauge.getRiverName(),
420 gauge.getOfficialNumber());
393 } 421 }
394 } 422 }
395 423
396 class GaugeInfoPanel extends DecoratorPanel { 424 class GaugeInfoPanel extends DecoratorPanel {
397 425

http://dive4elements.wald.intevation.org