]> 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)
committerHenri Sara <henri.sara@gmail.com>
Tue, 3 Jan 2017 07:47:18 +0000 (09:47 +0200)
Change-Id: I67dad4cfbd6e9e355c48703253ff3d6da00e4eef

client/src/main/java/com/vaadin/client/widgets/Grid.java
compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java

index 2cac853ea17e8b73f2d5a402b7b47166ee132584..c663b7af50b78719ee104372e4623471da45b5ac 100644 (file)
@@ -7316,31 +7316,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;
         }
     }
 
@@ -7394,6 +7397,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;
@@ -7407,6 +7414,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()) {
index a6fbfb4e760de0f1deb837ca02a7cdf80f62fddc..82d599b31d894b7f774ddd6665f1eb21ba61b5b4 100644 (file)
@@ -7324,31 +7324,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;
         }
     }
 
@@ -7402,6 +7405,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;
@@ -7415,6 +7422,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()) {