[PATCH] FocusHandler re-added

Wald Commits scm-commit at wald.intevation.org
Tue Jul 24 16:02:49 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1532440960 -7200
# Node ID e3e465766cfe8823cb4b7507e2d2fe5770844260
# Parent  e6958f0e72fa97d286308723353a3b62e7e39d25
FocusHandler re-added

diff -r e6958f0e72fa -r e3e465766cfe gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java	Tue Jul 24 15:30:10 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/BunduWstWQPanel.java	Tue Jul 24 16:02:40 2018 +0200
@@ -39,6 +39,8 @@
 import com.smartgwt.client.widgets.form.fields.TextItem;
 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.form.validator.IntegerRangeValidator;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
@@ -50,7 +52,7 @@
  *
  * @author <a href="mailto:aheinecke at intevation.de">Andre Heinecke</a>
  */
-public class BunduWstWQPanel extends AbstractWQAdaptedInputPanel {
+public class BunduWstWQPanel extends AbstractWQAdaptedInputPanel implements FocusHandler {
 
     private static final long serialVersionUID = -1L;
 
@@ -58,6 +60,9 @@
         Q, UD
     }
 
+    /** The currently focussed Input element. */
+    private DoubleArrayPanel itemWithFocus;
+
     /** Service to fetch W/Q MainValues. */
     private final DynamicMainValuesServiceAsync mainValueService = GWT.create(DynamicMainValuesService.class);
 
@@ -220,7 +225,7 @@
 
                 this.tabs.getTab(i).setTitle(this.tabs.getTab(i).getTitle() + " (" + label + ")");
 
-                final DoubleArrayPanel dap = new DoubleArrayPanel(label, null, this, null, TitleOrientation.LEFT);
+                final DoubleArrayPanel dap = new DoubleArrayPanel(label, null, this, this, TitleOrientation.LEFT);
                 this.wqranges.put(title, dap);
                 this.doubleArrayPanels.add(dap);
                 if (item instanceof WQDataItem) {
@@ -355,4 +360,14 @@
 
         this.mainValueService.getWQInfo(locale, river, start, end, startYear, endYear, cb);
     }
+
+    @Override
+    public void onFocus(final FocusEvent event) {
+        this.itemWithFocus = (DoubleArrayPanel) event.getForm();
+        // Switch to respective tab.
+        if (getMode().equals(mode.Q.toString())) {
+            final int inputIndex = this.doubleArrayPanels.indexOf(this.itemWithFocus);
+            this.tabs.selectTab(inputIndex);
+        }
+    }
 }
\ No newline at end of file


More information about the Dive4Elements-commits mailing list