]> source.dussan.org Git - vaadin-framework.git/commitdiff
Start client-side Grid DOM event handling refactor
authorJohannes Dahlström <johannesd@vaadin.com>
Tue, 2 Aug 2016 09:07:22 +0000 (12:07 +0300)
committerPekka Hyvönen <pekka@vaadin.com>
Thu, 1 Dec 2016 09:48:23 +0000 (09:48 +0000)
Change-Id: I67dad4cfbd6e9e355c48703253ff3d6da00e4eef

client/src/main/java/com/vaadin/client/widgets/Grid.java

index e10035f9f7f34be858f41f351e3d1baf8451c54d..5e331244059dc43527807bc623a15c2873a64adf 100644 (file)
@@ -7311,31 +7311,34 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         eventCell.set(cell, getSectionFromContainer(container));
 
         // Editor can steal focus from Grid and is still handled
-        if (isEditorEnabled() && handleEditorEvent(event, container)) {
+        if (handleEditorEvent(event, container)) {
             return;
         }
 
         // Fire GridKeyEvents and GridClickEvents. Pass the event to escalator.
-        super.onBrowserEvent(event);
+        if (handleSuperEvent(event, container)) {
+            return;
+        }
 
-        if (!isElementInChildWidget(e)) {
+        if (handleChildWidgetEvent(event, container)) {
+            return;
+        }
 
-            if (handleHeaderCellDragStartEvent(event, container)) {
-                return;
-            }
+        if (handleHeaderCellDragStartEvent(event, container)) {
+            return;
+        }
 
-            // Sorting through header Click / KeyUp
-            if (handleHeaderDefaultRowEvent(event, container)) {
-                return;
-            }
+        // Sorting through header Click / KeyUp
+        if (handleHeaderDefaultRowEvent(event, container)) {
+            return;
+        }
 
-            if (handleRendererEvent(event, container)) {
-                return;
-            }
+        if (handleRendererEvent(event, container)) {
+            return;
+        }
 
-            if (handleCellFocusEvent(event, container)) {
-                return;
-            }
+        if (handleCellFocusEvent(event, container)) {
+            return;
         }
     }
 
@@ -7389,6 +7392,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
     }
 
     private boolean handleEditorEvent(Event event, RowContainer container) {
+        if (!isEditorEnabled()) {
+            return false;
+        }
+
         Widget w;
         if (editor.focusedColumnIndex < 0) {
             w = null;
@@ -7402,6 +7409,16 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         return getEditor().getEventHandler().handleEvent(editorEvent);
     }
 
+    private boolean handleSuperEvent(Event event, RowContainer container) {
+        super.onBrowserEvent(event);
+        return false;
+    }
+
+    private boolean handleChildWidgetEvent(Event event,
+            RowContainer container) {
+        return isElementInChildWidget(Element.as(event.getEventTarget()));
+    }
+
     private boolean handleRendererEvent(Event event, RowContainer container) {
 
         if (container == escalator.getBody()) {