changeset 1561:3cf3cd8dd92d

Made manual points edit- and removable. flys-client/trunk@3807 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 27 Jan 2012 15:24:04 +0000
parents 1c47de6ccfb1
children af29d43cf4da
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java
diffstat 2 files changed, 53 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Fri Jan 27 15:22:59 2012 +0000
+++ b/flys-client/ChangeLog	Fri Jan 27 15:24:04 2012 +0000
@@ -1,3 +1,8 @@
+2012-01-27  Felix Wolfsteller <felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java:
+	  Made previously entered values edit- and removable, added TODOs.
+
 2012-01-27  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartPropertiesEditor.java,
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java	Fri Jan 27 15:22:59 2012 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/chart/ManualPointsEditor.java	Fri Jan 27 15:24:04 2012 +0000
@@ -18,6 +18,8 @@
 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.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
 import com.smartgwt.client.types.ListGridFieldType;
 
 import com.smartgwt.client.widgets.form.DynamicForm;
@@ -143,6 +145,8 @@
         Button accept = new Button(MSG.label_ok());
         Button cancel = new Button(MSG.label_cancel());
         cancel.addClickHandler(this);
+
+        // TODO refactor.
         accept.addClickHandler(new ClickHandler() {
             public void onClick(ClickEvent e) {
                 if(isDialogValid()) {
@@ -167,6 +171,7 @@
                             JSONArray data = new JSONArray();
 
                             // TODO better get double directly (via cell-formatter etc)
+                            // TODO finalize the X, Y etc.
                             String xString = record.getAttributeAsString("X");
                             String yString = record.getAttributeAsString("Y");
                             String nameString = record.getAttributeAsString("name");
@@ -200,14 +205,8 @@
                             }
                             public void onSuccess(Artifact fartifact) {
                                 GWT.log("Successfully set points ");
-                                // TODO refresh collection such that next time
-                                //      the new points are shown.
-                                //requestRedraw();
-                                //updateCollection();
-                                //updateGrid();
-                                //enable();
                                 redrawRequestHandler.onRedrawRequest(
-                                    new RedrawRequestEvent(Type.DEFAULT));
+                                    new RedrawRequestEvent());
                                 destroy();
                             }
                         });
@@ -229,18 +228,43 @@
         listGrid = new ListGrid();
         listGrid.setWidth100();
         listGrid.setHeight(200);
+        listGrid.setCanSort(false);
+        listGrid.setCanEdit(true);
+        listGrid.setShowHeaderContextMenu(false);
+
         // TODO X and Y Header depend on the current chart and axis (e.g. W[nn+m])
+        // collection.getSettings(outputName).getSettings -> Propertie -> "axis" -> "label"
         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());
+        final ListGridField removeField  =
+            new ListGridField("_removeRecord", MSG.removepoint()){{
+                setType(ListGridFieldType.ICON);
+                setIcon(GWT.getHostPageBaseURL() + MSG.removeFeature());
+                setCanEdit(false);
+                setCanFilter(false);
+                setCanSort(false);
+                setCanGroupBy(false);
+                setCanFreeze(false);
+                setWidth(25);
+        }};
+
         listGrid.setFields(new ListGridField[] {xField, yField,
             nameField, removeField});
 
+        listGrid.addRecordClickHandler(new RecordClickHandler() {
+                public void onRecordClick(final RecordClickEvent event) {
+                    // Just handle remove-clicks
+                    if(!event.getField().getName().equals(removeField.getName())) {
+                        return;
+                    }    
+                    event.getViewer().removeData(event.getRecord());
+                }
+            });
+
         // Find the artifacts uuid.
         findManualPointsUUID();
         CollectionItem item = collection.getItem(uuid);
@@ -333,10 +357,7 @@
         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;
+        protected static final String ATTRIBUTE_ACTIVE = "active";
 
         private PointRecord() {;}
 
@@ -346,31 +367,36 @@
             setY(y);
         }
 
+        public void setActive(boolean b) {
+            setAttribute(ATTRIBUTE_ACTIVE, b);
+        }
+
+        public boolean isActive() {
+            return getAttributeAsBoolean(ATTRIBUTE_ACTIVE);
+        }
+
         public void setName(String name) {
-            this.name = name;
-            setAttribute(ATTRIBUTE_NAME, getName());
+            setAttribute(ATTRIBUTE_NAME, name);
         }
 
         public String getName() {
-            return this.name;
+            return getAttributeAsString(ATTRIBUTE_NAME);
         }
 
         public void setX(double x) {
-            this.x = x;
-            setAttribute(ATTRIBUTE_X, getX());
+            setAttribute(ATTRIBUTE_X, x);
         }
 
         public void setY(double y) {
-            this.y = y;
-            setAttribute(ATTRIBUTE_Y, getY());
+            setAttribute(ATTRIBUTE_Y, y);
         }
 
         public double getX() {
-            return this.x;
+            return getAttributeAsDouble(ATTRIBUTE_X);
         }
 
         public double getY() {
-            return this.y;
+            return getAttributeAsDouble(ATTRIBUTE_Y);
         }
     }
 

http://dive4elements.wald.intevation.org