changeset 225:9040663aee01

Filled the context menu point 'Open project' of the ProjectList with life - it opens a new window displaying the parameterization of the selected project. flys-client/trunk@1670 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 12 Apr 2011 11:01:09 +0000
parents a4a68b4ee2a3
children a13382876e5d
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/ProjectList.java
diffstat 3 files changed, 93 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Tue Apr 12 10:54:59 2011 +0000
+++ b/flys-client/ChangeLog	Tue Apr 12 11:01:09 2011 +0000
@@ -1,3 +1,18 @@
+2011-04-12  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/FLYS.java:
+	  Implemented a method to open an existing project. The method takes the
+	  UUID of a Collection and creates a new CollectionView with
+	  ParameterList based on the first Artifact that is stored in that
+	  Collection.
+
+	  NOTE: Maybe we need to introduce a mechanism to mark the artifact that
+	  defines the parameterization. I am not sure, if the first artifact is
+	  always the artifact that the Collection's parameterization is based on!
+
+	* src/main/java/de/intevation/flys/client/client/ui/ProjectList.java:
+	  Triggers the method of FLYS to open an existing project.
+
 2011-04-12  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/ParameterList.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Tue Apr 12 10:54:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYS.java	Tue Apr 12 11:01:09 2011 +0000
@@ -11,11 +11,17 @@
 import com.smartgwt.client.widgets.layout.HLayout;
 
 import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.CollectionItem;
 import de.intevation.flys.client.shared.model.River;
 import de.intevation.flys.client.shared.model.User;
 
 import de.intevation.flys.client.client.services.ArtifactService;
 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
+import de.intevation.flys.client.client.services.DescribeCollectionService;
+import de.intevation.flys.client.client.services.DescribeCollectionServiceAsync;
+import de.intevation.flys.client.client.services.GetArtifactService;
+import de.intevation.flys.client.client.services.GetArtifactServiceAsync;
 import de.intevation.flys.client.client.services.RiverService;
 import de.intevation.flys.client.client.services.RiverServiceAsync;
 import de.intevation.flys.client.client.services.UserService;
@@ -49,6 +55,15 @@
     protected ArtifactServiceAsync artifactService =
         GWT.create(ArtifactService.class);
 
+    /** The ArtifactService used to communicate with the Artifact server. */
+    protected DescribeCollectionServiceAsync describeCollectionService =
+        GWT.create(DescribeCollectionService.class);
+
+    /** The GetArtifactService used to open an existing collection. */
+    protected GetArtifactServiceAsync getArtifactService =
+        GWT.create(GetArtifactService.class);
+
+
     /** The menu bar at the top of the application.*/
     protected MainMenu menu;
 
@@ -115,7 +130,7 @@
 
                 menu.setCurrentUser(user);
 
-                projectList = new ProjectList(user);
+                projectList = new ProjectList(FLYS.this, user);
                 workspace   = new FLYSWorkspace();
                 view.setProjectList(projectList);
                 view.setFLYSWorkspace(workspace);
@@ -216,6 +231,56 @@
     }
 
 
+    public void openProject(String collectionID) {
+        if (collectionID == null) {
+            return;
+        }
+
+        GWT.log("Open existing project: " + collectionID);
+
+        Config config    = Config.getInstance();
+        final String url = config.getServerUrl();
+
+        describeCollectionService.describe(collectionID, url,
+            new AsyncCallback<Collection>() {
+                public void onFailure(Throwable caught) {
+                    SC.warn(MSG.getString(caught.getMessage()));
+                }
+
+                public void onSuccess(Collection c) {
+                    final Collection collection = c;
+                    final CollectionItem   item = c.getItem(0);
+
+                    if (item == null) {
+                        SC.warn(MSG.error_load_parameterization());
+                        return;
+                    }
+
+                    getArtifactService.getArtifact(
+                        url,
+                        item.identifier(),
+                        item.hash(),
+                        new AsyncCallback<Artifact>() {
+                            public void onFailure(Throwable caught) {
+                                SC.warn(MSG.getString(caught.getMessage()));
+                            }
+
+                            public void onSuccess(Artifact artifact) {
+                                CollectionView view = new CollectionView(
+                                    FLYS.this, collection, artifact);
+
+                                view.addCollectionChangeHandler(
+                                    getProjectList());
+
+                                workspace.addView(view);
+                            }
+                    });
+
+                }
+        });
+    }
+
+
     /**
      * Create a new Artifact.
      */
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Tue Apr 12 10:54:59 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java	Tue Apr 12 11:01:09 2011 +0000
@@ -23,6 +23,7 @@
 import de.intevation.flys.client.shared.model.User;
 
 import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.FLYS;
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.event.CollectionChangeEvent;
 import de.intevation.flys.client.client.event.CollectionChangeHandler;
@@ -46,6 +47,9 @@
     protected UserCollectionsServiceAsync userCollectionsService =
         GWT.create(UserCollectionsService.class);
 
+    /** A pointer to the FLYS instance.*/
+    protected FLYS flys;
+
     /** The user whose projects should be displayed.*/
     protected User user;
 
@@ -58,7 +62,8 @@
      *
      * @param user The user.
      */
-    public ProjectList(User user) {
+    public ProjectList(FLYS flys, User user) {
+        this.flys = flys;
         this.user = user;
 
         grid = new CollectionGrid();
@@ -101,6 +106,11 @@
     }
 
 
+    public FLYS getFlys() {
+        return flys;
+    }
+
+
     /**
      * Creates a new context menu that interacts with a CollectionRecord.
      *
@@ -115,7 +125,7 @@
         MenuItem open = new MenuItem(messages.open_project());
         open.addClickHandler(new ClickHandler() {
             public void onClick(MenuItemClickEvent evt) {
-                SC.say("Open project: " + record.getName());
+                getFlys().openProject(record.getCollection().identifier());
             }
         });
 

http://dive4elements.wald.intevation.org