changeset 1615:07c38d054f91

Translate data item in locationpanel label. flys-client/trunk@3984 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Thu, 09 Feb 2012 08:51:00 +0000
parents 592751b635e3
children ff8312688cd5
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java
diffstat 3 files changed, 29 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu Feb 09 08:47:39 2012 +0000
+++ b/flys-client/ChangeLog	Thu Feb 09 08:51:00 2012 +0000
@@ -1,3 +1,11 @@
+2012-02-09	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/LocationPanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java:
+	  Minor refactoring, cosmetics and documentation.
+	  Also use translated data item name as label instead of fixed
+	  "location" string.
+
 2012-02-09	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPanel.java	Thu Feb 09 08:47:39 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPanel.java	Thu Feb 09 08:51:00 2012 +0000
@@ -71,7 +71,8 @@
         VLayout layout = new VLayout();
         layout.setMembersMargin(10);
 
-        Label label   = new Label(MSG.location ());
+        // Subclass uses translated data items name as label.
+        Label label   = new Label(MSG.location());
         Canvas widget = createWidget(data);
         Canvas submit = getNextButton();
 
@@ -88,11 +89,13 @@
     }
 
 
+    /** Store label of first data item in list. */
     public void findDataItemName(DataList list) {
         this.dataItemName = list.getAll().get(0).getLabel();
     }
 
 
+    /** Get label of first data item that this uiprovider has seen. */
     public String getDataItemName() {
         return this.dataItemName;
     }
@@ -117,6 +120,7 @@
 
         Canvas back = getBackButton(dataList.getState());
 
+        // TODO evaluate: isn't this what findDataItemName is doing?
         Label selected = new Label(loc[0].getLabel());
         selected.setWidth("130px");
 
@@ -209,7 +213,7 @@
 
     protected Canvas createWidget(DataList data) {
         VLayout layout = new VLayout();
-        inputLayout      = new HLayout();
+        inputLayout    = new HLayout();
 
         // The initial view will display the location input mode.
         locationPanel = new DoubleArrayPanel(
@@ -227,14 +231,12 @@
 
         inputLayout.setMembersMargin(30);
 
+        /*
         //picker.prepareFilter();
-
-        /*
         helperContainer.addMember(picker.getLocationTable());
         helperContainer.addMember(picker.getFilterLayout());
         helperContainer.addMember(picker.getResultCountForm());
         */
-        //createInputPanel();
         return layout;
     }
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java	Thu Feb 09 08:47:39 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java	Thu Feb 09 08:51:00 2012 +0000
@@ -53,6 +53,7 @@
      * then entered in the texfield. */
     protected LocationPicker picker;
 
+
     /**
      * Creates a new LocationDistancePanel instance.
      */
@@ -77,7 +78,16 @@
         VLayout layout = new VLayout();
         layout.setMembersMargin(10);
 
-        Label label   = new Label(MSG.location ());
+        // Take translated data item name as label, if translation available.
+        String labelString;
+        try {
+            labelString = MSG.getString(getDataItemName());
+        }
+        catch(java.util.MissingResourceException mre) {
+            GWT.log("Cannot find translation for data item name : " + getDataItemName());
+            labelString = MSG.location(); 
+        }
+        Label label   = new Label(labelString);
         Canvas widget = createWidget(data);
         Canvas submit = getNextButton();
 
@@ -224,9 +234,9 @@
 
 
     /**
-     * This method returns the selected data.
+     * This method returns the selected data (to feed).
      *
-     * @return the selected/inserted data.
+     * @return the selected/inserted data in feedable form.
      */
     public Data[] getData() {
         saveLocationValues(locationPanel);
@@ -281,6 +291,7 @@
             url, river, "locations"));
     }
 
+
     // TODO allow multiple selections here or in LocationPanel
     /**
      * Callback when an item from the input helper was clicked.

http://dive4elements.wald.intevation.org