changeset 1475:fb2fefe0325f

Improvements in CrossSectionChartThemePanel. flys-client/trunk@3520 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 22 Dec 2011 09:02:28 +0000
parents 0ba23e6fef0c
children edf18a9dfd8b
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java
diffstat 2 files changed, 55 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Dec 22 08:58:33 2011 +0000
+++ b/flys-client/ChangeLog	Thu Dec 22 09:02:28 2011 +0000
@@ -1,3 +1,11 @@
+2011-12-22	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java
+	  (artifactReference, dataOf): Extracted and use new helper.
+	  (CROSS_KM): Extracted and use static string.
+	  (findCurrentCSMaster): Set km of collectionviews master.
+	  Resolved some todos.
+
 2011-12-22	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/map/MapThemePanel.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java	Thu Dec 22 08:58:33 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/CrossSectionChartThemePanel.java	Thu Dec 22 09:02:28 2011 +0000
@@ -70,14 +70,31 @@
     /** The layout (used for visual active/inactive feedback). */
     protected VLayout layout;
 
+    /** Data item name for CrossSections selected km. */
+    protected static String CROSS_KM = "cross_section.km";
+
+
     /**
      * Trivial constructor.
      */
     public CrossSectionChartThemePanel(
         Collection collection,
-        OutputMode mode)
+        OutputMode mode,
+        CollectionView view)
     {
-        super(collection, mode);
+        super(collection, mode, view);
+    }
+
+
+    /** Create DefaultArtifact. */
+    public static DefaultArtifact artifactReference(String uuid) {
+        return new DefaultArtifact(uuid, "TODO:hash");
+    }
+
+
+    /** Access data of collection item of theme. */
+    public static String dataOf(Theme theme, String dataItemName) {
+        return theme.getCollectionItem().getData().get(dataItemName);
     }
 
 
@@ -91,7 +108,7 @@
 
         feedService.feed(
             Config.getInstance().getLocale(),
-            new DefaultArtifact(artifact, "TODO:hash"),
+            artifactReference(artifact),
             feedData,
             new AsyncCallback<Artifact>() {
                 public void onFailure(Throwable caught) {
@@ -118,18 +135,32 @@
         ThemeList themeList = getThemeList();
         int count = getThemeList().getThemeCount();
         String firstCSUuid = null;
+        Theme  firstCS     = null;
         for (int i = 1; i <= count; i++) {
             Theme theme = themeList.getThemeAt(i);
-            String value = theme.getCollectionItem().getData().get("cross_section.master?");
+            String value = dataOf(theme, "cross_section.master?");
 
             if (value != null) {
                 if (firstCSUuid == null) {
                     firstCSUuid = theme.getArtifact();
+                    firstCS     = theme;
                 }
                 if (!value.equals("0")) {
                     setCurrentCSMaster(theme.getArtifact());
                     GWT.log("found a master: " + currentCSMasterUUID
                         + "/" + theme.getDescription());
+                    Theme collectionMaster = getThemeList().getTheme(
+                        view.getArtifact().getUuid());
+                    if (!dataOf(theme, CROSS_KM)
+                            .equals(dataOf(collectionMaster, CROSS_KM))
+                    ) {
+                        // Tell Collection Master which kilometer the Cross-
+                        // Section Master is at, to have consistent subtitle
+                        // in diagram.
+                        //sendFeed(view.getArtifact().getUuid(),
+                        //     Double.valueOf(dataOf(theme, CROSS_KM)));
+                    }
+
                     return theme.getDescription();
                 }
             }
@@ -138,6 +169,11 @@
         if (firstCSUuid != null) {
             setCurrentCSMaster(firstCSUuid);
             feedTellMaster(firstCSUuid);
+            // Tell Collection Master which kilometer the Cross-
+            // Section Master is at, to have consistent subtitle
+            // in diagram.
+            sendFeed(view.getArtifact().getUuid(),
+                Double.valueOf(dataOf(firstCS, CROSS_KM)));
         }
         return null;
     }
@@ -184,7 +220,7 @@
                             "cross_section.master?", "0");
                     feedService.feed(
                         locale,
-                        new DefaultArtifact(getCurrentCSMaster(), "TODO:hash"),
+                        artifactReference(getCurrentCSMaster()),
                         feedData,
                         new AsyncCallback<Artifact>() {
                             public void onFailure(Throwable caught) {
@@ -252,21 +288,20 @@
     }
 
 
-    /** Feed a single artifact with the km of the crosssection to display. */
+    /** Feed a single artifact with the km of the crosssection to display.
+     * If its the selected master, also feed the collectionmaster. */
     public void sendFeed(final String artUUID, final double kmD) {
         Config config       = Config.getInstance();
         final String locale = config.getLocale();
 
         Data[] feedData =
-            DefaultData.createSimpleStringDataArray("cross_section.km",
+            DefaultData.createSimpleStringDataArray(CROSS_KM,
                 Double.valueOf(kmD).toString());
 
         disable();
         feedService.feed(
             locale,
-            new DefaultArtifact(
-                artUUID,
-                "TODO:hash"),
+            artifactReference(artUUID),
             feedData,
             new AsyncCallback<Artifact>() {
                 @Override
@@ -378,12 +413,10 @@
         spinnerItem.setWidth(45);
         spinnerItem.setDefaultValue(facetRecord.getTheme()
             .getCollectionItem()
-            .getData().get("cross_section.km"));
+            .getData().get(CROSS_KM));
 
-        // TODO actually use crosssectionkmservice with
-        // min/max-extension
         spinnerItem.setMin(0);
-        spinnerItem.setMax(1000);
+        spinnerItem.setMax(2000);
         spinnerItem.setStep(0.5f);
         spinnerItem.setChangeOnKeypress(true);
         return spinnerItem;
@@ -416,7 +449,6 @@
                         HLayout recordCanvas = new HLayout(3);
                         recordCanvas.setHeight(22);
                         recordCanvas.setAlign(Alignment.CENTER);
-                        // TODO Refactor in createSpinner(data, artifact)
                         SpinnerItem spinnerItem = createSpinnerItem(facetRecord);
                         spinnerItem.addChangedHandler(
                             createSpinnerHandler(feedService, facetRecord));

http://dive4elements.wald.intevation.org