changeset 5675:10aac4ec2d76

Localize the _data strings, limit the input in the panel and Search the current river in a very roundabout manner,.. (River search code was taken from the datacage window)
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 12 Apr 2013 12:56:25 +0200
parents c6a6ef2d4e7e
children f8409fbe3b88
files flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java
diffstat 1 files changed, 59 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java	Fri Apr 12 12:53:06 2013 +0200
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPrintPanel.java	Fri Apr 12 12:56:25 2013 +0200
@@ -25,21 +25,29 @@
 import de.intevation.flys.client.shared.model.Property;
 import de.intevation.flys.client.shared.model.PropertySetting;
 import de.intevation.flys.client.shared.model.Settings;
+import de.intevation.flys.client.shared.model.Artifact;
+import de.intevation.flys.client.shared.model.ArtifactDescription;
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+import de.intevation.flys.client.shared.model.DataList;
+
 
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.MissingResourceException;
 
 public class MapPrintPanel extends Canvas {
 
-    private static final String MAPFISH_MAPTITLE = "mapfish-mapTitle";
-    private static final String MAPFISH_RANGE = "mapfish-data-range";
-    private static final String MAPFISH_SUBTITLE = "mapfish-data-subtitle";
-    private static final String MAPFISH_STRETCH = "mapfish-data-strech";
-    private static final String MAPFISH_CREATED = "mapfish-data-created";
-    private static final String MAPFISH_SOURCE = "mapfish-data-source";
-    private static final String MAPFISH_CREATOR = "mapfish-data-creator";
-    private static final String MAPFISH_DATEPLACE = "mapfish-data-dateplace";
+    private static final String MAPFISH_MAPTITLE = "mapfish_mapTitle";
+    private static final String MAPFISH_RANGE = "mapfish_data_range";
+    private static final String MAPFISH_SUBTITLE = "mapfish_data_subtitle";
+    private static final String MAPFISH_STRETCH = "mapfish_data_strech";
+    private static final String MAPFISH_CREATED = "mapfish_data_created";
+    private static final String MAPFISH_SOURCE = "mapfish_data_source";
+    private static final String MAPFISH_CREATOR = "mapfish_data_creator";
+    private static final String MAPFISH_DATEPLACE = "mapfish_data_dateplace";
+    private static final String MAPFISH_RIVER = "mapfish_data_river";
 
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
@@ -119,6 +127,14 @@
         this.pageCreator.setTitle("Ersteller");
         this.pageDatePlace.setTitle("Ort, Datum");
 
+        pageTitle.setLength(21);
+        pageSubtitle.setLength(21);
+        pageRange.setLength(21);
+        pageStrech.setLength(21);
+        pageCreated.setLength(21);
+        pageSource.setLength(21);
+        pageCreator.setLength(21);
+        pageDatePlace.setLength(21);
         ButtonItem printButton = createPrintButtonItem();
 
         printButton.setAlign(Alignment.RIGHT);
@@ -229,11 +245,45 @@
             for (Property prop : properties) {
                 PropertySetting props = (PropertySetting)prop;
                 url.append("&");
-                url.append(props.getName());
+                String localized;
+                try {
+                    localized = MSG.getString(props.getName());
+                }
+                catch (MissingResourceException mre) {
+                    localized = props.getName();
+                }
+                url.append(localized);
                 url.append("=");
                 url.append(props.getValue());
             }
         }
+        // O.o
+        String river = findRiver(((MapOutputTab)mapToolbar.getOutputTab()
+                    ).getCollectionView().getArtifact());
+        url.append("&" + MSG.getString(MAPFISH_RIVER) + "=" + river);
+    }
+
+    // Copy of DatacageWindow's findRiver
+    protected String findRiver(Artifact artifact) {
+        ArtifactDescription adescr = artifact.getArtifactDescription();
+        DataList [] data = adescr.getOldData();
+
+        if (data != null && data.length > 0) {
+            for (int i = 0; i < data.length; i++) {
+                DataList dl = data[i];
+                if (dl.getState().equals("state.winfo.river")) {
+                    for (int j = dl.size()-1; j >= 0; --j) {
+                        Data d = dl.get(j);
+                        DataItem [] di = d.getItems();
+                        if (di != null && di.length == 1) {
+                           return d.getItems()[0].getStringValue();
+                        }
+                    }
+                }
+            }
+        }
+
+        return "";
     }
 
     protected void updateCollection() {

http://dive4elements.wald.intevation.org