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
This commit is contained in:
Shawn Pearce 2013-08-21 22:32:56 -07:00
parent 74f574324d
commit 888161bb20
5 changed files with 34 additions and 14 deletions

View File

@ -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);
}
}
});
}

View File

@ -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<DialogVisibleHandler> {
private static Type<DialogVisibleHandler> TYPE;
@ -26,12 +27,23 @@ public class DialogVisibleEvent extends GwtEvent<DialogVisibleHandler> {
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;
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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()