changeset 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 5c3d685546a6
children f7967d12ce6e
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java
diffstat 4 files changed, 61 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Mar 30 07:35:59 2011 +0000
+++ b/flys-client/ChangeLog	Wed Mar 30 07:40:53 2011 +0000
@@ -1,3 +1,17 @@
+2011-03-29  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java: The
+	  CollectionView no longer gets an empty collection when it is created.
+
+	* src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java:
+	  The CollectionViews are no longer stored in a Map but in a List.
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  Bugfix: We just create a new collection a single time - if no one is
+	  existing. If the output modes of the artifact that is used for the
+	  parameterization changes, we fetch the new DESCRIBE document of the
+	  collection using the new DescribeCollectionService.
+
 2011-03-29  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Wed Mar 30 07:35:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Wed Mar 30 07:40:53 2011 +0000
@@ -189,14 +189,10 @@
      * This method creates a new CollectionView and adds it to the workspace.
      */
     public void newProject() {
-        // TODO Call the REST service to create a new Collection
-        // TODO Use the UUID of the Collection to add a new CollectionView!
-        Collection c = new DefaultCollection(new java.util.Date().toString());
+        CollectionView view = new CollectionView(this);
+        workspace.addView(view);
 
-        CollectionView view = new CollectionView(this, c);
         view.addCollectionChangeHandler(getProjectList());
-
-        workspace.addView(c.identifier(), view);
     }
 
 
--- 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();
         }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java	Wed Mar 30 07:35:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java	Wed Mar 30 07:40:53 2011 +0000
@@ -2,8 +2,8 @@
 
 import com.smartgwt.client.widgets.Canvas;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.ArrayList;
+import java.util.List;
 
 
 /**
@@ -12,7 +12,7 @@
 public class FLYSWorkspace extends Canvas {
 
     /** A map that contains the open CollectionViews. */
-    protected Map<String, CollectionView> views;
+    protected List<CollectionView> views;
 
 
     /**
@@ -20,7 +20,7 @@
      * CollectionViews opened.
      */
     public FLYSWorkspace() {
-        views = new HashMap<String, CollectionView>();
+        views = new ArrayList<CollectionView>();
     }
 
 
@@ -30,9 +30,8 @@
      *
      * @param collectionView A new CollectionView.
      */
-    public void addView(String uuid, CollectionView collectionView) {
-        views.put(uuid, collectionView);
-
+    public void addView(CollectionView collectionView) {
+        views.add(collectionView);
         addChild(collectionView);
     }
 }

http://dive4elements.wald.intevation.org