changeset 1445:df7ebcbff984

Bugfixing and feature-adding for cross-sections/areas. flys-client/trunk@3457 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Mon, 19 Dec 2011 07:37:15 +0000
parents bdac8a72f7e6
children 4c5006fecd8d
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java
diffstat 2 files changed, 63 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Dec 16 13:36:23 2011 +0000
+++ b/flys-client/ChangeLog	Mon Dec 19 07:37:15 2011 +0000
@@ -1,3 +1,12 @@
+2011-12-19	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java:
+	  Feed name-data-item to area artifact, refresh collection.
+	  Set initial master for cross sections to be first area artifact in
+	  collection.
+	  Set step-size for spinner to 0.5.
+	  Added click handlers for "over" and "under" menu items.
+
 2011-12-16	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	Bring further UI regarding area creation (in cross-sections).
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java	Fri Dec 16 13:36:23 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java	Mon Dec 19 07:37:15 2011 +0000
@@ -117,14 +117,30 @@
 
     /**
      * Tell an area artifact where to get the upper and lower curve from.
+     * @param over if null, something
      */
     public void feedTellArea(final String artifact, Theme under, Theme over) {
-        Data[] feedData = new Data[] {
-            DefaultData.createSimpleStringData("area.curve_under",
-                under.getArtifact() + under.getIndex()),
-            DefaultData.createSimpleStringData("area.curve_over",
-                over.getArtifact() + over.getIndex()),
-        };
+
+        Data[] feedData;
+
+        if (over != null) {
+            feedData = new Data[] {
+                DefaultData.createSimpleStringData("area.curve_under",
+                    under.getArtifact() + under.getIndex()),
+                DefaultData.createSimpleStringData("area.curve_under",
+                      under.getArtifact() + under.getIndex()),
+                DefaultData.createSimpleStringData("area.name",
+                    over.getDescription() + " / " + under.getDescription())
+            };
+        }
+        else {
+            feedData = new Data[] {
+                DefaultData.createSimpleStringData("area.curve_under",
+                    under.getArtifact() + under.getIndex()),
+                DefaultData.createSimpleStringData("area.name",
+                    under.getDescription() + " / " + MSG.getString("x_axis"))
+            };
+        }
 
         feedService.feed(
             Config.getInstance().getLocale(),
@@ -140,10 +156,9 @@
                 public void onSuccess(Artifact artifact) {
                     GWT.log("Successfully set area params to " + artifact);
                     requestRedraw();
+                    updateCollection();
+                    updateGrid();
                     enable();
-                    // TODO: Update the grid/collection, to include this new
-                    // facet.
-                    //updateCollection?
                 }
             });
     }
@@ -154,16 +169,27 @@
     public String findCurrentMaster() {
         ThemeList themeList = getThemeList();
         int count = getThemeList().getThemeCount();
+        String firstCSUuid = null;
         for (int i = 1; i <= count; i++) {
             Theme theme = themeList.getThemeAt(i);
             String value = theme.getCollectionItem().getData().get("cross_section.master?");
 
-            if (value != null && !value.equals("0")) {
-                setCurrentMaster(theme.getArtifact());
-                GWT.log("found a master! " + currentMasterUUID + "/" + theme.getDescription());
-                return theme.getDescription();
+            if (value != null) {
+                if (firstCSUuid == null) {
+                    firstCSUuid = theme.getArtifact();
+                }
+                if (!value.equals("0")) {
+                    setCurrentMaster(theme.getArtifact());
+                    GWT.log("found a master: " + currentMasterUUID + "/" + theme.getDescription());
+                    return theme.getDescription();
+                }
             }
         }
+        // There is none selected. Take the first one.
+        if (firstCSUuid != null) {
+            setCurrentMaster(firstCSUuid);
+            feedTellMaster(firstCSUuid);
+        }
         return null;
     }
 
@@ -424,7 +450,7 @@
         // min/max-extension
         spinnerItem.setMin(0);
         spinnerItem.setMax(1000);
-        spinnerItem.setStep(5f);
+        spinnerItem.setStep(0.5f);
         spinnerItem.setChangeOnKeypress(true);
         return spinnerItem;
     }
@@ -525,6 +551,8 @@
 
     /**
      * Create and parameterize a new area artifact.
+     * @param under
+     * @param over if null, something.
      */
     public void createAreaArtifact(final Theme under, final Theme over) {
         Config config = Config.getInstance();
@@ -597,7 +625,19 @@
         }
 
         MenuItem underMenuItem = new MenuItem("Under ...");
+        underMenuItem.addClickHandler(new ClickHandler() {
+            public void onClick(MenuItemClickEvent evt) {
+                disable();
+                createAreaArtifact(facetTheme, null);
+            }
+        });
         MenuItem overMenuItem = new MenuItem("Over ...");
+        overMenuItem.addClickHandler(new ClickHandler() {
+            public void onClick(MenuItemClickEvent evt) {
+                disable();
+                createAreaArtifact(facetTheme, null);
+            }
+        });
         areaMenu.addItem(createSeparator());
         areaMenu.addItem(underMenuItem);
         areaMenu.addItem(overMenuItem);

http://dive4elements.wald.intevation.org