diff flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 30:5709bd8f4d7c

Added a new widget that combines the module and the river selection. Users can now choose the desired plugin and river in one step. flys-client/trunk@1433 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 09 Mar 2011 09:41:45 +0000
parents c19985f75118
children 88c530c25968
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Mar 09 08:00:06 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Wed Mar 09 09:41:45 2011 +0000
@@ -23,7 +23,11 @@
 import de.intevation.flys.client.shared.model.ArtifactDescription;
 import de.intevation.flys.client.shared.model.Collection;
 import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DefaultData;
+import de.intevation.flys.client.shared.model.DefaultDataItem;
 import de.intevation.flys.client.shared.model.DefaultCollection;
+import de.intevation.flys.client.shared.model.River;
 
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.FLYS;
@@ -38,6 +42,7 @@
 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
 import de.intevation.flys.client.client.services.CreateCollectionService;
 import de.intevation.flys.client.client.services.CreateCollectionServiceAsync;
+import de.intevation.flys.client.client.ui.ModuleSelection;
 
 
 /**
@@ -71,6 +76,9 @@
     /** The collection to be displayed.*/
     protected Collection collection;
 
+    /** The artifact that handles the parameterization.*/
+    protected Artifact artifact;
+
     protected TabSet tabs;
 
     /** The parameter tab.*/
@@ -201,33 +209,40 @@
 
 
     /**
-     * This method creates a Canvas displaying the plugins of FLYS.
+     * This method creates a Canvas displaying the plugins of FLYS combined with
+     * a widget to select a river.
      *
-     * @return a Canvas that displays the plugins of FLYS.
+     * @return a Canvas that displays the supported plugins and rivers of FLYS.
      */
     protected Canvas renderNew() {
-        VLayout newLayout = new VLayout();
-
-        DynamicForm    form  = new DynamicForm();
-        RadioGroupItem radio = new RadioGroupItem("plugin");
+        River[] rivers   = flys.getRivers();
+        DataItem[] items = new DataItem[rivers.length];
 
-        radio.setShowTitle(false);
-        radio.setVertical(false);
-        radio.setValueMap(
-            messages.winfo(),
-            messages.minfo(),
-            messages.map(),
-            messages.fix());
+        int i = 0;
+        for (River river: rivers) {
+            String name = river.getName();
+            items[i++]  = new DefaultDataItem(name, null, name);
+        }
 
-        form.setFields(radio);
+        Data data = new DefaultData(
+            "RIVER", "RIVER SELECTION", null, items, null);
 
-        IButton go = new IButton(messages.next());
-        go.addClickHandler(new ClickHandler() {
-            public void onClick(ClickEvent event) {
+        ModuleSelection widget         = new ModuleSelection();
+        HasStepForwardHandlers handler = (HasStepForwardHandlers) widget;
+
+        handler.addStepForwardHandler(new StepForwardHandler() {
+            public void onStepForward(StepForwardEvent event) {
+                Data[] data = event.getData();
+
+                DataItem[] moduleItems = data[0].getItems();
+                DataItem[] riversItems = data[1].getItems();
+
+                String module = moduleItems[0].getStringValue();
+                String river  = riversItems[0].getStringValue();
+
                 String serverUrl = Config.getInstance().getServerUrl();
-
                 artifactService.create(
-                    serverUrl, "winfo",
+                    serverUrl, module.toLowerCase(),
                     new AsyncCallback<Artifact>() {
                         public void onFailure(Throwable caught) {
                             GWT.log("Could not create the new artifact.");
@@ -236,19 +251,25 @@
 
                         public void onSuccess(Artifact artifact) {
                             GWT.log("Successfully created a new artifact.");
-                            Collection c = new DefaultCollection("TODO");
+                            setArtifact(artifact);
 
-                            c.addArtifact(artifact);
-                            setCollection(c);
+                            GWT.log("TODO: FEED WITH RIVER!");
                         }
                 });
             }
         });
 
-        newLayout.addMember(form);
-        newLayout.addMember(go);
+        return widget.create(data);
+    }
 
-        return newLayout;
+
+    /**
+     * Set the current artifact that is the master of the parameterization.
+     *
+     * @param artifact The new artifact.
+     */
+    protected void setArtifact(Artifact artifact) {
+        this.artifact = artifact;
     }
 
 

http://dive4elements.wald.intevation.org