Mercurial > dive4elements > river
comparison flys-client/src/main/java/org/dive4elements/river/client/client/ui/chart/ChartToolbar.java @ 5834:f507086aa94b
Repaired internal references.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 12:31:32 +0200 |
parents | flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ChartToolbar.java@3b974a24a8e1 |
children | 821a02bbfb4e |
comparison
equal
deleted
inserted
replaced
5833:a2bdc0f524e8 | 5834:f507086aa94b |
---|---|
1 package de.intevation.flys.client.client.ui.chart; | |
2 | |
3 import com.google.gwt.core.client.GWT; | |
4 | |
5 import com.smartgwt.client.widgets.Button; | |
6 import com.smartgwt.client.widgets.Canvas; | |
7 import com.smartgwt.client.widgets.ImgButton; | |
8 import com.smartgwt.client.widgets.Label; | |
9 import com.smartgwt.client.widgets.events.ClickEvent; | |
10 import com.smartgwt.client.widgets.events.ClickHandler; | |
11 | |
12 import de.intevation.flys.client.client.Config; | |
13 import de.intevation.flys.client.client.FLYSConstants; | |
14 import de.intevation.flys.client.client.event.ZoomEvent; | |
15 import de.intevation.flys.client.client.event.ZoomHandler; | |
16 import de.intevation.flys.client.client.ui.ImgLink; | |
17 import de.intevation.flys.client.client.ui.Toolbar; | |
18 | |
19 | |
20 /** | |
21 * Toolbar with buttons/icons to open datacage, switch to zoom mode, zoom out | |
22 * etc. | |
23 * | |
24 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
25 */ | |
26 public class ChartToolbar extends Toolbar implements ZoomHandler { | |
27 | |
28 protected static FLYSConstants MSG = GWT.create(FLYSConstants.class); | |
29 | |
30 public static final int PANEL_HEIGHT = 35; | |
31 | |
32 protected Button manageThemes; | |
33 protected Button datacage; | |
34 protected ImgLink downloadPNG; | |
35 protected ImgLink downloadPDF; | |
36 protected ImgLink downloadSVG; | |
37 protected Canvas downloadCSV; | |
38 protected MousePositionPanel position; | |
39 protected ZoomboxControl zoombox; | |
40 protected ImgButton zoomToMaxExtent; | |
41 protected ImgButton historyBack; | |
42 protected ImgButton zoomOut; | |
43 protected ImgButton chartProperties; | |
44 protected Button addPoints; | |
45 protected Button addWSP; | |
46 protected ImgLink exportAT; | |
47 protected PanControl panControl; | |
48 | |
49 | |
50 /** @param chartTab Output-Tab on which this toolbar is located. */ | |
51 public ChartToolbar(ChartOutputTab chartTab) { | |
52 super(chartTab); | |
53 initTools(); | |
54 } | |
55 | |
56 | |
57 protected void initTools() { | |
58 ChartOutputTab chartTab = getChartOutputTab(); | |
59 | |
60 manageThemes = new Button(MSG.manageThemes()); | |
61 datacage = new Button(MSG.databasket()); | |
62 position = new MousePositionPanel(chartTab); | |
63 zoombox = new ZoomboxControl(chartTab, MSG.zoom_in()); | |
64 zoomToMaxExtent = new ImgButton(); | |
65 zoomOut = new ImgButton(); | |
66 historyBack = new ImgButton(); | |
67 panControl = new PanControl(chartTab, MSG.pan()); | |
68 chartProperties = new ImgButton(); | |
69 addPoints = new Button(MSG.points()); | |
70 | |
71 if (chartTab.getMode().getName().equals("cross_section")) { | |
72 addWSP = new Button(MSG.addWSPButton()); | |
73 addWSP.setTooltip(MSG.addWSPTooltip()); | |
74 final ChartOutputTab finalChartTab = chartTab; | |
75 addWSP.addClickHandler(new ClickHandler() { | |
76 @Override | |
77 public void onClick(ClickEvent ce) { | |
78 new ManualWSPEditor(finalChartTab.getView().getCollection(), | |
79 finalChartTab, finalChartTab.getMode().getName()).show(); | |
80 }}); | |
81 } | |
82 | |
83 addPoints.addClickHandler(new ClickHandler() { | |
84 @Override | |
85 public void onClick(ClickEvent event) { | |
86 openPointWindow(); | |
87 } | |
88 }); | |
89 addPoints.setTooltip(MSG.addPointsTooltip()); | |
90 | |
91 manageThemes.addClickHandler(new ClickHandler() { | |
92 | |
93 @Override | |
94 public void onClick(ClickEvent event) { | |
95 getChartOutputTab().toggleThemePanel(); | |
96 } | |
97 }); | |
98 | |
99 datacage.addClickHandler(new ClickHandler() { | |
100 @Override | |
101 public void onClick(ClickEvent event) { | |
102 GWT.log("Clicked 'datacage' button."); | |
103 openDatacageWindow((ChartOutputTab) getOutputTab()); | |
104 } | |
105 }); | |
106 | |
107 String baseUrl = GWT.getHostPageBaseURL(); | |
108 String moduleUrl = GWT.getModuleBaseURL(); | |
109 Config config = Config.getInstance(); | |
110 | |
111 if (chartTab.getMode().getName().equals("fix_wq_curve")) { | |
112 exportAT = new ImgLink( | |
113 baseUrl + MSG.downloadCSV(), | |
114 moduleUrl + "export" + | |
115 "?uuid=" + chartTab.getCollection().identifier() + | |
116 "&name=" + chartTab.getMode().getName() + | |
117 "&mode=" + chartTab.getMode().getName() + "_at_export" + | |
118 "&type=at" + | |
119 "&server=" + config.getServerUrl() + | |
120 "&locale=" + config.getLocale() + | |
121 "&km=" + chartTab.getCollectionView().getCurrentKm(), | |
122 20, | |
123 20 | |
124 ); | |
125 exportAT.setTooltip(MSG.exportATTooltip()); | |
126 } | |
127 | |
128 downloadPNG = new ImgLink( | |
129 baseUrl + MSG.downloadPNG(), | |
130 chartTab.getExportUrl(-1, -1, "png"), | |
131 20, | |
132 20); | |
133 downloadPNG.setTooltip(MSG.downloadPNGTooltip()); | |
134 | |
135 downloadPDF = new ImgLink( | |
136 baseUrl + MSG.downloadPDF(), | |
137 chartTab.getExportUrl(1280, 1024, "pdf"), | |
138 20, | |
139 20); | |
140 downloadPDF.setTooltip(MSG.downloadPDFTooltip()); | |
141 | |
142 downloadSVG = new ImgLink( | |
143 baseUrl + MSG.downloadSVG(), | |
144 chartTab.getExportUrl(1280, 1024, "svg"), | |
145 20, | |
146 20); | |
147 downloadSVG.setTooltip(MSG.downloadSVGTooltip()); | |
148 | |
149 downloadCSV = new ImgLink( | |
150 baseUrl + MSG.downloadCSV(), | |
151 chartTab.getExportUrl(-1, -1, "csv"), | |
152 20, | |
153 20); | |
154 downloadCSV.setTooltip(MSG.downloadCSVTooltip()); | |
155 | |
156 zoomToMaxExtent.setSrc(baseUrl + MSG.zoom_all()); | |
157 adjustImageButton(zoomToMaxExtent); | |
158 zoomToMaxExtent.addClickHandler(new ClickHandler() { | |
159 @Override | |
160 public void onClick(ClickEvent event) { | |
161 getChartOutputTab().resetRanges(); | |
162 // Relink the export buttons. | |
163 onZoom(null); | |
164 } | |
165 }); | |
166 zoomToMaxExtent.setTooltip(MSG.zoomToMaxExtentTooltip()); | |
167 | |
168 zoomOut.setSrc(baseUrl + MSG.zoom_out()); | |
169 adjustImageButton(zoomOut); | |
170 zoomOut.addClickHandler(new ClickHandler() { | |
171 @Override | |
172 public void onClick(ClickEvent event) { | |
173 getChartOutputTab().zoomOut(10); | |
174 // Relink the export buttons. | |
175 onZoom(null); | |
176 } | |
177 }); | |
178 zoomOut.setTooltip(MSG.zoomOutTooltip()); | |
179 | |
180 historyBack.setSrc(baseUrl + MSG.zoom_back()); | |
181 adjustImageButton(historyBack); | |
182 historyBack.addClickHandler(new ClickHandler() { | |
183 @Override | |
184 public void onClick(ClickEvent event) { | |
185 getChartOutputTab().zoomOut(); | |
186 // Relink the export buttons. | |
187 onZoom(null); | |
188 } | |
189 }); | |
190 historyBack.setTooltip(MSG.historyBackTooltip()); | |
191 | |
192 zoombox.addZoomHandler(chartTab); | |
193 zoombox.addZoomHandler(this); | |
194 zoombox.addClickHandler(new ClickHandler() { | |
195 @Override | |
196 public void onClick(ClickEvent event) { | |
197 panControl.deselect(); | |
198 } | |
199 }); | |
200 zoombox.setTooltip(MSG.zoomboxTooltip()); | |
201 | |
202 panControl.addPanHandler(chartTab); | |
203 panControl.addClickHandler(new ClickHandler() { | |
204 @Override | |
205 public void onClick(ClickEvent event) { | |
206 zoombox.deselect(); | |
207 } | |
208 }); | |
209 panControl.setTooltip(MSG.panControlTooltip()); | |
210 | |
211 chartProperties.setSrc(baseUrl + MSG.properties_ico()); | |
212 adjustImageButton(chartProperties); | |
213 chartProperties.addClickHandler(new ClickHandler() { | |
214 @Override | |
215 public void onClick(ClickEvent event) { | |
216 openPropertiesEditor(); | |
217 } | |
218 }); | |
219 chartProperties.setTooltip(MSG.chartPropertiesTooltip()); | |
220 | |
221 initLayout(); | |
222 } | |
223 | |
224 /** Set width, height and other properties of an imagebutton. */ | |
225 public void adjustImageButton(ImgButton imgButton) { | |
226 imgButton.setWidth(20); | |
227 imgButton.setHeight(20); | |
228 imgButton.setShowDown(false); | |
229 imgButton.setShowRollOver(false); | |
230 imgButton.setShowRollOverIcon(false); | |
231 imgButton.setShowDisabled(false); | |
232 imgButton.setShowDisabledIcon(true); | |
233 imgButton.setShowDownIcon(false); | |
234 imgButton.setShowFocusedIcon(false); | |
235 } | |
236 | |
237 | |
238 protected ChartOutputTab getChartOutputTab() { | |
239 return (ChartOutputTab)getOutputTab(); | |
240 } | |
241 | |
242 | |
243 protected void initLayout() { | |
244 setWidth100(); | |
245 setHeight(PANEL_HEIGHT); | |
246 setMembersMargin(10); | |
247 setPadding(5); | |
248 setBorder("1px solid black"); | |
249 | |
250 Label spacer = new Label(); | |
251 spacer.setWidth("*"); | |
252 datacage.setWidth("95px"); | |
253 position.setWidth("200px"); | |
254 | |
255 addMember(manageThemes); | |
256 addMember(datacage); | |
257 addMember(downloadPNG); | |
258 addMember(downloadPDF); | |
259 addMember(downloadSVG); | |
260 addMember(downloadCSV); | |
261 if (getChartOutputTab().getMode().getName().equals("fix_wq_curve")) { | |
262 addMember(exportAT); | |
263 } | |
264 addMember(zoomToMaxExtent); | |
265 addMember(historyBack); | |
266 addMember(zoomOut); | |
267 addMember(zoombox); | |
268 addMember(panControl); | |
269 addMember(chartProperties); | |
270 addMember(addPoints); | |
271 | |
272 if (getChartOutputTab().getMode().getName().equals("cross_section")) { | |
273 addMember(addWSP); | |
274 } | |
275 | |
276 addMember(spacer); | |
277 addMember(position); | |
278 } | |
279 | |
280 /** | |
281 * Open the chart property editor dialog. | |
282 */ | |
283 protected void openPropertiesEditor() { | |
284 ChartPropertiesEditor editor = | |
285 new ChartPropertiesEditor(getChartOutputTab()); | |
286 editor.show(); | |
287 } | |
288 | |
289 | |
290 /** Open editor for custom points. */ | |
291 protected void openPointWindow() { | |
292 ChartOutputTab chartTab = getChartOutputTab(); | |
293 if (chartTab.getMode().getName().equals("historical_discharge")) { | |
294 new ManualDatePointsEditor(chartTab.getView().getCollection(), | |
295 chartTab, chartTab.getMode().getName()).show(); | |
296 } | |
297 else { | |
298 new ManualPointsEditor(chartTab.getView().getCollection(), | |
299 chartTab, chartTab.getMode().getName()).show(); | |
300 } | |
301 } | |
302 | |
303 | |
304 /** | |
305 * Sets new sources to the export button/images, such that the | |
306 * correct zoom values are included in the request when clicked. | |
307 * @param evt ignored. | |
308 */ | |
309 @Override | |
310 public void onZoom(ZoomEvent evt) { | |
311 ChartOutputTab chartTab = getChartOutputTab(); | |
312 downloadPNG.setSource(chartTab.getExportUrl(-1, -1, "png")); | |
313 downloadPDF.setSource(chartTab.getExportUrl(-1, -1, "pdf")); | |
314 downloadSVG.setSource(chartTab.getExportUrl(-1, -1, "svg")); | |
315 } | |
316 | |
317 public void deselectControls() { | |
318 zoombox.deselect(); | |
319 } | |
320 | |
321 public void updateLinks() { | |
322 ChartOutputTab chartTab = getChartOutputTab(); | |
323 String moduleUrl = GWT.getModuleBaseURL(); | |
324 Config config = Config.getInstance(); | |
325 | |
326 if (chartTab.getMode().getName().equals("fix_wq_curve")) { | |
327 exportAT.setSource( | |
328 moduleUrl + "export" + | |
329 "?uuid=" + chartTab.getCollection().identifier() + | |
330 "&mode=" + chartTab.getMode().getName() + "_at_export" + | |
331 "&type=at" + | |
332 "&server=" + config.getServerUrl() + | |
333 "&locale=" + config.getLocale() + | |
334 "&km=" + chartTab.getCollectionView().getCurrentKm()); | |
335 } | |
336 } | |
337 } | |
338 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |