changeset 1553:9ad19e31d149

Improved points UI to also respect language and name of point. flys-client/trunk@3791 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 27 Jan 2012 12:03:04 +0000
parents 69b38f890bb6
children ae25566ce6f6
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java
diffstat 2 files changed, 52 insertions(+), 49 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Jan 27 12:01:14 2012 +0000
+++ b/flys-client/ChangeLog	Fri Jan 27 12:03:04 2012 +0000
@@ -1,3 +1,10 @@
+2012-01-27  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java:
+	  Transfer name of points.
+	  Resolved various i18n TODOs.
+	  Minor layout improvement.
+
 2012-01-27  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/FLYSConstants.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java	Fri Jan 27 12:01:14 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java	Fri Jan 27 12:03:04 2012 +0000
@@ -3,6 +3,7 @@
 import com.google.gwt.json.client.JSONArray;
 import com.google.gwt.json.client.JSONNumber;
 import com.google.gwt.json.client.JSONParser;
+import com.google.gwt.json.client.JSONString;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
@@ -17,6 +18,7 @@
 import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.types.ListGridFieldType;
 
 import com.smartgwt.client.widgets.form.DynamicForm;
 
@@ -120,8 +122,7 @@
      * Initialize the editor window and its components.
      */
     protected void init() {
-        setTitle("Add Points");
-        //TODO MSG.properties());
+        setTitle(MSG.addpoints());
         setCanDragReposition(true);
         setCanDragResize(true);
 
@@ -150,7 +151,6 @@
                     int idx = 0;
                     JSONArray list = new JSONArray();
 
-                    // TODO also need name attribute
                     for(ListGridRecord record : listGrid.getRecords()) {
                         if (record instanceof PointRecord) {
                             JSONArray data = new JSONArray();
@@ -158,6 +158,7 @@
                             PointRecord point = (PointRecord) record;
                             data.set(0, new JSONNumber(point.getX()));
                             data.set(1, new JSONNumber(point.getY()));
+                            data.set(2, new JSONString(point.getName()));
 
                             list.set(idx, data);
                             idx++;
@@ -168,17 +169,20 @@
                             // TODO better get double directly (via cell-formatter etc)
                             String xString = record.getAttributeAsString("X");
                             String yString = record.getAttributeAsString("Y");
+                            String nameString = record.getAttributeAsString("name");
+                            if (nameString == null || nameString.equals("")) {
+                                nameString = xString + "/" + yString;
+                            }
 
                             data.set(0, new JSONNumber(Double.valueOf(xString)));
                             data.set(1, new JSONNumber(Double.valueOf(yString)));
+                            data.set(2, new JSONString(nameString));
 
                             list.set(idx, data);
                             idx++;
                         }
                     }
 
-                    // TODO lock UI until feed succeeded/failed.
-
                     // Feed list.toString to respective artifact.
                     Data[] feedData = new Data[] {
                         DefaultData.createSimpleStringData(POINT_DATA,
@@ -225,11 +229,17 @@
         listGrid = new ListGrid();
         listGrid.setWidth100();
         listGrid.setHeight(200);
-        final ListGridField xField = new ListGridField("X", "X");
-        final ListGridField yField = new ListGridField("Y", "Y");
-        final ListGridField nameField = new ListGridField("name", "name");
-        final ListGridField removeField = new ListGridField("remove", "remove");
-        listGrid.setFields(new ListGridField[] {xField, yField, removeField});
+        // TODO X and Y Header depend on the current chart and axis (e.g. W[nn+m])
+        ListGridField xField = new ListGridField("X", "X");
+        xField.setType(ListGridFieldType.FLOAT);
+        ListGridField yField = new ListGridField("Y", "Y");
+        yField.setType(ListGridFieldType.FLOAT);
+        ListGridField nameField = new ListGridField("name",
+            MSG.pointname());
+        ListGridField removeField = new ListGridField("remove",
+            MSG.removepoint());
+        listGrid.setFields(new ListGridField[] {xField, yField,
+            nameField, removeField});
 
         // Find the artifacts uuid.
         findManualPointsUUID();
@@ -245,20 +255,23 @@
             }
         }
         else {
+            // TODO proper log
             System.out.println("No item found for " + uuid);
         }
 
-        layout.addMember(listGrid);
-
-        addItem(layout);
-        IButton button = new IButton("Edit New");
+        IButton button = new IButton(MSG.newpoint());
         button.setTop(250);
         button.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent event) {
                 listGrid.startEditingNew();
             }
         });
-        addItem(button);
+
+        layout.addMember(listGrid);
+        layout.addMember(button);
+
+        addItem(layout);
+
         addItem(buttons);
         setWidth(380);
         setHeight(470);
@@ -270,14 +283,14 @@
     public PointRecord pointRecordFromJSON(JSONArray jsonArray) {
         JSONNumber x = (JSONNumber) jsonArray.get(0);
         JSONNumber y = (JSONNumber) jsonArray.get(1);
-        return new PointRecord(x.doubleValue(), y.doubleValue());
+        JSONString s = (JSONString) jsonArray.get(2);
+        return new PointRecord(x.doubleValue(), y.doubleValue(), s.stringValue());
     }
 
 
     /** Add a ManualPointArtifact to Collection. */
     public void addArtifactCreateUI() {
-        // TODO MSG:/i18n
-        final Label standByLabel = new Label("Creating artifact, these are not the droids");
+        final Label standByLabel = new Label(MSG.standby());
         addItem(standByLabel);
 
         setWidth(380);
@@ -319,17 +332,29 @@
     public class PointRecord extends ListGridRecord {
         protected static final String ATTRIBUTE_X = "X";
         protected static final String ATTRIBUTE_Y = "Y";
+        protected static final String ATTRIBUTE_NAME = "name";
 
+        String name;
         double x;
         double y;
 
         private PointRecord() {;}
 
-        public PointRecord(double x, double y) {
+        public PointRecord(double x, double y, String name) {
+            setName(name);
             setX(x);
             setY(y);
         }
 
+        public void setName(String name) {
+            this.name = name;
+            setAttribute(ATTRIBUTE_NAME, getName());
+        }
+
+        public String getName() {
+            return this.name;
+        }
+
         public void setX(double x) {
             this.x = x;
             setAttribute(ATTRIBUTE_X, getX());
@@ -350,36 +375,7 @@
     }
 
 
-    // TODO cleanup. We need code similar to the following.
-
-    /*
-    protected void updateCollection() {
-        final Config config = Config.getInstance();
-        final String loc    = config.getLocale();
-
-        GWT.log("PropertiesEditor.updateCollection via RPC now");
-
-        Settings s = settings;
-        collection.addSettings(this.tab.getOutputName(), s);
-        updater.update(collection, loc, new AsyncCallback<Collection>() {
-            public void onFailure(Throwable caught) {
-                GWT.log("Could not update collection attributes.");
-                SC.warn(MSG.getString(caught.getMessage()));
-            }
-            public void onSuccess(Collection collection) {
-                updateChartTab();
-            }
-        });
-    }
-
-/*
-    protected void updateChartTab() {
-        this.tab.updateChartInfo();
-        this.tab.updateChartPanel();
-        this.destroy();
-    }
-*/
-
+    // TODO validate entered values (CellFormatter).
     protected boolean isDialogValid() {
         boolean valid = true;
         /*

http://dive4elements.wald.intevation.org