comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 4661:5025acdb3815

Move loading of the full Collection to an own method
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 11 Dec 2012 16:25:41 +0100
parents bb9ce9aece70
children 7c59baa150bd
comparison
equal deleted inserted replaced
4660:bb9ce9aece70 4661:5025acdb3815
389 setArtifact(event.getNewValue()); 389 setArtifact(event.getNewValue());
390 } 390 }
391 391
392 392
393 protected void artifactChanged() { 393 protected void artifactChanged() {
394 Collection c = getCollection();
395
396 if (c != null) {
397 loadCollection(c);
398 }
399 else {
400 updateView();
401 }
402 }
403
404 /**
405 * Loads all information of a collection
406 * @param c the Collection
407 */
408 private void loadCollection(Collection c) {
394 ArtifactDescription desc = getArtifact().getArtifactDescription(); 409 ArtifactDescription desc = getArtifact().getArtifactDescription();
395 //OutputMode[] outs = desc.getOutputModes();
396 final Recommendation[] recom = desc.getRecommendations(); 410 final Recommendation[] recom = desc.getRecommendations();
397 411 Config config = Config.getInstance();
398 Collection c = getCollection(); 412 String locale = config.getLocale();
399 413
400 if (c != null) { 414 describeCollectionService.describe(c.identifier(), locale,
401 Config config = Config.getInstance(); 415 new AsyncCallback<Collection>() {
402 String locale = config.getLocale(); 416 @Override
403 417 public void onFailure(Throwable caught) {
404 describeCollectionService.describe(c.identifier(), locale, 418 GWT.log("Could not DESCRIBE collection.");
405 new AsyncCallback<Collection>() { 419 SC.warn(FLYS.getExceptionString(messages, caught));
406 @Override 420 }
407 public void onFailure(Throwable caught) { 421
408 GWT.log("Could not DESCRIBE collection."); 422 @Override
409 SC.warn(FLYS.getExceptionString(messages, caught)); 423 public void onSuccess(Collection newCollection) {
410 } 424 GWT.log("Successfully DESCRIBED collection.");
411 425 boolean loaded = true;
412 426 for (Recommendation r: recom) {
413 @Override 427 if(!newCollection.loadedRecommendation(r)) {
414 public void onSuccess(Collection newCollection) { 428 loaded = false;
415 GWT.log("Successfully DESCRIBED collection.");
416 boolean loaded = true;
417 for (Recommendation r: recom) {
418 if(!newCollection.loadedRecommendation(r)) {
419 loaded = false;
420 }
421 }
422 if (!loaded) {
423 loadRecommendedArtifacts(recom);
424 }
425 else {
426 setCollection(newCollection);
427 } 429 }
428 } 430 }
431 if (!loaded) {
432 loadRecommendedArtifacts(recom);
433 }
434 else {
435 setCollection(newCollection);
436 }
429 } 437 }
430 ); 438 }
431 } 439 );
432 else {
433 updateView();
434 }
435 } 440 }
436 441
437 442
438 /** 443 /**
439 * Returns the collection of displayed by this view. 444 * Returns the collection of displayed by this view.

http://dive4elements.wald.intevation.org