changeset 74:c5586446f3c0

Available output modes are displayed in the tab bar of the collection view. flys-client/trunk@1577 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 28 Mar 2011 07:09:34 +0000
parents 39210a74db07
children 571843833129
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java flys-client/src/main/java/de/intevation/flys/client/client/ui/OutputTab.java
diffstat 3 files changed, 124 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Mon Mar 28 06:48:44 2011 +0000
+++ b/flys-client/ChangeLog	Mon Mar 28 07:09:34 2011 +0000
@@ -1,3 +1,13 @@
+2011-03-28  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java:
+	  The tab bar is extended with output tabs if the artifact used for the
+	  parameterization reaches a state with output modes.
+
+	* src/main/java/de/intevation/flys/client/client/ui/OutputTab.java: A
+	  base class that might be used to derive concrete output tabs for charts,
+	  maps and so on.
+
 2011-03-28  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/CollectionView.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Mon Mar 28 06:48:44 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java	Mon Mar 28 07:09:34 2011 +0000
@@ -1,7 +1,10 @@
 package de.intevation.flys.client.client.ui;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Set;
 
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.DateTimeFormat;
@@ -73,7 +76,7 @@
     protected Tab parameterTab;
 
     /** The output tab.*/
-    protected Tab outputTab;
+    protected Map<String, OutputTab> outputTabs;
 
     /** The layout.*/
     protected Layout layout;
@@ -91,6 +94,7 @@
 
         this.tabs              = new TabSet();
         this.parameterTab      = new Tab(messages.winfo());
+        this.outputTabs        = new HashMap<String, OutputTab>();
         this.parameterList     = new ParameterList(flys, this);
         this.handlers          = new ArrayList<CollectionChangeHandler>();
         this.layout            = new VLayout();
@@ -240,6 +244,7 @@
      * @param event The ParameterChangeEvent.
      */
     public void onParameterChange(ParameterChangeEvent event) {
+        GWT.log("Parameter have changed.");
         Artifact art             = event.getNewValue();
         ArtifactDescription desc = art.getArtifactDescription();
         OutputMode[] outs        = desc.getOutputModes();
@@ -251,12 +256,23 @@
             createNewCollection(user.identifier());
         }
         else {
+            clearOutputTabs();
             updateView();
         }
     }
 
 
     /**
+     * Returns the collection of displayed by this view.
+     *
+     * @return the collection of this view.
+     */
+    protected Collection getCollection() {
+        return collection;
+    }
+
+
+    /**
      * Set the current collection.
      *
      * @param collection The new collection.
@@ -270,18 +286,68 @@
 
 
     public void onCollectionChange(CollectionChangeEvent event) {
+        Collection newCol = event.getNewValue();
+
+        Map<String, OutputMode> outs = newCol.getOutputModes();
+
+        Set<String> keys = outs.keySet();
+        for (String outname: keys) {
+            addOutputTab(outname, outs.get(outname));
+        }
+
         updateView();
     }
 
 
     /**
+     * Adds a new tab for the OutputMode <i>out</i>.
+     *
+     * @param name The name and title of the output.
+     */
+    protected void addOutputTab(String name, OutputMode out) {
+        GWT.log("Add new output tab for '" + name + "'");
+        OutputTab tab = new OutputTab(name, getCollection(), out);
+        outputTabs.put(name, tab);
+    }
+
+
+    /**
+     * Removes all output mode tabs from tab bar.
+     */
+    protected void clearOutputTabs() {
+        GWT.log("Clear OutputTabs.");
+
+        int num = tabs.getNumTabs();
+
+        for (int i = num-1; i >= 1; i--) {
+            tabs.removeTab(i);
+        }
+
+        outputTabs.clear();
+    }
+
+
+    /**
      * Update the view (refresh the list of old and current data).
      */
     protected void updateView() {
         GWT.log("CollectionView.updateView()");
+        updateOutputTabs();
+    }
 
-        tabs.setTabTitle(0, messages.winfo());
-        tabs.updateTab(0, parameterList);
+
+    /**
+     * This method is used to update the tabs to show specific output modes.
+     */
+    protected void updateOutputTabs() {
+        GWT.log("Update output tabs.");
+        if (outputTabs != null) {
+            Set<String> keys = outputTabs.keySet();
+
+            for (String key: keys) {
+                tabs.addTab(outputTabs.get(key));
+            }
+        }
     }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/OutputTab.java	Mon Mar 28 07:09:34 2011 +0000
@@ -0,0 +1,45 @@
+package de.intevation.flys.client.client.ui;
+
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.tab.Tab;
+
+import de.intevation.flys.client.shared.model.Collection;
+import de.intevation.flys.client.shared.model.OutputMode;
+
+
+public class OutputTab extends Tab {
+
+    /** The OutputMode that should be displayed in this tab.*/
+    protected OutputMode mode;
+
+    /** The Collection that should be displayed in this tab.*/
+    protected Collection collection;
+
+
+    /**
+     * The default constructor that creates a new Tab for displaying a specific
+     * OutputMode of a Collection.
+     *
+     * @param title The title of the tab.
+     * @param collection The collection that need to be displayed.
+     * @param outputmode The OutputMode that need to be displayed.
+     */
+    public OutputTab(String title, Collection collecton, OutputMode mode) {
+        super(title);
+
+        this.collection = collection;
+        this.mode       = mode;
+
+        init();
+    }
+
+
+    /**
+     * Method that is called at the end of a constructor to initialize the view
+     * of this widget.
+     */
+    protected void init() {
+        setPane(new Label("Implement concrete subclasses to vary the output."));
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org