changeset 1283:e8bb11976c70

Neaten certain GUI aspects with W-Diff waterlevel-pair selection. flys-client/trunk@2867 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 30 Sep 2011 07:44:35 +0000
parents 3904519ec161
children cdb1505a32f1
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java
diffstat 3 files changed, 122 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Sep 29 14:52:29 2011 +0000
+++ b/flys-client/ChangeLog	Fri Sep 30 07:44:35 2011 +0000
@@ -1,3 +1,15 @@
+2011-09-30	Felix Wolfsteller	<felix.wolfsteller@intevation.de> 
+
+	Neaten displayed gridcontent when selecting waterlevels for wdiff,
+	do not allow multi-selection.
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java:
+	  Display facets name in table when selecting pairs.
+
+	* src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java:
+	  (getSelectionTitle): New function to access visible titles of
+	   selection.
+
 2011-09-29  Ingo Weinzierl <ingo@intevation.de>
 
 	flys/issue179 (Zoom Out funktioniert nichtzuverlässig)
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java	Thu Sep 29 14:52:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacagePairWidget.java	Fri Sep 30 07:44:35 2011 +0000
@@ -1,5 +1,9 @@
 package de.intevation.flys.client.client.ui;
 
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import com.google.gwt.core.client.GWT;
 
 import com.smartgwt.client.widgets.Button;
@@ -20,6 +24,8 @@
 import de.intevation.flys.client.client.FLYSConstants;
 
 import de.intevation.flys.client.shared.model.Recommendation;
+import de.intevation.flys.client.shared.model.Recommendation.Facet;
+import de.intevation.flys.client.shared.model.Recommendation.Filter;
 
 
 /**
@@ -29,73 +35,88 @@
 public class DatacagePairWidget
 extends      VLayout
 {
-    protected FLYSConstants messages =
-        GWT.create(FLYSConstants.class);
-
-    /** The "remote" ListGrid to insert data to when add-button is clicked. */
-    protected ListGrid grid; 
+protected FLYSConstants messages =
+    GWT.create(FLYSConstants.class);
 
-    /** First attribute-name for StringPairRecord. */
-    protected static final String ATTRIBUTE_FIRST  = "first";
+/** The "remote" ListGrid to insert data to when add-button is clicked. */
+protected ListGrid grid; 
 
-    /** Second attribute-name for StringPairRecord. */
-    protected static final String ATTRIBUTE_SECOND = "second";
+/** First attribute-name for StringPairRecord. */
+protected static final String ATTRIBUTE_FIRST  = "first";
 
-    /** First (upper) DataCage Grid. */
-    protected DatacageWidget firstDatacageWidget;
+/** Second attribute-name for StringPairRecord. */
+protected static final String ATTRIBUTE_SECOND = "second";
 
-    /** Second (lower) DataCage Grid. */
-    protected DatacageWidget secondDatacageWidget;
+/** First (upper) DataCage Grid. */
+protected DatacageWidget firstDatacageWidget;
+
+/** Second (lower) DataCage Grid. */
+protected DatacageWidget secondDatacageWidget;
 
 
-    /**
-     * Two strings to be displayed in a GridList.
-     */
-    protected class RecommendationPairRecord extends ListGridRecord {
-        Recommendation first;
-        Recommendation second;
-
-        public RecommendationPairRecord() {
-        }
+/**
+ * Two strings to be displayed in a GridList, derived from two
+ * Recommendations.
+ */
+protected class RecommendationPairRecord extends ListGridRecord {
+    Recommendation first;
+    Recommendation second;
+    String firstName;
+    String secondName;
 
-        public RecommendationPairRecord(Recommendation first, Recommendation second) {
-            setFirst(first);
-            setSecond(second);
-        }
-
+    public RecommendationPairRecord() {
+    }
 
-        public void setFirst(Recommendation first) {
-            this.first = first;
-            setAttribute(ATTRIBUTE_FIRST, first.getFactory() + first.getIDs());
-        }
-
-
-        public void setSecond(Recommendation second) {
-            this.second = second;
-            setAttribute(ATTRIBUTE_SECOND, second.getFactory() + second.getIDs());
-        }
-
-        public Recommendation getFirst() {return first;}
-        public Recommendation getSecond() {return second;}
+    public RecommendationPairRecord(String firstName,
+        Recommendation first,
+        String secondName,
+        Recommendation second)
+    {
+        setFirst(first, firstName);
+        setSecond(second, secondName);
     }
 
 
-    /**
-     *
-     * @param artifact Artifact to query datacage with.
-     * @param user     User to query datacage with.
-     * @param outs     outs to query datacage with.
-     * @param grid     Grid into which to insert selection of pairs.
-     */
-    public DatacagePairWidget(Artifact artifact, User user, String outs,
-            ListGrid grid) {
+    public void setFirst(Recommendation first, String name) {
+        this.first = first;
+        this.firstName = name;
+        setAttribute(ATTRIBUTE_FIRST, name);
+    }
+
+
+    public void setSecond(Recommendation second, String name) {
+        this.second = second;
+        this.secondName = name;
+        setAttribute(ATTRIBUTE_SECOND, name);
+    }
+
+    public Recommendation getFirst() {return first;}
+    public Recommendation getSecond() {return second;}
+    public String getFirstName() {return firstName;}
+    public String getSecondName() {return secondName;}
+}
+
+
+/**
+ *
+ * @param artifact Artifact to query datacage with.
+ * @param user     User to query datacage with.
+ * @param outs     outs to query datacage with.
+ * @param grid     Grid into which to insert selection of pairs.
+ */
+public DatacagePairWidget(Artifact artifact,
+         User user,
+         String outs,
+         ListGrid grid) {
         this.grid = grid;
 
-        HLayout hLayout = new HLayout();
+        HLayout hLayout      = new HLayout();
+        firstDatacageWidget  = new DatacageWidget(artifact, user, outs, false);
+        secondDatacageWidget = new DatacageWidget(artifact, user, outs, false);
+        firstDatacageWidget.setIsMutliSelectable(false);
+        secondDatacageWidget.setIsMutliSelectable(false);
 
-        firstDatacageWidget = new DatacageWidget(artifact, user, outs, false);
         hLayout.addMember(firstDatacageWidget);
-        secondDatacageWidget = new DatacageWidget(artifact, user, outs, false);
         hLayout.addMember(secondDatacageWidget);
 
         // TODO: i18n + icon
@@ -119,6 +140,8 @@
     public void plusClicked() {
         ToLoad toLoad1 = firstDatacageWidget.getSelection();
         ToLoad toLoad2 = secondDatacageWidget.getSelection();
+        String [] sel1 = firstDatacageWidget.getSelectionTitles();
+        String [] sel2 = secondDatacageWidget.getSelectionTitles();
 
         // TODO further sanitize (toRecommendations.length)
         if (toLoad1 == null || toLoad2 == null) {
@@ -126,7 +149,9 @@
         }
 
         grid.addData(new RecommendationPairRecord(
+            sel1[0],
             toLoad1.toRecommendations().get(0),
+            sel2[0],
             toLoad2.toRecommendations().get(0)));
     }
 }
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java	Thu Sep 29 14:52:29 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DatacageWidget.java	Fri Sep 30 07:44:35 2011 +0000
@@ -47,6 +47,10 @@
 import java.util.Stack;
 
 // TODO: refactor, extract ~DataCageGrid
+/**
+ * Display tree of, for example, previous calculations and allows
+ * selection in order to access/clone these.
+ */
 public class DatacageWidget
 extends      VLayout
 {
@@ -163,6 +167,10 @@
     }
 
 
+    /**
+     * Sets whether more than one item can be selected.
+     * @param multi if true, allow mutliple selections.
+     */
     public void setIsMutliSelectable(boolean multi) {
         if (multi) {
             treeGrid.setSelectionType(SelectionStyle.MULTIPLE);
@@ -229,6 +237,31 @@
 
 
     /**
+     * Returns the titles of selected items (if any).
+     */
+    public String[] getSelectionTitles() {
+        if (treeGrid == null) {
+            return new String[] {};
+        }
+
+        ListGridRecord [] selection = treeGrid.getSelection();
+
+        if (selection == null) {
+            return new String[] {};
+        }
+
+        List<String> titleList = new ArrayList<String>();
+        for (ListGridRecord record: selection) {
+            if (record instanceof TreeNode) {
+                titleList.add(((TreeNode)record).getAttribute("name"));
+            }
+        }
+
+        return titleList.toArray(new String[titleList.size()]);
+    }
+
+
+    /**
      * Callback for add-button.
      * Fires to load for every selected element and handler.
      */

http://dive4elements.wald.intevation.org