Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java @ 2983:725470fc57d2
Add "Manage themes" button to ChartToolbar and MapToolbar.
flys-client/trunk@4991 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Fri, 13 Jul 2012 11:31:25 +0000 |
parents | a805118fffa6 |
children | 6d749af6a9c2 |
comparison
equal
deleted
inserted
replaced
2982:d2a54ae0016b | 2983:725470fc57d2 |
---|---|
1 package de.intevation.flys.client.client.ui.chart; | 1 package de.intevation.flys.client.client.ui.chart; |
2 | 2 |
3 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
4 | |
5 import com.smartgwt.client.widgets.Button; | 4 import com.smartgwt.client.widgets.Button; |
6 import com.smartgwt.client.widgets.Canvas; | 5 import com.smartgwt.client.widgets.Canvas; |
7 import com.smartgwt.client.widgets.ImgButton; | 6 import com.smartgwt.client.widgets.ImgButton; |
8 import com.smartgwt.client.widgets.Label; | 7 import com.smartgwt.client.widgets.Label; |
9 import com.smartgwt.client.widgets.events.ClickEvent; | 8 import com.smartgwt.client.widgets.events.ClickEvent; |
28 | 27 |
29 protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); | 28 protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); |
30 | 29 |
31 public static final int PANEL_HEIGHT = 30; | 30 public static final int PANEL_HEIGHT = 30; |
32 | 31 |
33 protected ChartOutputTab chartTab; | 32 protected Button manageThemes; |
34 | |
35 protected Button datacage; | 33 protected Button datacage; |
36 | |
37 protected ImgLink downloadPNG; | 34 protected ImgLink downloadPNG; |
38 | |
39 protected ImgLink downloadPDF; | 35 protected ImgLink downloadPDF; |
40 | |
41 protected ImgLink downloadSVG; | 36 protected ImgLink downloadSVG; |
42 | |
43 protected Canvas downloadCSV; | 37 protected Canvas downloadCSV; |
44 | |
45 protected MousePositionPanel position; | 38 protected MousePositionPanel position; |
46 | |
47 protected ZoomboxControl zoombox; | 39 protected ZoomboxControl zoombox; |
48 | |
49 protected ImgButton zoomToMaxExtent; | 40 protected ImgButton zoomToMaxExtent; |
50 | |
51 protected ImgButton historyBack; | 41 protected ImgButton historyBack; |
52 | |
53 protected ImgButton zoomOut; | 42 protected ImgButton zoomOut; |
54 | |
55 protected ImgButton chartProperties; | 43 protected ImgButton chartProperties; |
56 | |
57 protected Button addPoints; | 44 protected Button addPoints; |
58 | |
59 protected Button addWSP; | 45 protected Button addWSP; |
60 | |
61 protected PanControl panControl; | 46 protected PanControl panControl; |
62 | 47 |
63 | 48 |
64 /** @param chartTab Output-Tab on which this toolbar is located. */ | 49 /** @param chartTab Output-Tab on which this toolbar is located. */ |
65 public ChartToolbar(ChartOutputTab chartTab) { | 50 public ChartToolbar(ChartOutputTab chartTab) { |
66 super(chartTab); | 51 super(chartTab); |
67 | 52 |
68 this.chartTab = chartTab; | 53 manageThemes = new Button(MSG.manageThemes()); |
69 datacage = new Button(MSG.databasket()); | 54 datacage = new Button(MSG.databasket()); |
70 position = new MousePositionPanel(chartTab); | 55 position = new MousePositionPanel(chartTab); |
71 zoombox = new ZoomboxControl(chartTab, MSG.zoom_in()); | 56 zoombox = new ZoomboxControl(chartTab, MSG.zoom_in()); |
72 zoomToMaxExtent = new ImgButton(); | 57 zoomToMaxExtent = new ImgButton(); |
73 zoomOut = new ImgButton(); | 58 zoomOut = new ImgButton(); |
74 historyBack = new ImgButton(); | 59 historyBack = new ImgButton(); |
75 panControl = new PanControl(chartTab, MSG.pan()); | 60 panControl = new PanControl(chartTab, MSG.pan()); |
76 chartProperties = new ImgButton(); | 61 chartProperties = new ImgButton(); |
77 addPoints = new Button(MSG.points()); | 62 addPoints = new Button(MSG.points()); |
78 | 63 |
79 if (this.chartTab.getMode().getName().equals("cross_section")) { | 64 if (chartTab.getMode().getName().equals("cross_section")) { |
80 addWSP = new Button(MSG.addWSPButton()); | 65 addWSP = new Button(MSG.addWSPButton()); |
81 addWSP.setTooltip(MSG.addWSPTooltip()); | 66 addWSP.setTooltip(MSG.addWSPTooltip()); |
82 final ChartOutputTab finalChartTab = chartTab; | 67 final ChartOutputTab finalChartTab = chartTab; |
83 addWSP.addClickHandler(new ClickHandler() { | 68 addWSP.addClickHandler(new ClickHandler() { |
69 @Override | |
84 public void onClick(ClickEvent ce) { | 70 public void onClick(ClickEvent ce) { |
85 new ManualWSPEditor(finalChartTab.getView().getCollection(), | 71 new ManualWSPEditor(finalChartTab.getView().getCollection(), |
86 finalChartTab, finalChartTab.getMode().getName()).show(); | 72 finalChartTab, finalChartTab.getMode().getName()).show(); |
87 }}); | 73 }}); |
88 } | 74 } |
89 | 75 |
90 addPoints.addClickHandler(new ClickHandler() { | 76 addPoints.addClickHandler(new ClickHandler() { |
77 @Override | |
91 public void onClick(ClickEvent event) { | 78 public void onClick(ClickEvent event) { |
92 openPointWindow(); | 79 openPointWindow(); |
93 } | 80 } |
94 }); | 81 }); |
95 addPoints.setTooltip(MSG.addPointsTooltip()); | 82 addPoints.setTooltip(MSG.addPointsTooltip()); |
96 | 83 |
84 manageThemes.addClickHandler(new ClickHandler() { | |
85 | |
86 @Override | |
87 public void onClick(ClickEvent event) { | |
88 getChartOutputTab().toggleThemePanel(); | |
89 } | |
90 }); | |
91 | |
97 datacage.addClickHandler(new ClickHandler() { | 92 datacage.addClickHandler(new ClickHandler() { |
93 @Override | |
98 public void onClick(ClickEvent event) { | 94 public void onClick(ClickEvent event) { |
99 GWT.log("Clicked 'datacage' button."); | 95 GWT.log("Clicked 'datacage' button."); |
100 openDatacageWindow((ChartOutputTab) getOutputTab()); | 96 openDatacageWindow((ChartOutputTab) getOutputTab()); |
101 } | 97 } |
102 }); | 98 }); |
132 downloadCSV.setTooltip(MSG.downloadCSVTooltip()); | 128 downloadCSV.setTooltip(MSG.downloadCSVTooltip()); |
133 | 129 |
134 zoomToMaxExtent.setSrc(baseUrl + MSG.zoom_all()); | 130 zoomToMaxExtent.setSrc(baseUrl + MSG.zoom_all()); |
135 adjustImageButton(zoomToMaxExtent); | 131 adjustImageButton(zoomToMaxExtent); |
136 zoomToMaxExtent.addClickHandler(new ClickHandler() { | 132 zoomToMaxExtent.addClickHandler(new ClickHandler() { |
133 @Override | |
137 public void onClick(ClickEvent event) { | 134 public void onClick(ClickEvent event) { |
138 getChartOutputTab().resetRanges(); | 135 getChartOutputTab().resetRanges(); |
139 // Relink the export buttons. | 136 // Relink the export buttons. |
140 onZoom(null); | 137 onZoom(null); |
141 } | 138 } |
143 zoomToMaxExtent.setTooltip(MSG.zoomToMaxExtentTooltip()); | 140 zoomToMaxExtent.setTooltip(MSG.zoomToMaxExtentTooltip()); |
144 | 141 |
145 zoomOut.setSrc(baseUrl + MSG.zoom_out()); | 142 zoomOut.setSrc(baseUrl + MSG.zoom_out()); |
146 adjustImageButton(zoomOut); | 143 adjustImageButton(zoomOut); |
147 zoomOut.addClickHandler(new ClickHandler() { | 144 zoomOut.addClickHandler(new ClickHandler() { |
145 @Override | |
148 public void onClick(ClickEvent event) { | 146 public void onClick(ClickEvent event) { |
149 getChartOutputTab().zoomOut(10); | 147 getChartOutputTab().zoomOut(10); |
150 // Relink the export buttons. | 148 // Relink the export buttons. |
151 onZoom(null); | 149 onZoom(null); |
152 } | 150 } |
154 zoomOut.setTooltip(MSG.zoomOutTooltip()); | 152 zoomOut.setTooltip(MSG.zoomOutTooltip()); |
155 | 153 |
156 historyBack.setSrc(baseUrl + MSG.zoom_back()); | 154 historyBack.setSrc(baseUrl + MSG.zoom_back()); |
157 adjustImageButton(historyBack); | 155 adjustImageButton(historyBack); |
158 historyBack.addClickHandler(new ClickHandler() { | 156 historyBack.addClickHandler(new ClickHandler() { |
157 @Override | |
159 public void onClick(ClickEvent event) { | 158 public void onClick(ClickEvent event) { |
160 getChartOutputTab().zoomOut(); | 159 getChartOutputTab().zoomOut(); |
161 // Relink the export buttons. | 160 // Relink the export buttons. |
162 onZoom(null); | 161 onZoom(null); |
163 } | 162 } |
165 historyBack.setTooltip(MSG.historyBackTooltip()); | 164 historyBack.setTooltip(MSG.historyBackTooltip()); |
166 | 165 |
167 zoombox.addZoomHandler(chartTab); | 166 zoombox.addZoomHandler(chartTab); |
168 zoombox.addZoomHandler(this); | 167 zoombox.addZoomHandler(this); |
169 zoombox.addClickHandler(new ClickHandler() { | 168 zoombox.addClickHandler(new ClickHandler() { |
169 @Override | |
170 public void onClick(ClickEvent event) { | 170 public void onClick(ClickEvent event) { |
171 panControl.deselect(); | 171 panControl.deselect(); |
172 } | 172 } |
173 }); | 173 }); |
174 zoombox.setTooltip(MSG.zoomboxTooltip()); | 174 zoombox.setTooltip(MSG.zoomboxTooltip()); |
175 | 175 |
176 panControl.addPanHandler(chartTab); | 176 panControl.addPanHandler(chartTab); |
177 panControl.addClickHandler(new ClickHandler() { | 177 panControl.addClickHandler(new ClickHandler() { |
178 @Override | |
178 public void onClick(ClickEvent event) { | 179 public void onClick(ClickEvent event) { |
179 zoombox.deselect(); | 180 zoombox.deselect(); |
180 } | 181 } |
181 }); | 182 }); |
182 panControl.setTooltip(MSG.panControlTooltip()); | 183 panControl.setTooltip(MSG.panControlTooltip()); |
183 | 184 |
184 chartProperties.setSrc(baseUrl + MSG.properties_ico()); | 185 chartProperties.setSrc(baseUrl + MSG.properties_ico()); |
185 adjustImageButton(chartProperties); | 186 adjustImageButton(chartProperties); |
186 chartProperties.addClickHandler(new ClickHandler() { | 187 chartProperties.addClickHandler(new ClickHandler() { |
188 @Override | |
187 public void onClick(ClickEvent event) { | 189 public void onClick(ClickEvent event) { |
188 openPropertiesEditor(); | 190 openPropertiesEditor(); |
189 } | 191 } |
190 }); | 192 }); |
191 chartProperties.setTooltip(MSG.chartPropertiesTooltip()); | 193 chartProperties.setTooltip(MSG.chartPropertiesTooltip()); |
192 | 194 |
193 initLayout(); | 195 initLayout(); |
194 addResizedHandler(new ResizedHandler() { | 196 addResizedHandler(new ResizedHandler() { |
197 @Override | |
195 public void onResized(ResizedEvent e) { | 198 public void onResized(ResizedEvent e) { |
196 if (getVisibleWidth() < 740) { | 199 if (getVisibleWidth() < 740) { |
197 setHeight(55); | 200 setHeight(55); |
198 } | 201 } |
199 else { | 202 else { |
215 imgButton.setShowDownIcon(false); | 218 imgButton.setShowDownIcon(false); |
216 imgButton.setShowFocusedIcon(false); | 219 imgButton.setShowFocusedIcon(false); |
217 } | 220 } |
218 | 221 |
219 | 222 |
220 public ChartOutputTab getChartOutputTab() { | 223 private ChartOutputTab getChartOutputTab() { |
221 return chartTab; | 224 return (ChartOutputTab)getOutputTab(); |
222 } | 225 } |
223 | 226 |
224 | 227 |
225 protected void initLayout() { | 228 protected void initLayout() { |
226 setWidth100(); | 229 setWidth100(); |
232 Label spacer = new Label(); | 235 Label spacer = new Label(); |
233 spacer.setWidth("*"); | 236 spacer.setWidth("*"); |
234 datacage.setWidth("95px"); | 237 datacage.setWidth("95px"); |
235 position.setWidth("200px"); | 238 position.setWidth("200px"); |
236 | 239 |
240 addMember(manageThemes); | |
237 addMember(datacage); | 241 addMember(datacage); |
238 addMember(downloadPNG); | 242 addMember(downloadPNG); |
239 addMember(downloadPDF); | 243 addMember(downloadPDF); |
240 addMember(downloadSVG); | 244 addMember(downloadSVG); |
241 addMember(downloadCSV); | 245 addMember(downloadCSV); |
245 addMember(zoombox); | 249 addMember(zoombox); |
246 addMember(panControl); | 250 addMember(panControl); |
247 addMember(chartProperties); | 251 addMember(chartProperties); |
248 addMember(addPoints); | 252 addMember(addPoints); |
249 | 253 |
250 if (this.chartTab.getMode().getName().equals("cross_section")) { | 254 if (getChartOutputTab().getMode().getName().equals("cross_section")) { |
251 addMember(addWSP); | 255 addMember(addWSP); |
252 } | 256 } |
253 | 257 |
254 addMember(spacer); | 258 addMember(spacer); |
255 addMember(position); | 259 addMember(position); |
265 } | 269 } |
266 | 270 |
267 | 271 |
268 /** Open editor for custom points. */ | 272 /** Open editor for custom points. */ |
269 protected void openPointWindow() { | 273 protected void openPointWindow() { |
270 if (this.chartTab.getMode().getName().equals("historical_discharge")) { | 274 ChartOutputTab chartTab = getChartOutputTab(); |
275 if (chartTab.getMode().getName().equals("historical_discharge")) { | |
271 new ManualDatePointsEditor(chartTab.getView().getCollection(), | 276 new ManualDatePointsEditor(chartTab.getView().getCollection(), |
272 this.chartTab, this.chartTab.getMode().getName()).show(); | 277 chartTab, chartTab.getMode().getName()).show(); |
273 } | 278 } |
274 else { | 279 else { |
275 new ManualPointsEditor(chartTab.getView().getCollection(), | 280 new ManualPointsEditor(chartTab.getView().getCollection(), |
276 this.chartTab, this.chartTab.getMode().getName()).show(); | 281 chartTab, chartTab.getMode().getName()).show(); |
277 } | 282 } |
278 } | 283 } |
279 | 284 |
280 | 285 |
281 /** | 286 /** |
282 * Sets new sources to the export button/images, such that the | 287 * Sets new sources to the export button/images, such that the |
283 * correct zoom values are included in the request when clicked. | 288 * correct zoom values are included in the request when clicked. |
284 * @param evt ignored. | 289 * @param evt ignored. |
285 */ | 290 */ |
291 @Override | |
286 public void onZoom(ZoomEvent evt) { | 292 public void onZoom(ZoomEvent evt) { |
293 ChartOutputTab chartTab = getChartOutputTab(); | |
287 downloadPNG.setSource(chartTab.getExportUrl(-1, -1, "png")); | 294 downloadPNG.setSource(chartTab.getExportUrl(-1, -1, "png")); |
288 downloadPDF.setSource(chartTab.getExportUrl(-1, -1, "pdf")); | 295 downloadPDF.setSource(chartTab.getExportUrl(-1, -1, "pdf")); |
289 downloadSVG.setSource(chartTab.getExportUrl(-1, -1, "svg")); | 296 downloadSVG.setSource(chartTab.getExportUrl(-1, -1, "svg")); |
290 } | 297 } |
291 | 298 |