]> source.dussan.org Git - vaadin-framework.git/commitdiff
Added support for layout click events
authorArtur Signell <artur@vaadin.com>
Fri, 23 Mar 2012 12:04:47 +0000 (14:04 +0200)
committerArtur Signell <artur@vaadin.com>
Fri, 23 Mar 2012 14:31:21 +0000 (16:31 +0200)
src/com/vaadin/terminal/gwt/client/ui/AbstractOrderedLayoutConnector.java

index ce2d9c28ad29548a0a69c94b2ad40aeb98590115..11199ec99277fc74feb8ccd8135b024f62f1a908 100644 (file)
@@ -6,13 +6,18 @@ package com.vaadin.terminal.gwt.client.ui;
 import java.util.List;
 
 import com.google.gwt.dom.client.Style;
+import com.google.gwt.event.dom.client.DomEvent.Type;
+import com.google.gwt.event.shared.EventHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.user.client.Element;
 import com.google.gwt.user.client.ui.Widget;
 import com.vaadin.terminal.gwt.client.ApplicationConnection;
 import com.vaadin.terminal.gwt.client.ComponentConnector;
 import com.vaadin.terminal.gwt.client.DirectionalManagedLayout;
+import com.vaadin.terminal.gwt.client.EventId;
 import com.vaadin.terminal.gwt.client.LayoutManager;
 import com.vaadin.terminal.gwt.client.UIDL;
+import com.vaadin.terminal.gwt.client.Util;
 import com.vaadin.terminal.gwt.client.VCaption;
 import com.vaadin.terminal.gwt.client.ValueMap;
 import com.vaadin.terminal.gwt.client.ui.layout.ComponentConnectorLayoutSlot;
@@ -21,6 +26,22 @@ import com.vaadin.terminal.gwt.client.ui.layout.VLayoutSlot;
 public abstract class AbstractOrderedLayoutConnector extends
         AbstractComponentContainerConnector implements DirectionalManagedLayout {
 
+    private LayoutClickEventHandler clickEventHandler = new LayoutClickEventHandler(
+            this, EventId.LAYOUT_CLICK) {
+
+        @Override
+        protected ComponentConnector getChildComponent(Element element) {
+            return Util.getPaintableForElement(getConnection(), getWidget(),
+                    element);
+        }
+
+        @Override
+        protected <H extends EventHandler> HandlerRegistration registerHandler(
+                H handler, Type<H> type) {
+            return getWidget().addDomHandler(handler, type);
+        }
+    };
+
     @Override
     public void init() {
         getLayoutManager().registerDependency(this,
@@ -58,6 +79,7 @@ public abstract class AbstractOrderedLayoutConnector extends
         if (!isRealUpdate(uidl)) {
             return;
         }
+        clickEventHandler.handleEventHandlerRegistration();
 
         VMeasuringOrderedLayout layout = getWidget();