changeset 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 92c8f8d1a3ba
children 2a5b15e071d8
files flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/QSegmentedInputPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java
diffstat 3 files changed, 54 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java	Thu Mar 07 19:38:36 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DoubleArrayPanel.java	Fri Mar 08 09:17:50 2013 +0100
@@ -9,6 +9,7 @@
 import com.smartgwt.client.widgets.form.fields.StaticTextItem;
 import com.smartgwt.client.widgets.form.fields.TextItem;
 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
+import com.smartgwt.client.widgets.form.fields.events.FocusHandler;
 
 import de.intevation.flys.client.client.FLYSConstants;
 
@@ -33,7 +34,7 @@
         double[] values,
         BlurHandler handler)
     {
-        this(title, values, handler, TitleOrientation.RIGHT);
+        this(title, values, handler, null, TitleOrientation.RIGHT);
     }
 
 
@@ -44,12 +45,14 @@
      * @param name The name of the TextItem.
      * @param title The title of the TextItem.
      * @param values The double values that should be displayed initially.
-     * @param handler The BlurHandler that is used to valide the input.
+     * @param blurHandler The BlurHandler that is used to valide the input.
+     * @param focusHandler The FocueHandler that is used to valide the input.
      */
     public DoubleArrayPanel(
         String title,
         double[] values,
-        BlurHandler handler,
+        BlurHandler blurHandler,
+        FocusHandler focusHandler,
         TitleOrientation titleOrientation)
     {
         this.title = title;
@@ -60,7 +63,8 @@
         sti.setShowTitle(false);
         sti.setValue(title);
 
-        ti.addBlurHandler(handler);
+        ti.addBlurHandler(blurHandler);
+        ti.addFocusHandler(focusHandler);
 
         if (titleOrientation == TitleOrientation.RIGHT) {
             setFields(ti, sti);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/QSegmentedInputPanel.java	Thu Mar 07 19:38:36 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/QSegmentedInputPanel.java	Fri Mar 08 09:17:50 2013 +0100
@@ -297,7 +297,7 @@
             String title = item.getLabel();
 
             DoubleArrayPanel dap = new DoubleArrayPanel(
-                createLineTitle(title), null, this, TitleOrientation.LEFT);
+                createLineTitle(title), null, this, null, TitleOrientation.LEFT);
 
             wqranges.put(title, dap);
 
--- 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