Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java @ 4062:145980c21700
Handle error conditions more robust.
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Mon, 08 Oct 2012 12:10:50 +0200 |
parents | 22cd60315e08 |
children | 03de5c424f95 |
comparison
equal
deleted
inserted
replaced
4057:c3b959de4d83 | 4062:145980c21700 |
---|---|
1 package de.intevation.flys.client.client.ui; | 1 package de.intevation.flys.client.client.ui; |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 import java.util.Map; | |
6 import java.util.Set; | |
7 import java.util.TreeMap; | |
8 | 2 |
9 import com.google.gwt.core.client.GWT; | 3 import com.google.gwt.core.client.GWT; |
10 import com.google.gwt.user.client.rpc.AsyncCallback; | 4 import com.google.gwt.user.client.rpc.AsyncCallback; |
11 | 5 |
12 import com.smartgwt.client.types.VerticalAlignment; | 6 import com.smartgwt.client.types.VerticalAlignment; |
18 import com.smartgwt.client.widgets.layout.SectionStackSection; | 12 import com.smartgwt.client.widgets.layout.SectionStackSection; |
19 import com.smartgwt.client.widgets.layout.VLayout; | 13 import com.smartgwt.client.widgets.layout.VLayout; |
20 import com.smartgwt.client.widgets.tab.Tab; | 14 import com.smartgwt.client.widgets.tab.Tab; |
21 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; | 15 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler; |
22 | 16 |
23 import de.intevation.flys.client.shared.model.Artifact; | |
24 import de.intevation.flys.client.shared.model.WINFOArtifact; | |
25 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
26 import de.intevation.flys.client.shared.model.Collection; | |
27 import de.intevation.flys.client.shared.model.Data; | |
28 import de.intevation.flys.client.shared.model.DataItem; | |
29 import de.intevation.flys.client.shared.model.DataList; | |
30 import de.intevation.flys.client.shared.model.DefaultData; | |
31 import de.intevation.flys.client.shared.model.DefaultDataItem; | |
32 import de.intevation.flys.client.shared.model.ReportMode; | |
33 import de.intevation.flys.client.shared.model.ExportMode; | |
34 import de.intevation.flys.client.shared.model.OutputMode; | |
35 import de.intevation.flys.client.shared.model.River; | |
36 import de.intevation.flys.client.client.Config; | 17 import de.intevation.flys.client.client.Config; |
37 import de.intevation.flys.client.client.FLYS; | 18 import de.intevation.flys.client.client.FLYS; |
38 import de.intevation.flys.client.client.FLYSConstants; | 19 import de.intevation.flys.client.client.FLYSConstants; |
39 import de.intevation.flys.client.client.event.AdvanceHandler; | 20 import de.intevation.flys.client.client.event.AdvanceHandler; |
40 import de.intevation.flys.client.client.event.CollectionChangeEvent; | 21 import de.intevation.flys.client.client.event.CollectionChangeEvent; |
49 import de.intevation.flys.client.client.event.StepBackEvent; | 30 import de.intevation.flys.client.client.event.StepBackEvent; |
50 import de.intevation.flys.client.client.event.StepBackHandler; | 31 import de.intevation.flys.client.client.event.StepBackHandler; |
51 import de.intevation.flys.client.client.event.StepForwardEvent; | 32 import de.intevation.flys.client.client.event.StepForwardEvent; |
52 import de.intevation.flys.client.client.event.StepForwardHandler; | 33 import de.intevation.flys.client.client.event.StepForwardHandler; |
53 import de.intevation.flys.client.client.services.AdvanceService; | 34 import de.intevation.flys.client.client.services.AdvanceService; |
54 import de.intevation.flys.client.client.services.ReportService; | |
55 import de.intevation.flys.client.client.services.AdvanceServiceAsync; | 35 import de.intevation.flys.client.client.services.AdvanceServiceAsync; |
56 import de.intevation.flys.client.client.services.ArtifactService; | 36 import de.intevation.flys.client.client.services.ArtifactService; |
57 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 37 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
38 import de.intevation.flys.client.client.services.ReportService; | |
39 import de.intevation.flys.client.client.services.ReportServiceAsync; | |
58 import de.intevation.flys.client.client.services.StepForwardService; | 40 import de.intevation.flys.client.client.services.StepForwardService; |
59 import de.intevation.flys.client.client.services.StepForwardServiceAsync; | 41 import de.intevation.flys.client.client.services.StepForwardServiceAsync; |
60 import de.intevation.flys.client.client.services.ReportServiceAsync; | 42 import de.intevation.flys.client.shared.model.Artifact; |
43 import de.intevation.flys.client.shared.model.ArtifactDescription; | |
44 import de.intevation.flys.client.shared.model.Collection; | |
45 import de.intevation.flys.client.shared.model.Data; | |
46 import de.intevation.flys.client.shared.model.DataItem; | |
47 import de.intevation.flys.client.shared.model.DataList; | |
48 import de.intevation.flys.client.shared.model.DefaultData; | |
49 import de.intevation.flys.client.shared.model.DefaultDataItem; | |
50 import de.intevation.flys.client.shared.model.ExportMode; | |
51 import de.intevation.flys.client.shared.model.OutputMode; | |
52 import de.intevation.flys.client.shared.model.ReportMode; | |
53 import de.intevation.flys.client.shared.model.River; | |
54 import de.intevation.flys.client.shared.model.WINFOArtifact; | |
55 | |
56 import java.util.ArrayList; | |
57 import java.util.List; | |
58 import java.util.Map; | |
59 import java.util.Set; | |
60 import java.util.TreeMap; | |
61 | 61 |
62 | 62 |
63 public class ParameterList | 63 public class ParameterList |
64 extends Tab | 64 extends Tab |
65 implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, | 65 implements StepBackHandler, StepForwardHandler, ParameterChangeHandler, |
211 | 211 |
212 final SectionStackSection gaugeSection = new SectionStackSection(); | 212 final SectionStackSection gaugeSection = new SectionStackSection(); |
213 gaugeSection.setExpanded(false); | 213 gaugeSection.setExpanded(false); |
214 gaugeSection.setTitle(MSG.gaugePanelTitle()); | 214 gaugeSection.setTitle(MSG.gaugePanelTitle()); |
215 gaugePanel = new GaugePanel(flys, gaugeSection) { | 215 gaugePanel = new GaugePanel(flys, gaugeSection) { |
216 @Override | |
216 public void addMember(Canvas component) { | 217 public void addMember(Canvas component) { |
217 super.addMember(component); | 218 super.addMember(component); |
218 gaugeSection.setExpanded(true); | 219 gaugeSection.setExpanded(true); |
219 } | 220 } |
220 | 221 |
222 @Override | |
221 public void removeMembers(Canvas[] components) { | 223 public void removeMembers(Canvas[] components) { |
222 super.removeMembers(components); | 224 super.removeMembers(components); |
223 gaugeSection.setExpanded(false); | 225 gaugeSection.setExpanded(false); |
224 } | 226 } |
225 }; | 227 }; |
229 // This canvas is used to render helper widgets. | 231 // This canvas is used to render helper widgets. |
230 final SectionStackSection helperSection = new SectionStackSection(); | 232 final SectionStackSection helperSection = new SectionStackSection(); |
231 helperSection.setExpanded(false); | 233 helperSection.setExpanded(false); |
232 helperSection.setTitle(MSG.helperPanelTitle()); | 234 helperSection.setTitle(MSG.helperPanelTitle()); |
233 helperPanel = new VLayout() { | 235 helperPanel = new VLayout() { |
236 @Override | |
234 public void addMember(Canvas component) { | 237 public void addMember(Canvas component) { |
235 super.addMember(component); | 238 super.addMember(component); |
236 stack.expandSection(helperSection.getID()); | 239 stack.expandSection(helperSection.getID()); |
237 } | 240 } |
238 | 241 |
242 @Override | |
239 public void removeMembers(Canvas[] components) { | 243 public void removeMembers(Canvas[] components) { |
240 super.removeMembers(components); | 244 super.removeMembers(components); |
241 helperSection.setExpanded(false); | 245 helperSection.setExpanded(false); |
242 } | 246 } |
243 }; | 247 }; |
248 // This canvas is used to render calculation results. | 252 // This canvas is used to render calculation results. |
249 final SectionStackSection tableSection = new SectionStackSection(); | 253 final SectionStackSection tableSection = new SectionStackSection(); |
250 tableSection.setExpanded(false); | 254 tableSection.setExpanded(false); |
251 tableSection.setTitle(MSG.calcTableTitle()); | 255 tableSection.setTitle(MSG.calcTableTitle()); |
252 tablePanel = new VLayout() { | 256 tablePanel = new VLayout() { |
257 @Override | |
253 public void addMember(Canvas component) { | 258 public void addMember(Canvas component) { |
254 super.addMember(component); | 259 super.addMember(component); |
255 tableSection.setExpanded(true); | 260 tableSection.setExpanded(true); |
256 } | 261 } |
257 | 262 |
263 @Override | |
258 public void removeMembers(Canvas[] components) { | 264 public void removeMembers(Canvas[] components) { |
259 super.removeMembers(components); | 265 super.removeMembers(components); |
260 tableSection.setExpanded(false); | 266 tableSection.setExpanded(false); |
261 } | 267 } |
262 }; | 268 }; |
294 /** | 300 /** |
295 * This method registers a new ParameterChangeHandler. | 301 * This method registers a new ParameterChangeHandler. |
296 * | 302 * |
297 * @param handler The new ParameterChangeHandler. | 303 * @param handler The new ParameterChangeHandler. |
298 */ | 304 */ |
305 @Override | |
299 public void addParameterChangeHandler(ParameterChangeHandler handler) { | 306 public void addParameterChangeHandler(ParameterChangeHandler handler) { |
300 if (handler != null) { | 307 if (handler != null) { |
301 parameterHandlers.add(handler); | 308 parameterHandlers.add(handler); |
302 } | 309 } |
303 } | 310 } |
341 MSG.river_selection(), | 348 MSG.river_selection(), |
342 null, | 349 null, |
343 items); | 350 items); |
344 | 351 |
345 LinkSelection widget = new LinkSelection(); | 352 LinkSelection widget = new LinkSelection(); |
346 HasStepForwardHandlers handler = (HasStepForwardHandlers) widget; | 353 HasStepForwardHandlers handler = widget; |
347 | 354 |
348 widget.setContainer(helperPanel); | 355 widget.setContainer(helperPanel); |
349 | 356 |
350 handler.addStepForwardHandler(new StepForwardHandler() { | 357 handler.addStepForwardHandler(new StepForwardHandler() { |
358 @Override | |
351 public void onStepForward(StepForwardEvent event) { | 359 public void onStepForward(StepForwardEvent event) { |
352 lockUI(); | 360 lockUI(); |
353 Data[] data = event.getData(); | 361 Data[] data = event.getData(); |
354 | 362 |
355 DataItem[] moduleItems = data[0].getItems(); | 363 DataItem[] moduleItems = data[0].getItems(); |
373 final Data[] feedData = new Data[] { data[1] }; | 381 final Data[] feedData = new Data[] { data[1] }; |
374 | 382 |
375 artifactService.create( | 383 artifactService.create( |
376 locale, module.toLowerCase(), null, | 384 locale, module.toLowerCase(), null, |
377 new AsyncCallback<Artifact>() { | 385 new AsyncCallback<Artifact>() { |
386 @Override | |
378 public void onFailure(Throwable caught) { | 387 public void onFailure(Throwable caught) { |
379 unlockUI(); | 388 unlockUI(); |
380 GWT.log("Could not create the new artifact."); | 389 GWT.log("Could not create the new artifact."); |
381 SC.warn(MSG.getString(caught.getMessage())); | 390 SC.warn(MSG.getString(caught.getMessage())); |
382 } | 391 } |
383 | 392 |
393 @Override | |
384 public void onSuccess(Artifact artifact) { | 394 public void onSuccess(Artifact artifact) { |
385 GWT.log("Successfully created a new artifact."); | 395 GWT.log("Successfully created a new artifact."); |
386 | 396 |
387 forwardService.go(locale, artifact, feedData, | 397 forwardService.go(locale, artifact, feedData, |
388 new AsyncCallback<Artifact>() { | 398 new AsyncCallback<Artifact>() { |
399 @Override | |
389 public void onFailure(Throwable caught) { | 400 public void onFailure(Throwable caught) { |
390 unlockUI(); | 401 unlockUI(); |
391 GWT.log("Could not feed the artifact."); | 402 GWT.log("Could not feed the artifact."); |
392 SC.warn(caught.getMessage()); | 403 SC.warn(caught.getMessage()); |
393 } | 404 } |
394 | 405 |
406 @Override | |
395 public void onSuccess(Artifact artifact) { | 407 public void onSuccess(Artifact artifact) { |
396 GWT.log("Successfully feed the artifact."); | 408 GWT.log("Successfully feed the artifact."); |
397 old.clear(); | 409 old.clear(); |
398 cView.addArtifactToCollection(artifact); | 410 cView.addArtifactToCollection(artifact); |
399 setArtifact(artifact); | 411 setArtifact(artifact); |
602 * This method is called if the user clicks on the 'next' button to advance | 614 * This method is called if the user clicks on the 'next' button to advance |
603 * to the next state. | 615 * to the next state. |
604 * | 616 * |
605 * @param event The StepForwardEvent. | 617 * @param event The StepForwardEvent. |
606 */ | 618 */ |
619 @Override | |
607 public void onStepForward(StepForwardEvent event) { | 620 public void onStepForward(StepForwardEvent event) { |
608 GWT.log("CollectionView - onStepForward()"); | 621 GWT.log("CollectionView - onStepForward()"); |
609 lockUI(); | 622 lockUI(); |
610 | 623 |
611 Config config = Config.getInstance(); | 624 Config config = Config.getInstance(); |
612 String locale = config.getLocale(); | 625 String locale = config.getLocale(); |
613 | 626 |
614 forwardService.go(locale, artifact, event.getData(), | 627 forwardService.go(locale, artifact, event.getData(), |
615 new AsyncCallback<Artifact>() { | 628 new AsyncCallback<Artifact>() { |
629 @Override | |
616 public void onFailure(Throwable caught) { | 630 public void onFailure(Throwable caught) { |
617 unlockUI(); | 631 unlockUI(); |
618 GWT.log("Could not feed the artifact."); | 632 GWT.log("Could not feed the artifact."); |
619 SC.warn(MSG.getString(caught.getMessage())); | 633 SC.warn(FLYS.getExceptionString(MSG, caught)); |
620 } | 634 } |
621 | 635 |
636 @Override | |
622 public void onSuccess(Artifact artifact) { | 637 public void onSuccess(Artifact artifact) { |
623 GWT.log("Successfully feed the artifact."); | 638 GWT.log("Successfully feed the artifact."); |
624 old.clear(); | 639 old.clear(); |
625 | 640 |
626 setArtifact(artifact, true); | 641 setArtifact(artifact, true); |
634 * This method is used to remove all old items from this list after the user | 649 * This method is used to remove all old items from this list after the user |
635 * has clicked the step back button. | 650 * has clicked the step back button. |
636 * | 651 * |
637 * @param e The StepBackEvent that holds the identifier of the target state. | 652 * @param e The StepBackEvent that holds the identifier of the target state. |
638 */ | 653 */ |
654 @Override | |
639 public void onStepBack(StepBackEvent e) { | 655 public void onStepBack(StepBackEvent e) { |
640 lockUI(); | 656 lockUI(); |
641 final String target = e.getTarget(); | 657 final String target = e.getTarget(); |
642 | 658 |
643 Config config = Config.getInstance(); | 659 Config config = Config.getInstance(); |
644 final String locale = config.getLocale(); | 660 final String locale = config.getLocale(); |
645 | 661 |
646 advanceService.advance(locale, artifact, target, | 662 advanceService.advance(locale, artifact, target, |
647 new AsyncCallback<Artifact>() { | 663 new AsyncCallback<Artifact>() { |
664 @Override | |
648 public void onFailure(Throwable caught) { | 665 public void onFailure(Throwable caught) { |
649 unlockUI(); | 666 unlockUI(); |
650 GWT.log("Could not go back to '" + target + "'"); | 667 GWT.log("Could not go back to '" + target + "'"); |
651 SC.warn(MSG.getString(caught.getMessage())); | 668 SC.warn(FLYS.getExceptionString(MSG, caught)); |
652 } | 669 } |
653 | 670 |
671 @Override | |
654 public void onSuccess(Artifact artifact) { | 672 public void onSuccess(Artifact artifact) { |
655 GWT.log("Successfully step back to '" + target + "'"); | 673 GWT.log("Successfully step back to '" + target + "'"); |
656 | 674 |
657 old.clear(); | 675 old.clear(); |
658 | 676 |
662 } | 680 } |
663 ); | 681 ); |
664 } | 682 } |
665 | 683 |
666 | 684 |
685 @Override | |
667 public void onAdvance(final String target) { | 686 public void onAdvance(final String target) { |
668 Config config = Config.getInstance(); | 687 Config config = Config.getInstance(); |
669 final String locale = config.getLocale(); | 688 final String locale = config.getLocale(); |
670 | 689 |
671 advanceService.advance(locale, artifact, target, | 690 advanceService.advance(locale, artifact, target, |
672 new AsyncCallback<Artifact>() { | 691 new AsyncCallback<Artifact>() { |
692 @Override | |
673 public void onFailure(Throwable caught) { | 693 public void onFailure(Throwable caught) { |
674 GWT.log("Could not go to '" + target + "'"); | 694 GWT.log("Could not go to '" + target + "'"); |
675 SC.warn(MSG.getString(caught.getMessage())); | 695 SC.warn(FLYS.getExceptionString(MSG, caught)); |
676 } | 696 } |
677 | 697 |
698 @Override | |
678 public void onSuccess(Artifact artifact) { | 699 public void onSuccess(Artifact artifact) { |
679 GWT.log("Successfully advanced to '" + target + "'"); | 700 GWT.log("Successfully advanced to '" + target + "'"); |
680 | 701 |
681 old.clear(); | 702 old.clear(); |
682 | 703 |
691 * Implements the onCollectionChange() method to do update the GUI after the | 712 * Implements the onCollectionChange() method to do update the GUI after the |
692 * parameterization has changed. | 713 * parameterization has changed. |
693 * | 714 * |
694 * @param event The ParameterChangeEvent. | 715 * @param event The ParameterChangeEvent. |
695 */ | 716 */ |
717 @Override | |
696 public void onParameterChange(ParameterChangeEvent event) { | 718 public void onParameterChange(ParameterChangeEvent event) { |
697 GWT.log("ParameterList.onParameterChange"); | 719 GWT.log("ParameterList.onParameterChange"); |
698 | 720 |
699 Canvas[] c = helperPanel.getMembers(); | 721 Canvas[] c = helperPanel.getMembers(); |
700 if (c != null && c.length > 0) { | 722 if (c != null && c.length > 0) { |
756 desc.getOldData(), | 778 desc.getOldData(), |
757 event.getType() == ParameterChangeEvent.Type.BACK); | 779 event.getType() == ParameterChangeEvent.Type.BACK); |
758 } | 780 } |
759 | 781 |
760 | 782 |
783 @Override | |
761 public void onCollectionChange(CollectionChangeEvent event) { | 784 public void onCollectionChange(CollectionChangeEvent event) { |
762 Collection c = event.getNewValue(); | 785 Collection c = event.getNewValue(); |
763 Map<String, OutputMode> outs = c.getOutputModes(); | 786 Map<String, OutputMode> outs = c.getOutputModes(); |
764 Set<String> keys = outs.keySet(); | 787 Set<String> keys = outs.keySet(); |
765 | 788 |
773 updateExportModes(c, getExportModes(outputs)); | 796 updateExportModes(c, getExportModes(outputs)); |
774 updateReportModes(c, getReportModes(outputs)); | 797 updateReportModes(c, getReportModes(outputs)); |
775 } | 798 } |
776 | 799 |
777 | 800 |
801 @Override | |
778 public void onOutputModesChange(OutputModesChangeEvent event) { | 802 public void onOutputModesChange(OutputModesChangeEvent event) { |
779 | 803 |
780 Collection c = cView.getCollection(); | 804 Collection c = cView.getCollection(); |
781 | 805 |
782 if (c != null) { | 806 if (c != null) { |
853 for (ReportMode report: reports) { | 877 for (ReportMode report: reports) { |
854 GWT.log("report '" + report.toString() + "'"); | 878 GWT.log("report '" + report.toString() + "'"); |
855 | 879 |
856 reportService.report(cid, locale, report.getName(), | 880 reportService.report(cid, locale, report.getName(), |
857 new AsyncCallback<String>() { | 881 new AsyncCallback<String>() { |
882 @Override | |
858 public void onFailure(Throwable caught) { | 883 public void onFailure(Throwable caught) { |
859 SC.warn(caught.getMessage()); | 884 SC.warn(FLYS.getExceptionString(MSG, caught)); |
860 } | 885 } |
861 | 886 |
887 @Override | |
862 public void onSuccess(String msg) { | 888 public void onSuccess(String msg) { |
863 setReportMessage(msg); | 889 setReportMessage(msg); |
864 } | 890 } |
865 }); | 891 }); |
866 } | 892 } |