Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java @ 1379:546f7f890ffa
Cosmetics, refactoring.
flys-client/trunk@3130 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 01 Nov 2011 14:29:27 +0000 |
parents | ebba8a8618e6 |
children | bc06a671ef60 |
comparison
equal
deleted
inserted
replaced
1378:ebba8a8618e6 | 1379:546f7f890ffa |
---|---|
25 import de.intevation.flys.client.shared.model.DefaultArtifact; | 25 import de.intevation.flys.client.shared.model.DefaultArtifact; |
26 import de.intevation.flys.client.shared.model.DefaultData; | 26 import de.intevation.flys.client.shared.model.DefaultData; |
27 import de.intevation.flys.client.shared.model.DefaultDataItem; | 27 import de.intevation.flys.client.shared.model.DefaultDataItem; |
28 import de.intevation.flys.client.shared.model.FacetRecord; | 28 import de.intevation.flys.client.shared.model.FacetRecord; |
29 | 29 |
30 import de.intevation.flys.client.client.services.FeedServiceAsync; | |
31 | |
30 | 32 |
31 /** | 33 /** |
32 * ThemePanel much like ChartThemePanel, but shows an "Actions" column, | 34 * ThemePanel much like ChartThemePanel, but shows an "Actions" column, |
33 * needed for interaction in the CrossSection Charts. | 35 * needed for interaction in the CrossSection Charts. |
34 */ | 36 */ |
45 super(collection, mode); | 47 super(collection, mode); |
46 } | 48 } |
47 | 49 |
48 | 50 |
49 /** | 51 /** |
52 * Create the handler for ChangeEvents on the Spinner in the | |
53 * facets that control km of cross section. | |
54 * | |
55 * @param feedService The FeedService to send (changed) data to. | |
56 * @param facetRecord The FacetRecord (~row in table) where this | |
57 * handler is added to (to a child, to be exact). | |
58 */ | |
59 public final ChangedHandler createSpinnerHandler( | |
60 final FeedServiceAsync feedService, | |
61 final FacetRecord facetRecord) | |
62 { | |
63 Config config = Config.getInstance(); | |
64 final String serverUrl = config.getServerUrl(); | |
65 final String locale = config.getLocale(); | |
66 | |
67 ChangedHandler handler = new ChangedHandler() | |
68 { | |
69 @Override | |
70 public void onChanged(ChangedEvent ce) { | |
71 if (ce.getValue() == null) { | |
72 return; | |
73 } | |
74 DefaultDataItem kmItem = new DefaultDataItem( | |
75 "cross_section.km", | |
76 "cross_section.km", | |
77 ce.getValue().toString()); | |
78 DefaultData km = new DefaultData( | |
79 "cross_section.km", | |
80 null, | |
81 null, | |
82 new DataItem[] {kmItem}); | |
83 Data[] feedData = new Data[] {km}; | |
84 feedService.feed(serverUrl, | |
85 locale, | |
86 new DefaultArtifact( | |
87 facetRecord.getTheme().getArtifact(), | |
88 "TODO:hash"), | |
89 feedData, | |
90 new AsyncCallback<Artifact>() { | |
91 public void onFailure(Throwable caught) { | |
92 GWT.log("Could not feed artifact " + caught.getMessage()); | |
93 // TODO SC.warn | |
94 } | |
95 public void onSuccess(Artifact artifact) { | |
96 GWT.log("Successfully fed"); | |
97 // TODO: Also update content of spinnerbox | |
98 requestRedraw(); | |
99 } | |
100 }); | |
101 } | |
102 }; | |
103 return handler; | |
104 } | |
105 | |
106 | |
107 /** | |
50 * Create and configure the Grid to display. | 108 * Create and configure the Grid to display. |
51 */ | 109 */ |
52 @Override | 110 @Override |
53 protected ListGrid createGrid() { | 111 protected ListGrid createGrid() { |
54 ListGrid list = new ListGrid() { | 112 ListGrid list = new ListGrid() { |
55 @Override | 113 @Override |
56 protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) { | 114 protected Canvas createRecordComponent( |
115 final ListGridRecord record, | |
116 Integer colNum) | |
117 { | |
57 // Only cross_section Facets display an action widget. | 118 // Only cross_section Facets display an action widget. |
58 final FacetRecord facetRecord = (FacetRecord) record; | 119 final FacetRecord facetRecord = (FacetRecord) record; |
59 if (!facetRecord.getTheme().getFacet().equals( | 120 if (!facetRecord.getTheme().getFacet().equals( |
60 "cross_section")) { | 121 "cross_section")) |
122 { | |
61 return null; | 123 return null; |
62 } | 124 } |
63 | 125 |
64 String fieldName = this.getFieldName(colNum); | 126 String fieldName = this.getFieldName(colNum); |
65 | 127 |
78 spinnerItem.setMin(0); | 140 spinnerItem.setMin(0); |
79 spinnerItem.setMax(1000); | 141 spinnerItem.setMax(1000); |
80 spinnerItem.setStep(5f); | 142 spinnerItem.setStep(5f); |
81 spinnerItem.setChangeOnKeypress(true); | 143 spinnerItem.setChangeOnKeypress(true); |
82 | 144 |
83 Config config = Config.getInstance(); | 145 spinnerItem.addChangedHandler( |
84 final String serverUrl = config.getServerUrl(); | 146 createSpinnerHandler( |
85 final String locale = config.getLocale(); | 147 feedService, |
86 | 148 facetRecord)); |
87 spinnerItem.addChangedHandler(new ChangedHandler() { | |
88 @Override | |
89 public void onChanged(ChangedEvent ce) { | |
90 if (ce.getValue() == null) { | |
91 return; | |
92 } | |
93 DefaultDataItem kmItem = new DefaultDataItem("cross_section.km", | |
94 "cross_section.km", ce.getValue().toString()); | |
95 DefaultData km = new DefaultData("cross_section.km", | |
96 null, null, new DataItem[] {kmItem}); | |
97 Data[] feedData = new Data[] {km}; | |
98 feedService.feed(serverUrl, | |
99 locale, | |
100 new DefaultArtifact(facetRecord.getTheme().getArtifact(), "TODO:hash"), | |
101 feedData, | |
102 new AsyncCallback<Artifact>() { | |
103 public void onFailure(Throwable caught) { | |
104 GWT.log("Could not feed artifact " + caught.getMessage()); | |
105 // TODO SC.warn | |
106 } | |
107 public void onSuccess(Artifact artifact) { | |
108 GWT.log("Successfully fed"); | |
109 //TODO and now? | |
110 // fireOutputParameterChanged(); | |
111 // Also update content of spinnerbox | |
112 requestRedraw(); | |
113 } | |
114 }); | |
115 } | |
116 } | |
117 ); | |
118 | 149 |
119 DynamicForm formWrap = new DynamicForm(); | 150 DynamicForm formWrap = new DynamicForm(); |
120 formWrap.setFields(spinnerItem); | 151 formWrap.setFields(spinnerItem); |
121 formWrap.setTitlePrefix(""); | 152 formWrap.setTitlePrefix(""); |
122 formWrap.setTitleSuffix(""); | 153 formWrap.setTitleSuffix(""); |