Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 36:3cacc9d2dd01
CollectionView implements HasParameterChangeHandler and ParameterChangeHandler interfaces.
flys-client/trunk@1457 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Mar 2011 13:49:48 +0000 |
parents | 88c530c25968 |
children | b6b89ff1adee |
comparison
equal
deleted
inserted
replaced
35:d692e2ff95e2 | 36:3cacc9d2dd01 |
---|---|
25 | 25 |
26 import de.intevation.flys.client.client.Config; | 26 import de.intevation.flys.client.client.Config; |
27 import de.intevation.flys.client.client.FLYS; | 27 import de.intevation.flys.client.client.FLYS; |
28 import de.intevation.flys.client.client.FLYSMessages; | 28 import de.intevation.flys.client.client.FLYSMessages; |
29 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; | 29 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; |
30 import de.intevation.flys.client.client.event.HasParameterChangeHandler; | |
30 import de.intevation.flys.client.client.event.HasStepForwardHandlers; | 31 import de.intevation.flys.client.client.event.HasStepForwardHandlers; |
31 import de.intevation.flys.client.client.event.CollectionChangeEvent; | 32 import de.intevation.flys.client.client.event.CollectionChangeEvent; |
33 import de.intevation.flys.client.client.event.CollectionChangeHandler; | |
34 import de.intevation.flys.client.client.event.ParameterChangeEvent; | |
35 import de.intevation.flys.client.client.event.ParameterChangeHandler; | |
32 import de.intevation.flys.client.client.event.StepForwardEvent; | 36 import de.intevation.flys.client.client.event.StepForwardEvent; |
33 import de.intevation.flys.client.client.event.StepForwardHandler; | 37 import de.intevation.flys.client.client.event.StepForwardHandler; |
34 import de.intevation.flys.client.client.event.CollectionChangeHandler; | |
35 import de.intevation.flys.client.client.services.ArtifactService; | 38 import de.intevation.flys.client.client.services.ArtifactService; |
36 import de.intevation.flys.client.client.services.ArtifactServiceAsync; | 39 import de.intevation.flys.client.client.services.ArtifactServiceAsync; |
37 import de.intevation.flys.client.client.services.StepForwardService; | 40 import de.intevation.flys.client.client.services.StepForwardService; |
38 import de.intevation.flys.client.client.services.StepForwardServiceAsync; | 41 import de.intevation.flys.client.client.services.StepForwardServiceAsync; |
39 import de.intevation.flys.client.client.services.CreateCollectionService; | 42 import de.intevation.flys.client.client.services.CreateCollectionService; |
45 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 48 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
46 */ | 49 */ |
47 public class CollectionView | 50 public class CollectionView |
48 extends Window | 51 extends Window |
49 implements CollectionChangeHandler, HasCollectionChangeHandlers, | 52 implements CollectionChangeHandler, HasCollectionChangeHandlers, |
53 HasParameterChangeHandler, ParameterChangeHandler, | |
50 StepForwardHandler | 54 StepForwardHandler |
51 { | 55 { |
52 /** The ArtifactService used to communicate with the Artifact server. */ | 56 /** The ArtifactService used to communicate with the Artifact server. */ |
53 protected ArtifactServiceAsync artifactService = | 57 protected ArtifactServiceAsync artifactService = |
54 GWT.create(ArtifactService.class); | 58 GWT.create(ArtifactService.class); |
71 protected ParameterList parameterList; | 75 protected ParameterList parameterList; |
72 | 76 |
73 /** The list of ValueChangeHandlers.*/ | 77 /** The list of ValueChangeHandlers.*/ |
74 protected List<CollectionChangeHandler> handlers; | 78 protected List<CollectionChangeHandler> handlers; |
75 | 79 |
80 /** The list of ParameterizationChangeHandler.*/ | |
81 protected List<ParameterChangeHandler> parameterHandlers; | |
82 | |
76 /** The collection to be displayed.*/ | 83 /** The collection to be displayed.*/ |
77 protected Collection collection; | 84 protected Collection collection; |
78 | 85 |
79 /** The artifact that handles the parameterization.*/ | 86 /** The artifact that handles the parameterization.*/ |
80 protected Artifact artifact; | 87 protected Artifact artifact; |
99 */ | 106 */ |
100 public CollectionView(FLYS flys, Collection collection) { | 107 public CollectionView(FLYS flys, Collection collection) { |
101 this.flys = flys; | 108 this.flys = flys; |
102 this.collection = collection; | 109 this.collection = collection; |
103 | 110 |
104 this.tabs = new TabSet(); | 111 this.tabs = new TabSet(); |
105 this.parameterTab = new Tab(messages.winfo()); | 112 this.parameterTab = new Tab(messages.winfo()); |
106 this.parameterList = new ParameterList(); | 113 this.parameterList = new ParameterList(); |
107 this.handlers = new ArrayList<CollectionChangeHandler>(); | 114 this.handlers = new ArrayList<CollectionChangeHandler>(); |
108 this.layout = new VLayout(); | 115 this.parameterHandlers = new ArrayList<ParameterChangeHandler>(); |
116 this.layout = new VLayout(); | |
109 | 117 |
110 addCollectionChangeHandler(this); | 118 addCollectionChangeHandler(this); |
119 addParameterChangeHandler(this); | |
111 | 120 |
112 init(); | 121 init(); |
113 } | 122 } |
114 | 123 |
115 | 124 |
183 } | 192 } |
184 } | 193 } |
185 | 194 |
186 | 195 |
187 /** | 196 /** |
197 * This method registers a new ParameterChangeHandler. | |
198 * | |
199 * @param handler The new ParameterChangeHandler. | |
200 */ | |
201 public void addParameterChangeHandler(ParameterChangeHandler handler) { | |
202 if (handler != null) { | |
203 parameterHandlers.add(handler); | |
204 } | |
205 } | |
206 | |
207 | |
208 /** | |
188 * This method calls the <code>onValueChange()</code> method of all | 209 * This method calls the <code>onValueChange()</code> method of all |
189 * registered ValueChangeHanders. | 210 * registered ValueChangeHanders. |
190 */ | 211 */ |
191 protected void fireCollectionChangeEvent( | 212 protected void fireCollectionChangeEvent( |
192 Collection old, Collection newCol) | 213 Collection old, Collection newCol) |
193 { | 214 { |
194 for (CollectionChangeHandler handler: handlers) { | 215 for (CollectionChangeHandler handler: handlers) { |
195 handler.onCollectionChange(new CollectionChangeEvent(old, newCol)); | 216 handler.onCollectionChange(new CollectionChangeEvent(old, newCol)); |
217 } | |
218 } | |
219 | |
220 | |
221 /** | |
222 * This method calls the <code>onParameterChange()</code> method of all | |
223 * registered ParameterChangeHandler. | |
224 */ | |
225 protected void fireParameterChangeEvent(Artifact old, Artifact newArt) { | |
226 for (ParameterChangeHandler handler: parameterHandlers) { | |
227 handler.onParameterChange(new ParameterChangeEvent(old, newArt)); | |
196 } | 228 } |
197 } | 229 } |
198 | 230 |
199 | 231 |
200 /** | 232 /** |
250 GWT.log(caught.getMessage()); | 282 GWT.log(caught.getMessage()); |
251 } | 283 } |
252 | 284 |
253 public void onSuccess(Artifact artifact) { | 285 public void onSuccess(Artifact artifact) { |
254 GWT.log("Successfully created a new artifact."); | 286 GWT.log("Successfully created a new artifact."); |
255 setArtifact(artifact); | |
256 | 287 |
257 forwardService.go(serverUrl, artifact, feedData, | 288 forwardService.go(serverUrl, artifact, feedData, |
258 new AsyncCallback<Artifact>() { | 289 new AsyncCallback<Artifact>() { |
259 public void onFailure(Throwable caught) { | 290 public void onFailure(Throwable caught) { |
260 GWT.log("Could not feed the artifact."); | 291 GWT.log("Could not feed the artifact."); |
279 * Set the current artifact that is the master of the parameterization. | 310 * Set the current artifact that is the master of the parameterization. |
280 * | 311 * |
281 * @param artifact The new artifact. | 312 * @param artifact The new artifact. |
282 */ | 313 */ |
283 protected void setArtifact(Artifact artifact) { | 314 protected void setArtifact(Artifact artifact) { |
315 Artifact tmp = this.artifact; | |
284 this.artifact = artifact; | 316 this.artifact = artifact; |
317 | |
318 fireParameterChangeEvent(tmp, this.artifact); | |
319 } | |
320 | |
321 | |
322 /** | |
323 * Implements the onCollectionChange() method to do update the GUI after the | |
324 * parameterization has changed. | |
325 * | |
326 * @param event The ParameterChangeEvent. | |
327 */ | |
328 public void onParameterChange(ParameterChangeEvent event) { | |
329 | |
330 // TODO IMPLEMENT ME | |
331 updateView(); | |
285 } | 332 } |
286 | 333 |
287 | 334 |
288 /** | 335 /** |
289 * Set the current collection. | 336 * Set the current collection. |
301 public void onCollectionChange(CollectionChangeEvent event) { | 348 public void onCollectionChange(CollectionChangeEvent event) { |
302 updateView(); | 349 updateView(); |
303 } | 350 } |
304 | 351 |
305 | 352 |
353 /** | |
354 * This method is called if the user clicks on the 'next' button to advance | |
355 * to the next state. | |
356 * | |
357 * @param event The StepForwardEvent. | |
358 */ | |
306 public void onStepForward(StepForwardEvent event) { | 359 public void onStepForward(StepForwardEvent event) { |
307 GWT.log("CollectionView - onStepForward()"); | 360 GWT.log("CollectionView - onStepForward()"); |
308 GWT.log("TODO: IMPLEMENT FEED!"); | 361 GWT.log("TODO: IMPLEMENT FEED!"); |
309 } | 362 } |
310 | 363 |
311 | 364 |
312 /** | 365 /** |
313 * Update the view (refresh the list of old and current data). | 366 * Update the view (refresh the list of old and current data). |
314 */ | 367 */ |
315 protected void updateView() { | 368 protected void updateView() { |
316 GWT.log("Update view of the collection: " + collection.identifier()); | 369 GWT.log("CollectionView.updateView()"); |
317 Artifact artifact = collection.getArtifact(0); | |
318 ArtifactDescription desc = artifact.getArtifactDescription(); | 370 ArtifactDescription desc = artifact.getArtifactDescription(); |
319 | 371 |
320 Data currentData = desc.getCurrentData(); | 372 Data currentData = desc.getCurrentData(); |
321 if (currentData != null) { | 373 if (currentData != null) { |
322 String uiProvider = currentData.getUIProvider(); | 374 String uiProvider = currentData.getUIProvider(); |