From 888161bb20894f4e84940bfcab63644ae8d75b84 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Wed, 21 Aug 2013 22:32:56 -0700 Subject: [PATCH] CopyableLabel: Do not hide instances in the current dialog When displaying a dialog or popup that contains a CopyableLabel, allow the label to show its flash movie. The movie will paint on top of the dialog/popup and appear visually correct to the user. Change-Id: I40dd1d3a02e0247ac7d229e96357b328dfecde64 --- .../gwtexpui/clippy/client/CopyableLabel.java | 17 ++++++++++++----- .../user/client/DialogVisibleEvent.java | 14 +++++++++++++- .../user/client/PluginSafeDialogBox.java | 6 +++--- .../user/client/PluginSafePopupPanel.java | 6 +++--- .../google/gwtexpui/user/client/UserAgent.java | 5 +++-- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java index f948f490c6..8ec23a30af 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/clippy/client/CopyableLabel.java @@ -14,8 +14,10 @@ package com.google.gwtexpui.clippy.client; +import static com.google.gwt.dom.client.Style.Visibility.HIDDEN; +import static com.google.gwt.dom.client.Style.Visibility.VISIBLE; + import com.google.gwt.core.client.Scheduler; -import com.google.gwt.dom.client.Style; import com.google.gwt.event.dom.client.BlurEvent; import com.google.gwt.event.dom.client.BlurHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -170,10 +172,15 @@ public class CopyableLabel extends Composite implements HasText { UserAgent.addDialogVisibleHandler(new DialogVisibleHandler() { @Override public void onDialogVisible(DialogVisibleEvent event) { - swf.getStyle().setVisibility( - event.isVisible() - ? Style.Visibility.HIDDEN - : Style.Visibility.VISIBLE); + if (event.contains(CopyableLabel.this)) { + if (event.isVisible()) { + swf.getStyle().setVisibility(VISIBLE); + } + } else { + swf.getStyle().setVisibility(event.isVisible() + ? HIDDEN + : VISIBLE); + } } }); } diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/DialogVisibleEvent.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/DialogVisibleEvent.java index ff3cd516ea..80a940a20b 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/DialogVisibleEvent.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/DialogVisibleEvent.java @@ -15,6 +15,7 @@ package com.google.gwtexpui.user.client; import com.google.gwt.event.shared.GwtEvent; +import com.google.gwt.user.client.ui.Widget; public class DialogVisibleEvent extends GwtEvent { private static Type TYPE; @@ -26,12 +27,23 @@ public class DialogVisibleEvent extends GwtEvent { return TYPE; } + private final Widget parent; private final boolean visible; - DialogVisibleEvent(boolean visible) { + DialogVisibleEvent(Widget w, boolean visible) { + this.parent = w; this.visible = visible; } + public boolean contains(Widget c) { + for (; c != null; c = c.getParent()) { + if (c == parent) { + return true; + } + } + return false; + } + public boolean isVisible() { return visible; } diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafeDialogBox.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafeDialogBox.java index d268280ac1..80bfba12b3 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafeDialogBox.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafeDialogBox.java @@ -43,19 +43,19 @@ public class PluginSafeDialogBox extends DialogBox { @Override public void setVisible(final boolean show) { - UserAgent.fireDialogVisible(show); + UserAgent.fireDialogVisible(this, show); super.setVisible(show); } @Override public void show() { - UserAgent.fireDialogVisible(true); + UserAgent.fireDialogVisible(this, true); super.show(); } @Override public void hide(final boolean autoClosed) { - UserAgent.fireDialogVisible(false); + UserAgent.fireDialogVisible(this, false); super.hide(autoClosed); } } diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafePopupPanel.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafePopupPanel.java index f24387ef12..1ed8f99f0d 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafePopupPanel.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/PluginSafePopupPanel.java @@ -43,19 +43,19 @@ public class PluginSafePopupPanel extends PopupPanel { @Override public void setVisible(final boolean show) { - UserAgent.fireDialogVisible(show); + UserAgent.fireDialogVisible(this, show); super.setVisible(show); } @Override public void show() { - UserAgent.fireDialogVisible(true); + UserAgent.fireDialogVisible(this, true); super.show(); } @Override public void hide(final boolean autoClosed) { - UserAgent.fireDialogVisible(false); + UserAgent.fireDialogVisible(this, false); super.hide(autoClosed); } } diff --git a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/UserAgent.java b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/UserAgent.java index 32dfb71610..c6549026e2 100644 --- a/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/UserAgent.java +++ b/gerrit-gwtexpui/src/main/java/com/google/gwtexpui/user/client/UserAgent.java @@ -19,6 +19,7 @@ import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.ui.Widget; /** * User agent feature tests we don't create permutations for. @@ -39,8 +40,8 @@ public class UserAgent { return bus.addHandler(DialogVisibleEvent.getType(), handler); } - static void fireDialogVisible(boolean visible) { - bus.fireEvent(new DialogVisibleEvent(visible)); + static void fireDialogVisible(Widget w, boolean visible) { + bus.fireEvent(new DialogVisibleEvent(w, visible)); } private static native boolean hasFlash()