diff flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java @ 23:dc086030e6a3

The CollectionView is able to create new instances of a WINFO artifact and to display the artifact's state. flys-client/trunk@1337 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 22 Feb 2011 17:39:23 +0000
parents f48b2cb2e219
children c19985f75118
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue Feb 22 17:29:51 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Tue Feb 22 17:39:23 2011 +0000
@@ -14,18 +14,25 @@
 import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.layout.Layout;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.Tab;
+import com.smartgwt.client.widgets.tab.TabSet;
 
 import de.intevation.flys.client.shared.model.Artifact;
+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.DefaultCollection;
 
 import de.intevation.flys.client.client.Config;
 import de.intevation.flys.client.client.FLYS;
 import de.intevation.flys.client.client.FLYSMessages;
 import de.intevation.flys.client.client.event.HasCollectionChangeHandlers;
+import de.intevation.flys.client.client.event.HasStepForwardHandlers;
 import de.intevation.flys.client.client.event.CollectionChangeEvent;
+import de.intevation.flys.client.client.event.StepForwardEvent;
+import de.intevation.flys.client.client.event.StepForwardHandler;
 import de.intevation.flys.client.client.event.CollectionChangeHandler;
 import de.intevation.flys.client.client.services.ArtifactService;
 import de.intevation.flys.client.client.services.ArtifactServiceAsync;
@@ -36,8 +43,9 @@
  */
 public class CollectionView
 extends      Window
-implements   CollectionChangeHandler, HasCollectionChangeHandlers {
-
+implements   CollectionChangeHandler, HasCollectionChangeHandlers,
+             StepForwardHandler
+{
     /** The ArtifactService used to communicate with the Artifact server. */
     protected ArtifactServiceAsync artifactService =
         GWT.create(ArtifactService.class);
@@ -48,18 +56,26 @@
     /** The FLYS instance used to call services.*/
     protected FLYS flys;
 
+    /** The ParameterList.*/
+    protected ParameterList parameterList;
+
     /** The list of ValueChangeHandlers.*/
     protected List<CollectionChangeHandler> handlers;
 
     /** The collection to be displayed.*/
     protected Collection collection;
 
+    protected TabSet tabs;
+
     /** The parameter tab.*/
     protected Tab parameterTab;
 
     /** The output tab.*/
     protected Tab outputTab;
 
+    /** The layout.*/
+    protected Layout layout;
+
 
     /**
      * This constructor creates a new CollectionView that is used to display the
@@ -71,7 +87,11 @@
         this.flys       = flys;
         this.collection = collection;
 
-        this.handlers = new ArrayList<CollectionChangeHandler>();
+        this.tabs          = new TabSet();
+        this.parameterTab  = new Tab(messages.winfo());
+        this.parameterList = new ParameterList();
+        this.handlers      = new ArrayList<CollectionChangeHandler>();
+        this.layout        = new VLayout();
 
         addCollectionChangeHandler(this);
 
@@ -86,17 +106,22 @@
         setWidth(600);
         setHeight(400);
 
+        layout.setWidth100();
+
         setCanDragResize(true);
 
         DateTimeFormat dtf = DateTimeFormat.getFormat(messages.date_format());
         String lastAccess  = dtf.format(collection.getLastAccess());
         setTitle(lastAccess + " - " + collection.getName());
 
-        VLayout layout = new VLayout();
         addItem(layout);
 
+        layout.addMember(tabs);
+        tabs.addTab(parameterTab);
+
         if (isNew()) {
-            layout.addMember(renderNew());
+            tabs.setTabTitle(0, "MODUL");
+            tabs.updateTab(0, renderNew());
         }
     }
 
@@ -143,8 +168,7 @@
      * @return a Canvas that displays the plugins of FLYS.
      */
     protected Canvas renderNew() {
-        VLayout layout = new VLayout();
-        layout.setWidth100();
+        VLayout newLayout = new VLayout();
 
         DynamicForm    form  = new DynamicForm();
         RadioGroupItem radio = new RadioGroupItem("plugin");
@@ -175,18 +199,18 @@
                         public void onSuccess(Artifact artifact) {
                             GWT.log("Successfully created a new artifact.");
                             Collection c = new DefaultCollection("TODO");
+
                             c.addArtifact(artifact);
-
                             setCollection(c);
                         }
                 });
             }
         });
 
-        layout.addMember(form);
-        layout.addMember(go);
+        newLayout.addMember(form);
+        newLayout.addMember(go);
 
-        return layout;
+        return newLayout;
     }
 
 
@@ -208,9 +232,35 @@
     }
 
 
+    public void onStepForward(StepForwardEvent event) {
+        GWT.log("CollectionView - onStepForward()");
+        GWT.log("TODO: IMPLEMENT FEED!");
+    }
+
+
+    /**
+     * Update the view (refresh the list of old and current data).
+     */
     protected void updateView() {
         GWT.log("Update view of the collection: " + collection.identifier());
-        // TODO display the artifact information / data
+        Artifact artifact        = collection.getArtifact(0);
+        ArtifactDescription desc = artifact.getArtifactDescription();
+
+        Data currentData = desc.getCurrentData();
+        if (currentData != null) {
+            String uiProvider   = currentData.getUIProvider();
+            UIProvider provider = UIProviderFactory.getProvider(uiProvider);
+
+            HasStepForwardHandlers handler = (HasStepForwardHandlers) provider;
+            handler.addStepForwardHandler(this);
+
+            parameterList.setCurrentData(currentData, provider);
+        }
+
+        parameterList.addOldDatas(desc.getOldData());
+
+        tabs.setTabTitle(0, messages.winfo());
+        tabs.updateTab(0, parameterList);
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org