diff flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 100:95b30a5d6350

Bugfix: A collection view just creates a single time a new collection - even if we step back to a previous state and go forward afterwards. flys-client/trunk@1614 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 30 Mar 2011 07:40:53 +0000
parents fa3d9f79dff5
children f7967d12ce6e
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Mar 30 07:35:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Mar 30 07:40:53 2011 +0000
@@ -34,6 +34,8 @@
 import de.intevation.flys.client.client.services.AddArtifactServiceAsync;
 import de.intevation.flys.client.client.services.CreateCollectionService;
 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync;
+import de.intevation.flys.client.client.services.DescribeCollectionService;
+import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync;
 
 
 /**
@@ -52,6 +54,10 @@
     protected AddArtifactServiceAsync addArtifactService =
         GWT.create(AddArtifactService.class);
 
+    /** The DescribeCollectionService used to update the existing collection. */
+    protected DescribeCollectionServiceAsync describeCollectionService =
+        GWT.create(DescribeCollectionService.class);
+
     /** The message class that provides i18n strings.*/
     protected FLYSMessages messages = GWT.create(FLYSMessages.class);
 
@@ -85,15 +91,13 @@
      *
      * @param collection The collection to be displayed.
      */
-    public CollectionView(FLYS flys, Collection collection) {
-        this.flys       = flys;
-        this.collection = collection;
-
-        this.tabs              = new TabSet();
-        this.outputTabs        = new HashMap<String, OutputTab>();
-        this.handlers          = new ArrayList<CollectionChangeHandler>();
-        this.layout            = new VLayout();
-        this.parameterList     = new ParameterList(
+    public CollectionView(FLYS flys) {
+        this.flys          = flys;
+        this.tabs          = new TabSet();
+        this.outputTabs    = new HashMap<String, OutputTab>();
+        this.handlers      = new ArrayList<CollectionChangeHandler>();
+        this.layout        = new VLayout();
+        this.parameterList = new ParameterList(
             flys, this, messages.new_project());
 
         addCollectionChangeHandler(this);
@@ -134,6 +138,8 @@
      * @param ownerId The uuid of the user that should own the new collection.
      */
     protected void createNewCollection(String ownerId) {
+        GWT.log("CollectionView.createNewCollection");
+
         Config config          = Config.getInstance();
         final String serverUrl = config.getServerUrl();
 
@@ -238,7 +244,8 @@
      * @param event The ParameterChangeEvent.
      */
     public void onParameterChange(ParameterChangeEvent event) {
-        GWT.log("Parameter have changed.");
+        GWT.log("CollectionView.onParameterChange");
+
         Artifact art             = event.getNewValue();
         ArtifactDescription desc = art.getArtifactDescription();
         OutputMode[] outs        = desc.getOutputModes();
@@ -246,10 +253,31 @@
         setArtifact(art);
         clearOutputTabs();
 
-        if (outs != null) {
+        Collection collection = getCollection();
+
+        if (outs != null && collection == null) {
             User user = getFlys().getCurrentUser();
             createNewCollection(user.identifier());
         }
+        else if (outs != null && collection != null) {
+            Config config = Config.getInstance();
+            String url    = config.getServerUrl();
+
+            describeCollectionService.describe(collection.identifier(), url,
+                new AsyncCallback<Collection>() {
+                    public void onFailure(Throwable caught) {
+                        GWT.log("Could not DESCRIBE collection.");
+                        GWT.log(caught.getMessage());
+                    }
+
+
+                    public void onSuccess(Collection newCollection) {
+                        GWT.log("Successfully DESCRIBED collection.");
+                        setCollection(newCollection);
+                    }
+                }
+            );
+        }
         else {
             updateView();
         }

http://dive4elements.wald.intevation.org