Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixationPanel.java @ 2962:f14d4c668ec5
Bugfix: #698 Fix-Analysis is working in Tomcat again.
flys-client/trunk@4949 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 12 Jul 2012 12:26:14 +0000 |
parents | 43e0f6d96206 |
children | f362e54b7e80 |
comparison
equal
deleted
inserted
replaced
2961:579e33a24a4c | 2962:f14d4c668ec5 |
---|---|
40 | 40 |
41 import de.intevation.flys.client.client.Config; | 41 import de.intevation.flys.client.client.Config; |
42 | 42 |
43 import de.intevation.flys.client.shared.model.Data; | 43 import de.intevation.flys.client.shared.model.Data; |
44 import de.intevation.flys.client.shared.model.DataList; | 44 import de.intevation.flys.client.shared.model.DataList; |
45 import de.intevation.flys.client.shared.model.FixFilter; | |
45 import de.intevation.flys.client.shared.model.FixingsOverviewInfo; | 46 import de.intevation.flys.client.shared.model.FixingsOverviewInfo; |
46 import de.intevation.flys.client.shared.model.FixAnalysisArtifact; | 47 import de.intevation.flys.client.shared.model.FixAnalysisArtifact; |
47 | 48 |
48 import de.intevation.flys.client.client.services.FixingsOverviewService; | 49 import de.intevation.flys.client.client.services.FixingsOverviewService; |
49 import de.intevation.flys.client.client.services.FixingsOverviewServiceAsync; | 50 import de.intevation.flys.client.client.services.FixingsOverviewServiceAsync; |
74 protected Tab chart; | 75 protected Tab chart; |
75 protected VLayout chartContainer; | 76 protected VLayout chartContainer; |
76 protected Img chartImg; | 77 protected Img chartImg; |
77 protected TextItem kmText; | 78 protected TextItem kmText; |
78 | 79 |
80 public static final DateTimeFormat DTF = DateTimeFormat.getFormat("dd.MM.yyyy"); | |
81 | |
82 | |
79 public FixationPanel() { | 83 public FixationPanel() { |
80 chartImg = new Img(); | 84 chartImg = new Img(); |
81 htmlOverview = ""; | 85 htmlOverview = ""; |
82 } | 86 } |
83 | 87 |
84 protected String getArtifactUuid() { | 88 protected String getArtifactUuid() { |
85 return this.artifact.getUuid(); | 89 return this.artifact.getUuid(); |
86 } | 90 } |
87 | 91 |
88 protected void init() { | 92 protected void init() { |
89 | |
90 } | 93 } |
91 | 94 |
92 public Data[] getData() { | 95 public Data[] getData() { |
93 return null; | 96 return null; |
94 } | 97 } |
138 FixAnalysisArtifact art = (FixAnalysisArtifact) this.artifact; | 141 FixAnalysisArtifact art = (FixAnalysisArtifact) this.artifact; |
139 | 142 |
140 overviewService.generateOverview( | 143 overviewService.generateOverview( |
141 locale, | 144 locale, |
142 artifact.getUuid(), | 145 artifact.getUuid(), |
143 art.getFilter().getOverviewFilter(), | 146 getOverviewFilter(art.getFilter()), |
144 renderCheckboxes(), | 147 renderCheckboxes(), |
145 callBack, | 148 callBack, |
146 new AsyncCallback<FixingsOverviewInfo>() { | 149 new AsyncCallback<FixingsOverviewInfo>() { |
147 public void onFailure(Throwable caught) { | 150 public void onFailure(Throwable caught) { |
148 GWT.log("Could not receive overview."); | 151 GWT.log("Could not receive overview."); |
175 return tabs; | 178 return tabs; |
176 } | 179 } |
177 | 180 |
178 | 181 |
179 protected Canvas createChartHelper() { | 182 protected Canvas createChartHelper() { |
180 | |
181 DynamicForm form = new DynamicForm(); | 183 DynamicForm form = new DynamicForm(); |
182 Button lower = new Button("<<"); | 184 Button lower = new Button("<<"); |
183 lower.setWidth(30); | 185 lower.setWidth(30); |
184 Button upper = new Button(">>"); | 186 Button upper = new Button(">>"); |
185 upper.setWidth(30); | 187 upper.setWidth(30); |
260 } | 262 } |
261 | 263 |
262 String imgUrl = GWT.getModuleBaseURL(); | 264 String imgUrl = GWT.getModuleBaseURL(); |
263 imgUrl += "fixings-km-chart"; | 265 imgUrl += "fixings-km-chart"; |
264 imgUrl += "?locale=" + locale; | 266 imgUrl += "?locale=" + locale; |
265 imgUrl += "&filter=" + filter.getChartFilter(hWidth, hHeight); | 267 imgUrl += "&filter=" + getChartFilter(filter, hWidth, hHeight); |
266 | 268 |
267 if (chartContainer.hasMember(chartImg)) { | 269 if (chartContainer.hasMember(chartImg)) { |
268 chartImg.setWidth(hWidth); | 270 chartImg.setWidth(hWidth); |
269 chartImg.setHeight(hHeight); | 271 chartImg.setHeight(hHeight); |
270 chartImg.setSrc(imgUrl); | 272 chartImg.setSrc(imgUrl); |
319 | 321 |
320 private static void helperCallback(boolean checked, String name) { | 322 private static void helperCallback(boolean checked, String name) { |
321 String[] parts = name.split(":"); | 323 String[] parts = name.split(":"); |
322 String uuid = parts[0]; | 324 String uuid = parts[0]; |
323 String cid = parts[1]; | 325 String cid = parts[1]; |
326 | |
324 FixationPanel p = FixationPanel.getInstance(uuid); | 327 FixationPanel p = FixationPanel.getInstance(uuid); |
325 if (p != null) { | 328 if (p != null) { |
326 p.setValues(cid, checked); | 329 p.setValues(cid, checked); |
327 } | 330 } |
328 } | 331 } |
334 public abstract Canvas createWidget(DataList data); | 337 public abstract Canvas createWidget(DataList data); |
335 public abstract void setValues(String cid, boolean checked); | 338 public abstract void setValues(String cid, boolean checked); |
336 public abstract boolean renderCheckboxes(); | 339 public abstract boolean renderCheckboxes(); |
337 public abstract void success(); | 340 public abstract void success(); |
338 | 341 |
339 public static class FixFilter implements Serializable{ | 342 |
340 protected String river; | 343 public static String getOverviewFilter(FixFilter filter) { |
341 protected double fromKm; | 344 String river = filter.getRiver(); |
342 protected double toKm; | 345 |
343 protected double currentKm; | 346 if (river != null && river.length() > 0) { |
344 protected int fromClass; | 347 JSONObject jfix = new JSONObject(); |
345 protected int toClass; | 348 JSONObject jfilter = new JSONObject(); |
346 protected long fromDate; | 349 JSONObject jrName = new JSONObject(); |
347 protected long toDate; | 350 JSONString jrValue = new JSONString(river); |
348 protected boolean hasDate; | 351 jrName.put("name", jrValue); |
349 protected int[] events; | 352 jfilter.put("river", jrName); |
350 | 353 jfix.put("fixings", createFilter(filter, jfilter)); |
351 public FixFilter() { | 354 return jfix.toString(); |
352 this.river = ""; | 355 } |
353 this.fromKm = -Double.MAX_VALUE; | 356 return ""; |
354 this.toKm = -1; | 357 } |
355 this.currentKm = -1; | 358 |
356 this.fromClass = -1; | 359 public String getChartFilter(FixFilter filter, int width, int height) { |
357 this.toClass = -1; | 360 String river = filter.getRiver(); |
358 this.fromDate = -1; | 361 double currentKm = filter.getCurrentKm(); |
359 this.toDate = -1; | 362 double fromKm = filter.getFromKm(); |
360 this.hasDate = false; | 363 double toKm = filter.getToKm(); |
361 this.events = new int[0]; | 364 |
362 } | 365 if (river != null && river.length() > 0 && |
363 | 366 currentKm >= fromKm && currentKm <= toKm) |
364 public void setRiver(String river) { | 367 { |
365 this.river = river; | 368 JSONObject jfix = new JSONObject(); |
366 } | 369 JSONObject jfilter = new JSONObject(); |
367 | 370 JSONObject jrName = new JSONObject(); |
368 public void setFromKm(double from) { | 371 JSONString jrValue = new JSONString(river); |
369 this.fromKm = from; | 372 JSONObject jkm = new JSONObject(); |
370 } | 373 JSONNumber jkmValue = new JSONNumber(currentKm); |
371 | 374 JSONObject jextent = new JSONObject(); |
372 public void setToKm(double to) { | 375 JSONNumber jwidth = new JSONNumber(width); |
373 this.toKm = to; | 376 JSONNumber jheight = new JSONNumber(height); |
374 } | 377 |
375 | 378 jkm.put("value", jkmValue); |
376 public void setCurrentKm(double km) { | 379 jrName.put("name", jrValue); |
377 this.currentKm = km; | 380 jfilter.put("river", jrName); |
378 } | 381 jfilter.put("km", jkm); |
379 | 382 jextent.put("width", jwidth); |
380 public void setFromClass(int from) { | 383 jextent.put("height", jheight); |
381 this.fromClass = from; | 384 jfilter.put("extent", jextent); |
382 } | 385 jfix.put("fixings", createFilter(filter, jfilter)); |
383 | 386 return jfix.toString(); |
384 public void setToClass(int to) { | 387 } |
385 this.toClass = to; | 388 return ""; |
386 } | 389 } |
387 | 390 |
388 public void setFromDate(long from) { | 391 protected static JSONObject createFilter(FixFilter filter, JSONObject root) { |
389 this.hasDate = true; | 392 double fromKm = filter.getFromKm(); |
390 this.fromDate = from; | 393 double toKm = filter.getToKm(); |
391 } | 394 boolean hasDate = filter.getFromDate() > 0 && filter.getToDate() > 0; |
392 | 395 |
393 public void setToDate(long to) { | 396 if (fromKm >= 0 && toKm >= 0 && fromKm <= toKm) { |
394 this.hasDate = true; | 397 JSONObject range = new JSONObject(); |
395 this.toDate = to; | 398 JSONObject fromtokm = new JSONObject(); |
396 } | 399 JSONNumber f = new JSONNumber(fromKm); |
397 | 400 JSONNumber t = new JSONNumber(toKm); |
398 public void setEvents(int[] ev) { | 401 fromtokm.put("from", f); |
399 this.events = ev; | 402 fromtokm.put("to", t); |
400 } | 403 root.put("range", fromtokm); |
401 | 404 } |
402 public String getRiver() { | 405 |
403 return this.river; | 406 JSONObject and = new JSONObject(); |
404 } | 407 if (hasDate) { |
405 | 408 long fromDate = filter.getFromDate(); |
406 public double getFromKm() { | 409 long toDate = filter.getToDate(); |
407 return this.fromKm; | 410 |
408 } | 411 Date df = new Date(fromDate); |
409 | 412 Date dt = new Date(toDate); |
410 public double getToKm() { | 413 |
411 return this.toKm; | 414 JSONObject daterange = new JSONObject(); |
412 } | 415 JSONString f = new JSONString(DTF.format(df)); |
413 | 416 JSONString t = new JSONString(DTF.format(dt)); |
414 public double getCurrentKm() { | 417 |
415 return this.currentKm; | 418 daterange.put("from", f); |
416 } | 419 daterange.put("to", t); |
417 | 420 and.put("date-range", daterange); |
418 public int getFromClass() { | 421 } |
419 return this.fromClass; | 422 |
420 } | 423 int fromClass = filter.getFromClass(); |
421 | 424 int toClass = filter.getToClass(); |
422 public int getToClass() { | 425 |
423 return this.toClass; | 426 if (fromClass >= 0 && toClass >= 0 && fromClass <= toClass) { |
424 } | 427 JSONObject classrange = new JSONObject(); |
425 | 428 JSONNumber f = new JSONNumber(fromClass); |
426 public long getFromDate() { | 429 JSONNumber t = new JSONNumber(toClass); |
427 return this.fromDate; | 430 |
428 } | 431 classrange.put("from", f); |
429 | 432 classrange.put("to", t); |
430 public long getToDate() { | 433 and.put("sector-range", classrange); |
431 return this.toDate; | 434 } |
432 } | 435 |
433 | 436 int[] events = filter.getEvents(); |
434 public int[] getEvents() { | 437 |
435 return this.events; | 438 if (events.length > 0) { |
436 } | 439 StringBuilder cids = new StringBuilder(); |
437 | 440 |
438 public String getOverviewFilter() { | 441 for (int i = 0; i < events.length; i++) { |
439 if (river != null && river.length() > 0) { | 442 if (i > 0) cids.append(' '); |
440 JSONObject jfix = new JSONObject(); | 443 cids.append(events[i]); |
441 JSONObject jfilter = new JSONObject(); | |
442 JSONObject jrName = new JSONObject(); | |
443 JSONString jrValue = new JSONString(river); | |
444 jrName.put("name", jrValue); | |
445 jfilter.put("river", jrName); | |
446 jfix.put("fixings", createFilter(jfilter)); | |
447 return jfix.toString(); | |
448 } | 444 } |
449 return ""; | 445 JSONObject columns = new JSONObject(); |
450 } | 446 columns.put("cids", new JSONString(cids.toString())); |
451 | 447 and.put("columns", columns); |
452 public String getChartFilter(int width, int height) { | 448 } |
453 if (river != null && river.length() > 0 && | 449 if (and.size() > 0) { |
454 currentKm >= fromKm && currentKm <= toKm) | 450 JSONObject jFilter = new JSONObject(); |
455 { | 451 jFilter.put("and", and); |
456 JSONObject jfix = new JSONObject(); | 452 root.put("filter", jFilter); |
457 JSONObject jfilter = new JSONObject(); | 453 } |
458 JSONObject jrName = new JSONObject(); | 454 return root; |
459 JSONString jrValue = new JSONString(river); | |
460 JSONObject jkm = new JSONObject(); | |
461 JSONNumber jkmValue = new JSONNumber(currentKm); | |
462 JSONObject jextent = new JSONObject(); | |
463 JSONNumber jwidth = new JSONNumber(width); | |
464 JSONNumber jheight = new JSONNumber(height); | |
465 | |
466 jkm.put("value", jkmValue); | |
467 jrName.put("name", jrValue); | |
468 jfilter.put("river", jrName); | |
469 jfilter.put("km", jkm); | |
470 jextent.put("width", jwidth); | |
471 jextent.put("height", jheight); | |
472 jfilter.put("extent", jextent); | |
473 jfix.put("fixings", createFilter(jfilter)); | |
474 return jfix.toString(); | |
475 } | |
476 return ""; | |
477 } | |
478 | |
479 protected JSONObject createFilter(JSONObject root) { | |
480 if (this.fromKm >= 0 && this.toKm >= 0 && this.fromKm <=this.toKm) { | |
481 JSONObject range = new JSONObject(); | |
482 JSONObject fromtokm = new JSONObject(); | |
483 JSONNumber f = new JSONNumber(this.fromKm); | |
484 JSONNumber t = new JSONNumber(this.toKm); | |
485 fromtokm.put("from", f); | |
486 fromtokm.put("to", t); | |
487 root.put("range", fromtokm); | |
488 } | |
489 JSONObject and = new JSONObject(); | |
490 if (this.hasDate) { | |
491 JSONObject daterange = new JSONObject(); | |
492 Date df = new Date(this.fromDate); | |
493 Date dt = new Date(this.toDate); | |
494 DateTimeFormat dtf = DateTimeFormat.getFormat("dd.MM.yyyy"); | |
495 JSONString f = new JSONString(dtf.format(df)); | |
496 JSONString t = new JSONString(dtf.format(dt)); | |
497 daterange.put("from", f); | |
498 daterange.put("to", t); | |
499 and.put("date-range", daterange); | |
500 } | |
501 if (this.fromClass >= 0 && | |
502 this.toClass >= 0 && | |
503 this.fromClass <= this.toClass) { | |
504 JSONObject classrange = new JSONObject(); | |
505 JSONNumber f = new JSONNumber(this.fromClass); | |
506 JSONNumber t = new JSONNumber(this.toClass); | |
507 classrange.put("from", f); | |
508 classrange.put("to", t); | |
509 and.put("sector-range", classrange); | |
510 } | |
511 if (this.events.length > 0) { | |
512 StringBuilder cids = new StringBuilder(); | |
513 | |
514 for (int i = 0; i < events.length; i++) { | |
515 if (i > 0) cids.append(' '); | |
516 cids.append(events[i]); | |
517 } | |
518 JSONObject columns = new JSONObject(); | |
519 columns.put("cids", new JSONString(cids.toString())); | |
520 and.put("columns", columns); | |
521 } | |
522 if (and.size() > 0) { | |
523 JSONObject filter = new JSONObject(); | |
524 filter.put("and", and); | |
525 root.put("filter", filter); | |
526 } | |
527 return root; | |
528 } | |
529 } | 455 } |
530 } | 456 } |