From 1cf11f84320ef650b650eb8f852cee34e9e75c75 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Antti=20Tanhuanp=C3=A4=C3=A4?= Date: Tue, 6 May 2014 16:39:15 +0300 Subject: [PATCH] Resize PopupView's overlay on content resize (#13666) Change-Id: Iad410f26ed7f20bb03f15c46673f6f18081261d9 --- .../src/com/vaadin/client/ui/VPopupView.java | 18 ++++- uitest/ivy.xml | 2 + .../popupview/PopupViewResizeWhileOpen.java | 73 +++++++++++++++++++ .../PopupViewResizeWhileOpenTest.java | 70 ++++++++++++++++++ 4 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpen.java create mode 100644 uitest/src/com/vaadin/tests/components/popupview/PopupViewResizeWhileOpenTest.java diff --git a/client/src/com/vaadin/client/ui/VPopupView.java b/client/src/com/vaadin/client/ui/VPopupView.java index 60165c9f9d..adf070f453 100644 --- a/client/src/com/vaadin/client/ui/VPopupView.java +++ b/client/src/com/vaadin/client/ui/VPopupView.java @@ -43,6 +43,7 @@ import com.vaadin.client.ComponentConnector; import com.vaadin.client.Util; import com.vaadin.client.VCaptionWrapper; import com.vaadin.client.VConsole; +import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.popupview.VisibilityChangeEvent; import com.vaadin.client.ui.popupview.VisibilityChangeHandler; @@ -193,7 +194,8 @@ public class VPopupView extends HTML implements Iterable { * (other than it being a VOverlay) is to be considered private and * potentially subject to change. */ - public class CustomPopup extends VOverlay { + public class CustomPopup extends VOverlay implements + StateChangeEvent.StateChangeHandler { private ComponentConnector popupComponentConnector = null; @@ -333,7 +335,9 @@ public class VPopupView extends HTML implements Iterable { @Override public boolean remove(Widget w) { - + if (popupComponentConnector != null) { + popupComponentConnector.removeStateChangeHandler(this); + } popupComponentConnector = null; popupComponentWidget = null; captionWrapper = null; @@ -344,10 +348,15 @@ public class VPopupView extends HTML implements Iterable { public void setPopupConnector(ComponentConnector newPopupComponent) { if (newPopupComponent != popupComponentConnector) { + if (popupComponentConnector != null) { + popupComponentConnector.removeStateChangeHandler(this); + } Widget newWidget = newPopupComponent.getWidget(); setWidget(newWidget); popupComponentWidget = newWidget; popupComponentConnector = newPopupComponent; + popupComponentConnector.addStateChangeHandler("height", this); + popupComponentConnector.addStateChangeHandler("width", this); } } @@ -361,6 +370,11 @@ public class VPopupView extends HTML implements Iterable { return super.getContainerElement(); } + @Override + public void onStateChanged(StateChangeEvent stateChangeEvent) { + positionOrSizeUpdated(); + } + }// class CustomPopup public HandlerRegistration addVisibilityChangeHandler( diff --git a/uitest/ivy.xml b/uitest/ivy.xml index f54ea7270e..020543c53f 100644 --- a/uitest/ivy.xml +++ b/uitest/ivy.xml @@ -83,6 +83,8 @@ +