changeset 250:27f12703937e

Enable or disable table rows depending on the WQ selection. flys-client/trunk@1841 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 05 May 2011 15:42:38 +0000
parents 6c7133eb8c4c
children f22f457d4e9a
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java
diffstat 2 files changed, 60 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Thu May 05 13:32:36 2011 +0000
+++ b/flys-client/ChangeLog	Thu May 05 15:42:38 2011 +0000
@@ -1,3 +1,8 @@
+2011-05-05  Raimund Renkert <rrenkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java:
+	  Enable or disable table rows depending on the WQ selection.
+
 2011-05-05  Raimund Renkert <rrenkert@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Thu May 05 13:32:36 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQInputPanel.java	Thu May 05 15:42:38 2011 +0000
@@ -21,6 +21,7 @@
 import com.smartgwt.client.widgets.layout.VLayout;
 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.CellClickHandler;
 import com.smartgwt.client.widgets.grid.events.CellClickEvent;
 
@@ -257,7 +258,7 @@
 
         CellClickHandler cch = new CellClickHandler() {
             public void onCellClick(CellClickEvent e) {
-                if (e.getColNum() == 0 && !e.getRecord().getEnabled ()) {
+                if (e.getColNum() == 0 && e.getRecord().getEnabled ()) {
                     Record r = e.getRecord ();
                     double val = r.getAttributeAsDouble("value");
                     if(isWMode() && !isRangeMode()) {
@@ -304,7 +305,7 @@
 
         CellClickHandler cchRange = new CellClickHandler() {
             public void onCellClick(CellClickEvent e) {
-                if (e.getColNum() == 0 && !e.getRecord().getEnabled ()) {
+                if (e.getColNum() == 0 && e.getRecord().getEnabled ()) {
                     Record r = e.getRecord ();
                     double val = r.getAttributeAsDouble("value");
                     if(isWMode() && isRangeMode()) {
@@ -320,7 +321,7 @@
                             qRangePanel.getStep());
                     }
                 }
-                if (e.getColNum() == 1 && !e.getRecord().getEnabled()) {
+                if (e.getColNum() == 1 && e.getRecord().getEnabled()) {
                     Record r = e.getRecord ();
                     double val = r.getAttributeAsDouble("value");
                     if (isWMode() && isRangeMode()) {
@@ -789,10 +790,13 @@
             inputMode = form.getValueAsString(FIELD_MODE);
         }
 
-        container.removeMembers(container.getMembers());
+        updatePanels(wqMode, inputMode);
+    }
 
-        Canvas newPanel = null;
 
+    protected void updatePanels(String wqMode, String inputMode) {
+        container.removeMembers(container.getMembers());
+        GWT.log("updating Panel and Table");
         if (wqMode.equals(FIELD_WQ_W)) {
             if (inputMode.equals(FIELD_MODE_SINGLE)) {
                 // Single W mode
@@ -803,6 +807,17 @@
 
                 container.addMember(wArrayPanel);
                 container.addMember(wqTable);
+                int size = wqTable.getRecords().length;
+                for(int i = 0; i < size; i++) {
+                    ListGridRecord r = wqTable.getRecord(i);
+                    String type = r.getAttributeAsString("type");
+                    if (type.equals("W")) {
+                        wqTable.getRecord(i).setEnabled(true);
+                    }
+                    else if(type.equals("D") || type.equals("Q")) {
+                        wqTable.getRecord(i).setEnabled(false);
+                    }
+                }
             }
             else {
                 // Range W mode
@@ -817,6 +832,17 @@
                     this);
                 container.addMember(wRangePanel);
                 container.addMember(wqRangeTable);
+                int size = wqRangeTable.getRecords().length;
+                for(int i = 0; i < size; i++) {
+                    ListGridRecord r = wqRangeTable.getRecord(i);
+                    String type = r.getAttributeAsString("type");
+                    if (type.equals("W")) {
+                        wqRangeTable.getRecord(i).setEnabled(true);
+                    }
+                    else if(type.equals("D") || type.equals("Q")) {
+                        wqRangeTable.getRecord(i).setEnabled(false);
+                    }
+                }
             }
         }
         else {
@@ -828,6 +854,18 @@
                     MESSAGE.unitQSingle(), values, this);
                 container.addMember(qArrayPanel);
                 container.addMember(wqTable);
+                int size = wqTable.getRecords().length;
+                for(int i = 0; i < size; i++) {
+                    ListGridRecord r = wqTable.getRecord(i);
+                    String type = r.getAttributeAsString("type");
+                    if (type.equals("W")) {
+                        wqTable.getRecord(i).setEnabled(false);
+                    }
+                    else if(type.equals("D") || type.equals("Q")) {
+                        wqTable.getRecord(i).setEnabled(true);
+                    }
+            }
+
             }
             else {
                 // Range Q mode
@@ -842,12 +880,21 @@
                     this);
                 container.addMember(qRangePanel);
                 container.addMember(wqRangeTable);
+                int size = wqRangeTable.getRecords().length;
+                for(int i = 0; i < size; i++) {
+                    ListGridRecord r = wqRangeTable.getRecord(i);
+                    String type = r.getAttributeAsString("type");
+                    if (type.equals("W")) {
+                        wqRangeTable.getRecord(i).setEnabled(false);
+                    }
+                    else if(type.equals("D") || type.equals("Q")) {
+                        wqRangeTable.getRecord(i).setEnabled(true);
+                    }
+                }
             }
         }
-
     }
 
-
     /**
      * This method is called if the value of one of the input fields might have
      * changed. The entered values are validated and stored.
@@ -1095,6 +1142,7 @@
                     }
                     tableData = wqi;
                     addWQInfo(wqi);
+                    updatePanels(FIELD_WQ_W, FIELD_MODE_SINGLE);
                 }
             }
         );

http://dive4elements.wald.intevation.org