From 85a1e621e7b64bb16de61b5f511837362a90b352 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 24 Nov 2015 11:35:35 +0200 Subject: Remove VOverlay dependency and use PopupPanel instead in Grid (#18698) Change-Id: Id28a9fa8a204c1e2a12160e2e1dba1823f3726a5 --- client/src/com/vaadin/client/widgets/Grid.java | 34 +++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'client/src') diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 1304c40030..2fc2b4610b 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -34,8 +34,10 @@ import java.util.logging.Logger; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.shared.GWT; +import com.google.gwt.dom.client.BodyElement; import com.google.gwt.dom.client.BrowserEvents; import com.google.gwt.dom.client.DivElement; +import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.EventTarget; import com.google.gwt.dom.client.NativeEvent; @@ -88,7 +90,6 @@ import com.vaadin.client.renderers.Renderer; import com.vaadin.client.renderers.WidgetRenderer; import com.vaadin.client.ui.FocusUtil; import com.vaadin.client.ui.SubPartAware; -import com.vaadin.client.ui.VOverlay; import com.vaadin.client.ui.dd.DragAndDropHandler; import com.vaadin.client.ui.dd.DragAndDropHandler.DragAndDropCallback; import com.vaadin.client.ui.dd.DragHandle; @@ -3595,7 +3596,7 @@ public class Grid extends ResizeComposite implements private final Grid grid; - private VOverlay overlay; + private PopupPanel overlay; private Sidebar(Grid grid) { this.grid = grid; @@ -3687,9 +3688,34 @@ public class Grid extends ResizeComposite implements * Creates and initializes the overlay. */ private void createOverlay() { - overlay = GWT.create(VOverlay.class); + overlay = new PopupPanel() { + + @Override + protected void onAttach() { + // PopupPanel by default attaches itself directly to the + // body. Try to find a Vaadin overlay container and move the + // overlay there if found. + + // FIXME: This is a hack; Grid should not have + // Vaadin-specific behavior special-cased. Instead, there + // should be a customization point for setting the overlay + // container. + + BodyElement body = Document.get().getBody(); + Element target = body.getFirstChildElement(); + while (!target.hasClassName("v-overlay-container") + && target != null) { + target = target.getNextSiblingElement(); + } + + if (target != null) { + target.appendChild(getElement()); + } + + super.onAttach(); + } + }; overlay.setAutoHideEnabled(true); - overlay.setOwner(grid); overlay.addStyleDependentName("popup"); overlay.add(content); overlay.addAutoHidePartner(rootContainer.getElement()); -- cgit v1.2.3