changeset 908:a680ccec5dd6

Create new collections initially when starting a new project. flys-client/trunk@2765 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 15 Sep 2011 15:55:30 +0000 (2011-09-15)
parents 24d15c2e0da3
children 794d1af42987
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java
diffstat 2 files changed, 28 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Sep 15 15:28:31 2011 +0000
+++ b/flys-client/ChangeLog	Thu Sep 15 15:55:30 2011 +0000
@@ -1,3 +1,15 @@
+2011-09-15  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Create a new collection if no Collection is given while initializing a
+	  CollectionView. This is necessary, because a Collection is required in
+	  states that try to add cloned Artifacts (as it is the case in
+	  WspDatacagePanel).
+
+	  !! NOTE: This changes the behaviour - before, Collections have been
+	  created when a Collection has Outputs. Now, a Collection is initially
+	  created when the user starts a new project. !!
+
 2011-09-15  Raimund Renkert <raimund.renkert@intevation.de>
 
 	Issue199
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Thu Sep 15 15:28:31 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Thu Sep 15 15:55:30 2011 +0000
@@ -118,6 +118,10 @@
      * @param collection The collection to be displayed.
      */
     public CollectionView(FLYS flys) {
+        // do this first because it takes longer than the other stuff in here.
+        User user = flys.getCurrentUser();
+        createNewCollection(user.identifier());
+
         this.flys          = flys;
         this.tabs          = new TabSet();
         this.outputTabs    = new HashMap<String, OutputTab>();
@@ -221,19 +225,7 @@
 
                 public void onSuccess(Collection collection) {
                     GWT.log("Successfully created a new collection.");
-
                     setCollection(collection);
-
-                    Artifact artifact = getArtifact();
-                    addArtifactToCollection(artifact);
-                    // Load recommendations, if any.
-                    ArtifactDescription desc = 
-                         artifact.getArtifactDescription();
-                    Recommendation[] recom = desc.getRecommendations();
-
-                    if (recom != null && collection != null) {
-                        loadRecommendedArtifacts(recom);
-                    }
                 }
             });
     }
@@ -359,11 +351,7 @@
             loadRecommendedArtifacts(recom);
         }
 
-        if (outs != null && c == null) {
-            User user = getFlys().getCurrentUser();
-            createNewCollection(user.identifier());
-        }
-        else if (c != null) {
+        if (c != null) {
             Config config = Config.getInstance();
             String url    = config.getServerUrl();
             String locale = config.getLocale();
@@ -399,12 +387,17 @@
     }
 
 
+    protected void setCollection(Collection collection) {
+        setCollection(collection, false);
+    }
+
+
     /**
      * Set the current collection.
      *
      * @param collection The new collection.
      */
-    protected void setCollection(Collection collection) {
+    protected void setCollection(Collection collection, boolean suppress) {
         if (collection != null && this.collection == null) {
             flys.getWorkspace().addView(collection.identifier(), this);
         }
@@ -413,7 +406,10 @@
         this.collection = collection;
 
         setTitle(collection.getName() + " (UUID: " + collection.identifier() + ")");
-        fireCollectionChangeEvent(tmp, this.collection);
+
+        if (!suppress) {
+            fireCollectionChangeEvent(tmp, this.collection);
+        }
     }
 
 
@@ -555,7 +551,7 @@
     }
 
 
-    protected void addArtifactToCollection(final Artifact artifact) {
+    public void addArtifactToCollection(final Artifact artifact) {
         Config config               = Config.getInstance();
         final String url            = config.getServerUrl();
         final String locale         = config.getLocale();

http://dive4elements.wald.intevation.org