Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/stationinfo/InfoPanel.java @ 4956:f46a07c11324
Refactor Pegel- and Messtelleninfo in client ui
Use SmartGWT ListGrid instead of GWT Tree to display the station entires.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Fri, 01 Feb 2013 16:32:48 +0100 |
parents | |
children | e70ff0a600a3 |
comparison
equal
deleted
inserted
replaced
4950:4c7acc3a4ae1 | 4956:f46a07c11324 |
---|---|
1 package de.intevation.flys.client.client.ui.stationinfo; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 | |
5 import com.smartgwt.client.types.Overflow; | |
6 import com.smartgwt.client.widgets.Canvas; | |
7 import com.smartgwt.client.widgets.layout.SectionStackSection; | |
8 import com.smartgwt.client.widgets.layout.VLayout; | |
9 import de.intevation.flys.client.client.FLYSConstants; | |
10 import de.intevation.flys.client.client.services.RiverInfoService; | |
11 import de.intevation.flys.client.client.services.RiverInfoServiceAsync; | |
12 import de.intevation.flys.client.client.ui.RiverInfoPanel; | |
13 import de.intevation.flys.client.shared.model.DataList; | |
14 import de.intevation.flys.client.shared.model.RiverInfo; | |
15 | |
16 /** | |
17 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> | |
18 */ | |
19 public abstract class InfoPanel extends VLayout { | |
20 | |
21 /** SectionStackSection where this InfoPanel belongs in*/ | |
22 protected SectionStackSection section; | |
23 | |
24 /** Name of the river */ | |
25 protected String river; | |
26 | |
27 /** The message class that provides i18n strings.*/ | |
28 protected FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
29 | |
30 protected RiverInfoServiceAsync riverInfoService = GWT.create(RiverInfoService.class); | |
31 | |
32 /** Panel to show the info about the river */ | |
33 protected RiverInfoPanel riverinfopanel; | |
34 | |
35 protected InfoListGrid listgrid; | |
36 | |
37 public final static String SECTION_ID = "InfoPanelSection"; | |
38 | |
39 public InfoPanel(InfoListGrid listgrid) { | |
40 SectionStackSection section = new SectionStackSection(); | |
41 section.setExpanded(false); | |
42 section.setTitle(getSectionTitle()); | |
43 section.setName(SECTION_ID); | |
44 section.setID(SECTION_ID); | |
45 | |
46 setOverflow(Overflow.HIDDEN); | |
47 setStyleName("infopanel"); | |
48 | |
49 section.setHidden(true); | |
50 section.setItems(this); | |
51 this.section = section; | |
52 this.listgrid = listgrid; | |
53 this.addMember(listgrid); | |
54 } | |
55 | |
56 /** | |
57 * Sets and loads the river data if river is not the current set river | |
58 */ | |
59 public void setRiver(String river) { | |
60 if (!river.equals(this.river)) { | |
61 this.river = river; | |
62 this.refresh(); | |
63 } | |
64 } | |
65 | |
66 /** | |
67 * Sets the data and closes not corresponding folds in the gauge tree | |
68 */ | |
69 public void setData(DataList[] data) { | |
70 this.listgrid.setData(data); | |
71 } | |
72 | |
73 protected void render(RiverInfo riverinfo) { | |
74 if (this.riverinfopanel == null) { | |
75 this.riverinfopanel = new RiverInfoPanel(riverinfo); | |
76 | |
77 this.addMember(this.riverinfopanel, 0); | |
78 } | |
79 else { | |
80 riverinfopanel.setRiverInfo(riverinfo); | |
81 } | |
82 this.listgrid.setRiverInfo(riverinfo); | |
83 } | |
84 | |
85 /** | |
86 * Hide the section stack section. | |
87 */ | |
88 @Override | |
89 public void hide() { | |
90 GWT.log("InfoPanel - hide"); | |
91 this.section.setHidden(true); | |
92 } | |
93 | |
94 /** | |
95 * Show the section stack section. | |
96 */ | |
97 @Override | |
98 public void show() { | |
99 GWT.log("InfoPanel - show"); | |
100 this.section.setHidden(false); | |
101 } | |
102 | |
103 @Override | |
104 public void addMember(Canvas component) { | |
105 super.addMember(component); | |
106 expand(); | |
107 } | |
108 | |
109 @Override | |
110 public void removeMembers(Canvas[] components) { | |
111 super.removeMembers(components); | |
112 contract(); | |
113 } | |
114 | |
115 public SectionStackSection getSection() { | |
116 return this.section; | |
117 } | |
118 | |
119 protected void removeAllMembers() { | |
120 removeMembers(getMembers()); | |
121 } | |
122 | |
123 /** | |
124 * Expands the gauge section | |
125 */ | |
126 public void expand() { | |
127 section.setExpanded(true); | |
128 } | |
129 | |
130 /** | |
131 * Contracts/shrinks the expanded gauge section | |
132 */ | |
133 public void contract() { | |
134 section.setExpanded(false); | |
135 } | |
136 | |
137 protected abstract void refresh(); | |
138 | |
139 protected abstract String getSectionTitle(); | |
140 } |