annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/GaugePanel.java @ 3841:5877d6900e34

Refactor GaugeTree folding for different states flys-client/trunk@5556 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Bjoern Ricks <bjoern.ricks@intevation.de>
date Fri, 21 Sep 2012 13:19:21 +0000
parents cf64f54aa39c
children 44c1beb78ad1
rev   line source
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
2
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
3 import java.util.ArrayList;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
4 import java.util.Iterator;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
5 import java.util.List;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
6
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
7 import com.google.gwt.core.client.GWT;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
8 import com.google.gwt.i18n.client.NumberFormat;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
9 import com.google.gwt.user.client.rpc.AsyncCallback;
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
10 import com.google.gwt.user.client.ui.Anchor;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
11 import com.google.gwt.user.client.ui.DecoratorPanel;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
12 import com.google.gwt.user.client.ui.Grid;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
13 import com.google.gwt.user.client.ui.HorizontalPanel;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
14 import com.google.gwt.user.client.ui.Label;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
15 import com.google.gwt.user.client.ui.ScrollPanel;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
16 import com.google.gwt.user.client.ui.Tree;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
17 import com.google.gwt.user.client.ui.TreeItem;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
18
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.types.Overflow;
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
20 import com.smartgwt.client.widgets.events.ResizedEvent;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
21 import com.smartgwt.client.widgets.events.ResizedHandler;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
22 import com.smartgwt.client.widgets.layout.HLayout;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
23 import com.smartgwt.client.widgets.layout.SectionStackSection;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
24 import com.smartgwt.client.widgets.layout.VLayout;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
25
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
26 import de.intevation.flys.client.client.FLYSConstants;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
27 import de.intevation.flys.client.client.services.GaugeOverviewInfoService;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
28 import de.intevation.flys.client.client.services.GaugeOverviewInfoServiceAsync;
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
29 import de.intevation.flys.client.shared.model.Data;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
30 import de.intevation.flys.client.shared.model.DataItem;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
31 import de.intevation.flys.client.shared.model.DataList;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
32 import de.intevation.flys.client.shared.model.GaugeInfo;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
33 import de.intevation.flys.client.shared.model.RiverInfo;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
34
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
35 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
36 * The GaugePanel is intendet to be used within a SectionStackSection
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
37 * It extends the VLayout by two methods to show and hide the
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
38 * section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
39 */
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
40 public class GaugePanel extends VLayout implements ResizedHandler {
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
41
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
42 /** SectionStackSection where this GaugePanel belongs in*/
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
43 private SectionStackSection sectionStack;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
44
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
45 /** Name of the river */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
46 private String river;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
47
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
48 /** The message class that provides i18n strings.*/
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
49 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
50
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
51 protected GaugeOverviewInfoServiceAsync gaugeOverviewInfoService =
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
52 GWT.create(GaugeOverviewInfoService.class);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
53
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
54 protected GaugeTree gaugetree = new GaugeTree();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
55
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
56 protected RiverInfoPanel riverinfopanel;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
57
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
58 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
59 * Creates a new VLayout with a SectionStackSection
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
60 * The GaugePanel's SectionStackSection is hidden by default.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
61 * @param sectionStack The section stack section to place the VLayout in.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
62 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
63 public GaugePanel(SectionStackSection sectionStack) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
64 setOverflow(Overflow.HIDDEN);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
65 sectionStack.setHidden(true);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
66 sectionStack.setItems(this);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
67 this.sectionStack = sectionStack;
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
68 setStyleName("gaugepanel");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
69 addResizedHandler(this);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
70 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
71
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
72 /**
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
73 * Sets and loads the river data if river is not the current set river
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
74 */
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
75 public void setRiver(String river) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
76 if (!river.equals(this.river)) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
77 this.river = river;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
78 this.refresh();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
79 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
80 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
81
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
82 /**
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
83 * Sets the data and closes not corresponding folds in the gauge tree
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
84 */
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
85 public void setData(DataList[] data) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
86 gaugetree.setData(data);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
87 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
88
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
89 /**
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
90 * Loads the river info and renders it afterwards
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
91 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
92 public void refresh() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
93 gaugeOverviewInfoService.getRiverInfo(this.river, new AsyncCallback<RiverInfo>() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
94 public void onFailure(Throwable e) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
95 GWT.log("Could not load the river info." + e);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
96 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
97
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
98 public void onSuccess(RiverInfo riverinfo) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
99 GWT.log("Loaded river info");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
100 renderGaugeOverviewInfo(riverinfo);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
101 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
102 });
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
103 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
104
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
105 public void renderGaugeOverviewInfo(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
106 removeMembers(getMembers());
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
107
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
108 riverinfopanel = new RiverInfoPanel(riverinfo);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
109 addMember(riverinfopanel);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
110 addMember(gaugetree);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
111
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
112 gaugetree.setGauges(riverinfo);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
113 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
114
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
115 @Override
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
116 public void onResized(ResizedEvent event) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
117 /* this height calculation is only an approximation and doesn't reflect
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
118 * the real height of the the gaugetree. */
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
119 int height = getInnerContentHeight() -
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
120 (RiverInfoPanel.HEIGHT +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
121 (2 * RiverInfoPanel.BORDER_WIDTH) +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
122 (2 * RiverInfoPanel.PADDING) +
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
123 (2 * RiverInfoPanel.MARGIN));
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
124
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
125 if (height < 0) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
126 height = 0;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
127 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
128
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
129 gaugetree.setHeight("" + height + "px");
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
130 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
131
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
132
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
133 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
134 * Hide the section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
135 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
136 public void hide() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
137 GWT.log("GaugePanel - hide");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
138 this.sectionStack.setHidden(true);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
139 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
140
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
141 /**
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
142 * Show the section stack section.
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
143 */
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
144 public void show() {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
145 GWT.log("GaugePanel - show");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
146 this.sectionStack.setHidden(false);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
147 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
148
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
149 class GaugeTree extends ScrollPanel {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
150
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
151 private Tree tree;
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
152 private DataList[] data;
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
153
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
154 public GaugeTree() {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
155 tree = new Tree();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
156 setWidget(tree);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
157 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
158
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
159 /**
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
160 * Resets the items of the tree.
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
161 * If the list of gauges is empty or null the tree will be empty.
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
162 */
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
163 public void setGauges(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
164 tree.clear();
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
165
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
166 List<GaugeInfo> gauges = riverinfo.getGauges();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
167
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
168 if (gauges != null && !gauges.isEmpty()) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
169
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
170 ArrayList<GaugeInfo> emptygauges = new ArrayList<GaugeInfo>();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
171
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
172 if (!riverinfo.isKmUp()) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
173 for (GaugeInfo gauge : gauges) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
174 addGauge(gauge, emptygauges);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
175 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
176 }
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
177 else {
3834
52109c4bc5de Prevent AIOOB exception.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 3833
diff changeset
178 for (int i = gauges.size()-1; i >= 0; i--) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
179 GaugeInfo gauge = gauges.get(i);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
180 addGauge(gauge, emptygauges);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
181 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
182 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
183
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
184 // put empty gauges to the end
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
185 for (GaugeInfo gauge : emptygauges) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
186 addGauge(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
187 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
188
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
189 open();
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
190 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
191 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
192
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
193 private void addGauge(GaugeInfo gauge, List<GaugeInfo> empty) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
194 if (gauge.getKmStart() != null && gauge.getKmEnd() != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
195 addGauge(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
196 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
197 else {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
198 empty.add(gauge);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
199 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
200 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
201
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
202 private void addGauge(GaugeInfo gauge) {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
203 GaugeInfoItem gaugeitem = new GaugeInfoItem(gauge);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
204 tree.addItem(gaugeitem);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
205 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
206
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
207 public void openAll() {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
208 GWT.log("GaugeTree - openAll");
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
209 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
210 TreeItem item = it.next();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
211 item.setState(true);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
212 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
213 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
214
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
215 public void setData(DataList[] data) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
216 this.data = data;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
217 if (tree.getItemCount() > 0) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
218 open();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
219 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
220 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
221
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
222 public void open() {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
223 ArrayList<Double> locations = new ArrayList<Double>();
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
224
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
225 if (data != null && data.length > 0) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
226 for (int i = 0; i < data.length; i++) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
227 DataList dl = data[i];
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
228 String state = dl.getState();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
229 GWT.log("GaugeTree - setData " + state);
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
230 if (state.equals("state.winfo.location_distance")) {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
231 Double ldfrom = null;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
232 Double ldto = null;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
233
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
234 for (int j = dl.size()-1; j >= 0; --j) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
235 Data d = dl.get(j);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
236 String label = d.getLabel();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
237 GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
238 if (label.equals("ld_from")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
239 ldfrom = getDoubleValue(d);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
240 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
241 else if (label.equals("ld_to")) {
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
242 ldto = getDoubleValue(d);
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
243 }
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
244 else if (label.equals("ld_locations")) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
245 getLocationsFromData(locations, d);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
246 openOnLocations(locations);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
247 return;
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
248 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
249 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
250 if (ldfrom != null) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
251 openOnDistance(ldfrom, ldto);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
252 return;
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
253 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
254 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
255 else if(state.equals("state.winfo.distance_only") ||
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
256 state.equals("state.winfo.distance")) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
257 Double ldfrom = null;
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
258 Double ldto = null;
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
259
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
260 for (int j = dl.size()-1; j >= 0; --j) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
261 Data d = dl.get(j);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
262 String label = d.getLabel();
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
263 GWT.log("GaugeTree - setData - label " + label + " " + d.getStringValue());
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
264 if (label.equals("ld_from")) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
265 ldfrom = getDoubleValue(d);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
266 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
267 else if (label.equals("ld_to")) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
268 ldto = getDoubleValue(d);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
269 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
270 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
271
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
272 if (ldfrom != null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
273 openOnDistance(ldfrom, ldto);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
274 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
275 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
276 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
277 else if (state.equals("state.winfo.location")) {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
278 getLocations("ld_locations", locations, dl);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
279 openOnLocations(locations);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
280 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
281 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
282 else if (state.equals("state.winfo.reference.curve.input.start")) {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
283 getLocations("reference_startpoint", locations, dl);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
284 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
285 else if (state.equals("state.winfo.reference.curve.input.end")) {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
286 getLocations("reference_endpoint", locations, dl);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
287 }
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
288 else if (state.equals("state.winfo.historicalq.reference_gauge")) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
289 for (int j = dl.size()-1; j >= 0; --j) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
290 Data d = dl.get(j);
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
291 String label = d.getLabel();
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
292 if (label.equals("reference_gauge")) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
293 String tmp = d.getStringValue();
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
294 if (tmp != null) {
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
295 Integer gaugereference = Integer.valueOf(tmp);
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
296 if (gaugereference != null) {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
297 //TODO
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
298 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
299 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
300 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
301 }
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
302 }
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
303 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
304 }
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
305 if (!locations.isEmpty()) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
306 openOnLocations(locations);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
307 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
308 else {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
309 openAll();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
310 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
311 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
312
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
313 private void getLocations(String labelname, List<Double> locations, DataList dl) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
314 for (int j = dl.size()-1; j >= 0; --j) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
315 Data d = dl.get(j);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
316 String label = d.getLabel();
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
317 if (label.equals(labelname)) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
318 getLocationsFromData(locations, d);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
319 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
320 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
321 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
322
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
323 private void getLocationsFromData(List<Double> locations, Data data) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
324 DataItem[] items = data.getItems();
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
325 for (int k = 0; k < items.length; k++) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
326 String tmp = items[k].getStringValue();
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
327 GWT.log("GaugeTree - getLocationsFromData " + tmp);
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
328 if (tmp != null) {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
329 if (tmp.contains(" ")) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
330 // string contains several values ...
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
331 String[] values = tmp.split(" ");
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
332 for(int i=0; i < values.length; i++) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
333 Double value = Double.valueOf(values[i]);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
334 if (value != null) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
335 locations.add(value);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
336 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
337 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
338 }
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
339 else {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
340 Double value = Double.valueOf(tmp);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
341 if (value != null) {
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
342 locations.add(value);
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
343 }
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
344 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
345 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
346 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
347 }
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
348
3840
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
349 private Double getDoubleValue(Data d) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
350 String tmp = d.getStringValue();
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
351 if (tmp != null) {
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
352 return Double.valueOf(tmp);
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
353 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
354 return null;
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
355 }
cf64f54aa39c Refactor to avoid code duplication
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3839
diff changeset
356
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
357 public void openOnDistance(Double start, Double end) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
358 GWT.log("GaugeTree - openOnDistance " + start + " " + end + " " +
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
359 tree.getItemCount());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
360
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
361 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
362 TreeItem item = it.next();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
363 /* Strange stuff is happening here:
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
364 * GWT Tree.treeItemIterator returns another TreeItem for each
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
365 * GaugeInfoItem */
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
366 if (item instanceof GaugeInfoItem) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
367 boolean setstate = false;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
368 GaugeInfoItem gitem = (GaugeInfoItem)item;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
369 if (end == null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
370 if (gitem.getStart() >= start) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
371 setstate = true;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
372 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
373 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
374 else {
3841
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
375 GWT.log("GaugeTree - openOnDistance gitem " + gitem.getStart() + " " + gitem.getEnd());
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
376 if ((start >= gitem.getStart() && start <= gitem.getEnd()) ||
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
377 (end >= gitem.getStart() && end <= gitem.getEnd()) ||
5877d6900e34 Refactor GaugeTree folding for different states
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3840
diff changeset
378 (start <= gitem.getStart() && end >= gitem.getEnd())) {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
379 setstate = true;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
380 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
381 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
382 item.setState(setstate);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
383 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
384 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
385 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
386
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
387 public void openOnLocations(List<Double> locations) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
388 GWT.log("GaugeTree - openOnLocations " + locations + " " +
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
389 tree.getItemCount());
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
390
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
391 if (locations == null || locations.isEmpty()) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
392 return;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
393 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
394
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
395 for (Iterator<TreeItem> it = tree.treeItemIterator(); it.hasNext();) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
396 TreeItem item = it.next();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
397 if (item instanceof GaugeInfoItem) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
398 GaugeInfoItem gitem = (GaugeInfoItem)item;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
399 boolean isset = false;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
400 for (Double location: locations) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
401 if (locations == null) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
402 continue;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
403 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
404 if (location >= gitem.getStart() &&
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
405 location <= gitem.getEnd()) {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
406 isset = true;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
407 break;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
408 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
409 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
410 item.setState(isset);
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
411 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
412 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
413 }
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
414 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
415
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
416 class RiverInfoPanel extends HorizontalPanel {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
417
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
418 public final static int HEIGHT = 30;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
419 public final static int BORDER_WIDTH = 3;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
420 public final static int PADDING = 8;
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
421 public final static int MARGIN = 10;
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
422
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
423 public RiverInfoPanel(RiverInfo riverinfo) {
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
424 setStyleName("riverinfopanel");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
425 setHeight("" + HEIGHT + "px");
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
426 setVerticalAlignment(ALIGN_MIDDLE);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
427
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
428 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
429
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
430 addLabel(riverinfo.getName(), false);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
431
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
432 String kmtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
433 Double start = riverinfo.getKmStart();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
434 Double end = riverinfo.getKmEnd();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
435
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
436 if (!riverinfo.isKmUp()) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
437 Double tmp = end;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
438 end = start;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
439 start = tmp;
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
440 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
441 if (end != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
442 kmtext += nf.format(end);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
443 kmtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
444 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
445 if (start != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
446 kmtext += nf.format(start);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
447 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
448 kmtext += " km";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
449
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
450 addLabel(kmtext, false);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
451
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
452 String qtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
453 Double qmin = riverinfo.getMinQ();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
454 Double qmax = riverinfo.getMaxQ();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
455 if (qmin != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
456 qtext += nf.format(qmin);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
457 qtext += " " + MSG.gauge_q_unit();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
458 qtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
459 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
460 if (qmax != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
461 qtext += nf.format(qmax);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
462 qtext += " " + MSG.gauge_q_unit();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
463 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
464
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
465 addLabel(qtext, false);
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
466
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
467 Anchor anchor = new Anchor(MSG.gauge_river_info_link(), riverinfo.getInfoURL());
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
468 add(anchor);
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
469 }
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
470
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
471 private void addLabel(String text, boolean wordwrap) {
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
472 Label label = new Label(text, wordwrap);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
473 add(label);
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
474 setCellHeight(label, "" + HEIGHT + "px");
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
475 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
476 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
477
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
478 class GaugeInfoItem extends TreeItem {
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
479
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
480 private GaugeInfo gauge;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
481
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
482 public GaugeInfoItem(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
483 GaugeInfoHead gaugeinfohead = new GaugeInfoHead(gauge);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
484 GaugeInfoPanel gaugeinfopanel = new GaugeInfoPanel(gauge);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
485 setWidget(gaugeinfohead);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
486 addItem(gaugeinfopanel);
3837
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
487 this.gauge = gauge;
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
488 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
489
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
490 public Double getStart() {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
491 return gauge.getKmStart();
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
492 }
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
493
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
494 public Double getEnd() {
6b2ae2ec5b01 Open and close gauge tree folds that correspond to the selected WINFO
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3834
diff changeset
495 return gauge.getKmEnd();
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
496 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
497 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
498
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
499 class GaugeInfoHead extends HLayout {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
500
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
501 public GaugeInfoHead(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
502 setStyleName("gaugeinfohead");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
503 setAutoHeight();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
504 setAutoWidth();
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
505
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
506 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
507
3825
e91c5112d67c Implement a scrolling gauge info tree
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3716
diff changeset
508 Label label = new Label(gauge.getName(), true);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
509 addMember(label);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
510
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
511 Double start;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
512 Double end;
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
513
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
514 if (!gauge.isKmUp()) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
515 start = gauge.getKmStart();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
516 end = gauge.getKmEnd();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
517 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
518 else {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
519 start = gauge.getKmEnd();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
520 end = gauge.getKmStart();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
521 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
522
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
523 String kmtext = "";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
524 if (start != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
525 kmtext += nf.format(start);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
526 kmtext += " - ";
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
527 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
528 if (end != null) {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
529 kmtext += nf.format(end);
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
530 }
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
531 if (start != null || end != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
532 kmtext += " km";
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
533 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
534
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
535 label = new Label(kmtext);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
536
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
537 addMember(label);
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
538
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
539 Double station = gauge.getStation();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
540 if (station != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
541 String stext = nf.format(station);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
542 stext += " km";
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
543 label = new Label(stext);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
544 addMember(label);
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
545 }
3839
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
546
509ef6ec93af Add html links for the additinal river and gauge info pages
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3837
diff changeset
547 addMember(new Anchor(MSG.gauge_info_link(), gauge.getInfoURL()));
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
548 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
549 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
550
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
551 class GaugeInfoPanel extends DecoratorPanel {
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
552
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
553 public GaugeInfoPanel(GaugeInfo gauge) {
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
554 setStyleName("gaugeinfopanel");
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
555 Grid grid = new Grid(4, 2);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
556
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
557 NumberFormat nf = NumberFormat.getDecimalFormat();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
558
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
559 Double minw = gauge.getMinW();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
560 Double maxw = gauge.getMaxW();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
561 if (minw != null && maxw != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
562 grid.setText(0, 0, MSG.wq_value_q());
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
563 grid.setText(0, 1, "" + nf.format(minw) +
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
564 " - " + nf.format(maxw));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
565 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
566
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
567 Double minq = gauge.getMinQ();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
568 Double maxq = gauge.getMaxQ();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
569 if (minq != null && maxq != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
570 grid.setText(1, 0, MSG.wq_value_w());
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
571 grid.setText(1, 1, "" + nf.format(minq) +
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
572 " - " + nf.format(maxq));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
573 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
574
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
575 Double aeo = gauge.getAeo();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
576 if (aeo != null) {
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
577 grid.setText(2, 0, "AEO [kmĀ²]");
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
578 grid.setText(2, 1, "" + nf.format(aeo));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
579 }
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
580
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
581 Double datum = gauge.getDatum();
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
582 if (datum != null) {
3831
dc505433173f Use the wstunit from the river as unit for the Pegelnullpunkt
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3828
diff changeset
583 grid.setText(3, 0, MSG.gauge_zero() + " [" +
dc505433173f Use the wstunit from the river as unit for the Pegelnullpunkt
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3828
diff changeset
584 gauge.getWstUnit() + "]");
3828
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
585 grid.setText(3, 1, "" + nf.format(datum));
9cbc8311e820 Improve the GaugePanel
Bjoern Ricks <bjoern.ricks@intevation.de>
parents: 3825
diff changeset
586 }
3715
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
587
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
588 setWidget(grid);
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
589 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
590 }
8d3e48f189d2 Add first draft for the gauge overview info ui
Bjoern Ricks <bjoern.ricks@intevation.de>
parents:
diff changeset
591 }

http://dive4elements.wald.intevation.org