diff options
author | Denis Anisimov <denis@vaadin.com> | 2014-08-17 16:20:32 +0300 |
---|---|---|
committer | Sauli Tähkäpää <sauli@vaadin.com> | 2014-10-16 15:51:34 +0300 |
commit | c91fee32e902bbc981056b428463c3548d491aad (patch) | |
tree | c10d170615aa51a12cbb58458a412f550a25a084 /client | |
parent | 4f71e74a2a4ae59885928c23d818737e9c9887c8 (diff) | |
download | vaadin-framework-c91fee32e902bbc981056b428463c3548d491aad.tar.gz vaadin-framework-c91fee32e902bbc981056b428463c3548d491aad.zip |
Postpone shortcut action handler initialization in PopupView (#14275).
Change-Id: I233a63fac4f1afe3f99105ac6dfbbbb38f9b9fad
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VPopupView.java | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/client/src/com/vaadin/client/ui/VPopupView.java b/client/src/com/vaadin/client/ui/VPopupView.java index 931945e546..1a59501d38 100644 --- a/client/src/com/vaadin/client/ui/VPopupView.java +++ b/client/src/com/vaadin/client/ui/VPopupView.java @@ -20,6 +20,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; +import com.google.gwt.core.client.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.Element; import com.google.gwt.event.dom.client.ClickEvent; import com.google.gwt.event.dom.client.ClickHandler; @@ -40,6 +42,7 @@ import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ComponentConnector; +import com.vaadin.client.DeferredWorker; import com.vaadin.client.Util; import com.vaadin.client.VCaptionWrapper; import com.vaadin.client.VConsole; @@ -48,7 +51,8 @@ import com.vaadin.client.ui.ShortcutActionHandler.ShortcutActionHandlerOwner; import com.vaadin.client.ui.popupview.VisibilityChangeEvent; import com.vaadin.client.ui.popupview.VisibilityChangeHandler; -public class VPopupView extends HTML implements Iterable<Widget> { +public class VPopupView extends HTML implements Iterable<Widget>, + DeferredWorker { public static final String CLASSNAME = "v-popupview"; @@ -73,6 +77,8 @@ public class VPopupView extends HTML implements Iterable<Widget> { public final CustomPopup popup; private final Label loading = new Label(); + private boolean popupShowInProgress; + /** * loading constructor */ @@ -280,19 +286,33 @@ public class VPopupView extends HTML implements Iterable<Widget> { @Override public void show() { + popupShowInProgress = true; // Find the shortcut action handler that should handle keyboard // events from the popup. The events do not propagate automatically // because the popup is directly attached to the RootPanel. - Widget widget = VPopupView.this; - while (shortcutActionHandler == null && widget != null) { - if (widget instanceof ShortcutActionHandlerOwner) { - shortcutActionHandler = ((ShortcutActionHandlerOwner) widget) - .getShortcutActionHandler(); - } - widget = widget.getParent(); - } super.show(); + + /* + * Shortcut actions could be set (and currently in 7.2 they ARE SET + * via old style "updateFromUIDL" method, see f.e. UIConnector) + * AFTER method show() has been invoked (which is called as a + * reaction on change in component hierarchy). As a result there + * could be no shortcutActionHandler set yet. So let's postpone + * search of shortcutActionHandler. + */ + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override + public void execute() { + try { + if (shortcutActionHandler == null) { + shortcutActionHandler = findShortcutActionHandler(); + } + } finally { + popupShowInProgress = false; + } + } + }); } /** @@ -378,6 +398,18 @@ public class VPopupView extends HTML implements Iterable<Widget> { positionOrSizeUpdated(); } + private ShortcutActionHandler findShortcutActionHandler() { + Widget widget = VPopupView.this; + ShortcutActionHandler handler = null; + while (handler == null && widget != null) { + if (widget instanceof ShortcutActionHandlerOwner) { + handler = ((ShortcutActionHandlerOwner) widget) + .getShortcutActionHandler(); + } + widget = widget.getParent(); + } + return handler; + } }// class CustomPopup public HandlerRegistration addVisibilityChangeHandler( @@ -391,4 +423,9 @@ public class VPopupView extends HTML implements Iterable<Widget> { return Collections.singleton((Widget) popup).iterator(); } + @Override + public boolean isWorkPending() { + return popupShowInProgress; + } + }// class VPopupView |