changeset 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 9220ab02f34f
files flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java
diffstat 1 files changed, 39 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue Dec 11 16:24:57 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue Dec 11 16:25:41 2012 +0100
@@ -391,49 +391,54 @@
 
 
     protected void artifactChanged() {
-        ArtifactDescription desc = getArtifact().getArtifactDescription();
-        //OutputMode[] outs        = desc.getOutputModes();
-        final Recommendation[] recom = desc.getRecommendations();
-
         Collection c = getCollection();
 
         if (c != null) {
-            Config config = Config.getInstance();
-            String locale = config.getLocale();
-
-            describeCollectionService.describe(c.identifier(), locale,
-                new AsyncCallback<Collection>() {
-                    @Override
-                    public void onFailure(Throwable caught) {
-                        GWT.log("Could not DESCRIBE collection.");
-                        SC.warn(FLYS.getExceptionString(messages, caught));
-                    }
-
-
-                    @Override
-                    public void onSuccess(Collection newCollection) {
-                        GWT.log("Successfully DESCRIBED collection.");
-                        boolean loaded = true;
-                        for (Recommendation r: recom) {
-                            if(!newCollection.loadedRecommendation(r)) {
-                                loaded = false;
-                            }
-                        }
-                        if  (!loaded) {
-                            loadRecommendedArtifacts(recom);
-                        }
-                        else {
-                            setCollection(newCollection);
-                        }
-                    }
-                }
-            );
+            loadCollection(c);
         }
         else {
             updateView();
         }
     }
 
+    /**
+     * Loads all information of a collection
+     * @param c the Collection
+     */
+    private void loadCollection(Collection c) {
+        ArtifactDescription desc = getArtifact().getArtifactDescription();
+        final Recommendation[] recom = desc.getRecommendations();
+        Config config = Config.getInstance();
+        String locale = config.getLocale();
+
+        describeCollectionService.describe(c.identifier(), locale,
+            new AsyncCallback<Collection>() {
+                @Override
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not DESCRIBE collection.");
+                    SC.warn(FLYS.getExceptionString(messages, caught));
+                }
+
+                @Override
+                public void onSuccess(Collection newCollection) {
+                    GWT.log("Successfully DESCRIBED collection.");
+                    boolean loaded = true;
+                    for (Recommendation r: recom) {
+                        if(!newCollection.loadedRecommendation(r)) {
+                            loaded = false;
+                        }
+                    }
+                    if  (!loaded) {
+                        loadRecommendedArtifacts(recom);
+                    }
+                    else {
+                        setCollection(newCollection);
+                    }
+                }
+            }
+        );
+    }
+
 
     /**
      * Returns the collection of displayed by this view.

http://dive4elements.wald.intevation.org