diff flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java @ 5195:d07abdb7ed7f

flys/issue1137: Allow value selection via inputhelpers in WQAdaptedPanel.
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 08 Mar 2013 09:17:50 +0100
parents 7b37876b2f51
children 2a5b15e071d8
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Thu Mar 07 19:38:36 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Fri Mar 08 09:17:50 2013 +0100
@@ -4,17 +4,23 @@
 import com.google.gwt.i18n.client.NumberFormat;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
+import com.smartgwt.client.data.Record;
 import com.smartgwt.client.types.TitleOrientation;
 import com.smartgwt.client.types.VerticalAlignment;
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.FormItem;
 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
 import com.smartgwt.client.widgets.form.fields.events.ChangeEvent;
 import com.smartgwt.client.widgets.form.fields.events.ChangeHandler;
+import com.smartgwt.client.widgets.form.fields.events.FocusEvent;
+import com.smartgwt.client.widgets.form.fields.events.FocusHandler;
+import com.smartgwt.client.widgets.grid.events.CellClickEvent;
+import com.smartgwt.client.widgets.grid.events.CellClickHandler;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 import com.smartgwt.client.widgets.tab.Tab;
@@ -52,7 +58,7 @@
  */
 public class WQAdaptedInputPanel
 extends      AbstractUIProvider
-implements   ChangeHandler, BlurHandler
+implements   ChangeHandler, BlurHandler, FocusHandler
 {
     private static final long serialVersionUID = -3218827566805476423L;
 
@@ -104,6 +110,9 @@
 
     protected TabSet tabs;
 
+    /** The currently focussed Input element. */
+    protected DoubleArrayPanel itemWithFocus;
+
 
     public WQAdaptedInputPanel() {
         wqranges = new HashMap<String, DoubleArrayPanel>();
@@ -111,6 +120,7 @@
         wranges  = new HashMap<String, double[]>();
         qdTable  = new QDTable();
         wTable   = new WTable();
+        initTableListeners();
     }
 
 
@@ -146,9 +156,9 @@
         Tab wTab = new Tab(MESSAGE.wq_table_w());
         Tab qTab = new Tab(MESSAGE.wq_table_q());
 
+        qdTable.showSelect();
         wTab.setPane(wTable);
         qTab.setPane(qdTable);
-        qdTable.hideIconFields();
 
         tabs.addTab(wTab, 0);
         tabs.addTab(qTab, 1);
@@ -159,6 +169,31 @@
     }
 
 
+    /**
+     * Initializes the listeners of the WQD tables.
+     */
+    // TODO dupe from WQInputPanel
+    protected void initTableListeners() {
+        CellClickHandler handler = new CellClickHandler() {
+            @Override
+            public void onCellClick(CellClickEvent e) {
+                if (isWMode() || qdTable.isLocked()) {
+                    return;
+                }
+
+                int    idx = e.getColNum();
+                Record r   = e.getRecord();
+                double val = r.getAttributeAsDouble("value");
+
+                if (itemWithFocus != null) {
+                    itemWithFocus.setValues(new double[]{val});
+                }
+            }
+        };
+
+        qdTable.addCellClickHandler(handler);
+    }
+
     @Override
     public Canvas createOld(DataList dataList) {
         List<Data> all = dataList.getAll();
@@ -426,7 +461,7 @@
             String title = item.getLabel();
             String label = item.getStringValue();
             DoubleArrayPanel dap = new DoubleArrayPanel(
-                label, null, this, TitleOrientation.LEFT);
+                label, null, this, this, TitleOrientation.LEFT);
 
             wqranges.put(title, dap);
 
@@ -597,6 +632,13 @@
     }
 
 
+    /** Store the currently focussed DoubleArrayPanel. */
+    @Override
+    public void onFocus(FocusEvent event) {
+        itemWithFocus = (DoubleArrayPanel) event.getForm();
+    }
+
+
     @Override
     public void onBlur(BlurEvent event) {
         DoubleArrayPanel dap = (DoubleArrayPanel) event.getForm();

http://dive4elements.wald.intevation.org