comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 71:987567f31200

Adjusted the return type of the CreateCollectionService and added code to react on Collection changes (like output modes). flys-client/trunk@1573 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 25 Mar 2011 11:51:54 +0000
parents f793d35bfb08
children 9b726350ab07
comparison
equal deleted inserted replaced
70:493efc8e4e28 71:987567f31200
20 import de.intevation.flys.client.shared.model.Data; 20 import de.intevation.flys.client.shared.model.Data;
21 import de.intevation.flys.client.shared.model.DataItem; 21 import de.intevation.flys.client.shared.model.DataItem;
22 import de.intevation.flys.client.shared.model.DataList; 22 import de.intevation.flys.client.shared.model.DataList;
23 import de.intevation.flys.client.shared.model.DefaultData; 23 import de.intevation.flys.client.shared.model.DefaultData;
24 import de.intevation.flys.client.shared.model.DefaultDataItem; 24 import de.intevation.flys.client.shared.model.DefaultDataItem;
25 import de.intevation.flys.client.shared.model.OutputMode;
25 import de.intevation.flys.client.shared.model.River; 26 import de.intevation.flys.client.shared.model.River;
27 import de.intevation.flys.client.shared.model.User;
26 28
27 import de.intevation.flys.client.client.Config; 29 import de.intevation.flys.client.client.Config;
28 import de.intevation.flys.client.client.FLYS; 30 import de.intevation.flys.client.client.FLYS;
29 import de.intevation.flys.client.client.FLYSMessages; 31 import de.intevation.flys.client.client.FLYSMessages;
30 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers; 32 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers;
37 import de.intevation.flys.client.client.event.ParameterChangeHandler; 39 import de.intevation.flys.client.client.event.ParameterChangeHandler;
38 import de.intevation.flys.client.client.event.StepBackEvent; 40 import de.intevation.flys.client.client.event.StepBackEvent;
39 import de.intevation.flys.client.client.event.StepBackHandler; 41 import de.intevation.flys.client.client.event.StepBackHandler;
40 import de.intevation.flys.client.client.event.StepForwardEvent; 42 import de.intevation.flys.client.client.event.StepForwardEvent;
41 import de.intevation.flys.client.client.event.StepForwardHandler; 43 import de.intevation.flys.client.client.event.StepForwardHandler;
44 import de.intevation.flys.client.client.services.AddArtifactService;
45 import de.intevation.flys.client.client.services.AddArtifactServiceAsync;
42 import de.intevation.flys.client.client.services.AdvanceService; 46 import de.intevation.flys.client.client.services.AdvanceService;
43 import de.intevation.flys.client.client.services.AdvanceServiceAsync; 47 import de.intevation.flys.client.client.services.AdvanceServiceAsync;
44 import de.intevation.flys.client.client.services.ArtifactService; 48 import de.intevation.flys.client.client.services.ArtifactService;
45 import de.intevation.flys.client.client.services.ArtifactServiceAsync; 49 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
46 import de.intevation.flys.client.client.services.StepForwardService; 50 import de.intevation.flys.client.client.services.StepForwardService;
73 77
74 /** The ArtifactService used to communicate with the Artifact server. */ 78 /** The ArtifactService used to communicate with the Artifact server. */
75 protected CreateCollectionServiceAsync createCollectionService = 79 protected CreateCollectionServiceAsync createCollectionService =
76 GWT.create(CreateCollectionService.class); 80 GWT.create(CreateCollectionService.class);
77 81
82 /** The AddArtifactService used to add an artifact to a collection. */
83 protected AddArtifactServiceAsync addArtifactService =
84 GWT.create(AddArtifactService.class);
85
78 /** The message class that provides i18n strings.*/ 86 /** The message class that provides i18n strings.*/
79 FLYSMessages messages = GWT.create(FLYSMessages.class); 87 FLYSMessages messages = GWT.create(FLYSMessages.class);
80 88
81 /** The FLYS instance used to call services.*/ 89 /** The FLYS instance used to call services.*/
82 protected FLYS flys; 90 protected FLYS flys;
164 * collection in the artifact server. 172 * collection in the artifact server.
165 * 173 *
166 * @param ownerId The uuid of the user that should own the new collection. 174 * @param ownerId The uuid of the user that should own the new collection.
167 */ 175 */
168 protected void createNewCollection(String ownerId) { 176 protected void createNewCollection(String ownerId) {
169 Config config = Config.getInstance(); 177 Config config = Config.getInstance();
170 String serverUrl = config.getServerUrl(); 178 final String serverUrl = config.getServerUrl();
171 179
172 createCollectionService.create( 180 createCollectionService.create(
173 serverUrl, ownerId, 181 serverUrl, ownerId,
174 new AsyncCallback<String>() { 182 new AsyncCallback<Collection>() {
175 public void onFailure(Throwable caught) { 183 public void onFailure(Throwable caught) {
176 GWT.log("Could not create the new collection."); 184 GWT.log("Could not create the new collection.");
177 GWT.log(caught.getMessage()); 185 GWT.log(caught.getMessage());
178 } 186 }
179 187
180 public void onSuccess(String uuid) { 188 public void onSuccess(Collection collection) {
181 GWT.log("Successfully created a new collection."); 189 GWT.log("Successfully created a new collection.");
182 GWT.log("NEW collection uuid: " + uuid); 190
191 Artifact artifact = getArtifact();
192 addArtifactService.add(collection, artifact, serverUrl,
193 new AsyncCallback<Collection>() {
194
195 public void onFailure(Throwable caught) {
196 GWT.log("An error occured while adding artifact.");
197 }
198
199 public void onSuccess(Collection newCollection) {
200 GWT.log("Successfully added artifact.");
201 setCollection(newCollection);
202 }
203 }
204 );
183 } 205 }
184 }); 206 });
185 } 207 }
186 208
187 209
244 * been chosen. 266 * been chosen.
245 * 267 *
246 * @return true, if the Collection is new. 268 * @return true, if the Collection is new.
247 */ 269 */
248 public boolean isNew() { 270 public boolean isNew() {
249 return collection.getArtifactLength() == 0 ? true : false; 271 return collection.getItemLength() == 0 ? true : false;
250 } 272 }
251 273
252 274
253 /** 275 /**
254 * This method creates a Canvas displaying the plugins of FLYS combined with 276 * This method creates a Canvas displaying the plugins of FLYS combined with
321 return widget.create(list); 343 return widget.create(list);
322 } 344 }
323 345
324 346
325 /** 347 /**
348 * Returns the artifact that is used for the parameterization.
349 *
350 * @return the artifact that is used for the parameterization.
351 */
352 protected Artifact getArtifact() {
353 return artifact;
354 }
355
356
357 /**
326 * Set the current artifact that is the master of the parameterization. 358 * Set the current artifact that is the master of the parameterization.
327 * 359 *
328 * @param artifact The new artifact. 360 * @param artifact The new artifact.
329 */ 361 */
330 protected void setArtifact(Artifact artifact) { 362 protected void setArtifact(Artifact artifact) {
340 * parameterization has changed. 372 * parameterization has changed.
341 * 373 *
342 * @param event The ParameterChangeEvent. 374 * @param event The ParameterChangeEvent.
343 */ 375 */
344 public void onParameterChange(ParameterChangeEvent event) { 376 public void onParameterChange(ParameterChangeEvent event) {
345 377 Artifact art = event.getNewValue();
346 updateView(); 378 ArtifactDescription desc = art.getArtifactDescription();
379 OutputMode[] outs = desc.getOutputModes();
380
381 if (outs != null) {
382 User user = getFlys().getCurrentUser();
383 createNewCollection(user.identifier());
384 }
385 else {
386 updateView();
387 }
347 } 388 }
348 389
349 390
350 /** 391 /**
351 * Set the current collection. 392 * Set the current collection.

http://dive4elements.wald.intevation.org