public class PopupPanel extends SimplePanel implements SourcesPopupEvents, EventPreview, HasAnimation, HasCloseHandlers<PopupPanel>
A PopupPanel should not generally be added to other panels; rather, it should
be shown and hidden using the show()
and hide()
methods.
The width and height of the PopupPanel cannot be explicitly set; they are
determined by the PopupPanel's widget. Calls to setWidth(String)
and
setHeight(String)
will call these methods on the PopupPanel's
widget.
The PopupPanel can be optionally displayed with a "glass" element behind it,
which is commonly used to gray out the widgets behind it. It can be enabled
using setGlassEnabled(boolean)
. It has a default style name of
"gwt-PopupPanelGlass", which can be changed using
setGlassStyleName(String)
.
Modifier and Type | Class and Description |
---|---|
static interface |
PopupPanel.PositionCallback
A callback that is used to set the position of a
PopupPanel right
before it is shown. |
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
HasWidgets.ForIsWidget
DEBUG_ID_PREFIX
Constructor and Description |
---|
PopupPanel()
Creates an empty popup panel.
|
PopupPanel(boolean autoHide)
Creates an empty popup panel, specifying its "auto-hide" property.
|
PopupPanel(boolean autoHide,
boolean modal)
Creates an empty popup panel, specifying its "auto-hide" and "modal"
properties.
|
Modifier and Type | Method and Description |
---|---|
void |
addAutoHidePartner(Element partner)
Mouse events that occur within an autoHide partner will not hide a panel
set to autoHide.
|
HandlerRegistration |
addCloseHandler(CloseHandler<PopupPanel> handler)
Adds a
CloseEvent handler. |
void |
addPopupListener(PopupListener listener)
|
void |
center()
Centers the popup in the browser window and shows it.
|
protected Element |
getContainerElement()
Override this method to specify that an element other than the root element
be the container for the panel's child widget.
|
protected Element |
getGlassElement()
Get the glass element used by this
PopupPanel . |
String |
getGlassStyleName()
Gets the style name to be used on the glass element.
|
int |
getOffsetHeight()
Gets the panel's offset height in pixels.
|
int |
getOffsetWidth()
Gets the panel's offset width in pixels.
|
int |
getPopupLeft()
Gets the popup's left position relative to the browser's client area.
|
int |
getPopupTop()
Gets the popup's top position relative to the browser's client area.
|
protected Element |
getStyleElement()
Template method that returns the element to which style names will be
applied.
|
String |
getTitle()
Gets the title associated with this object.
|
void |
hide()
Hides the popup and detaches it from the page.
|
void |
hide(boolean autoClosed)
Hides the popup and detaches it from the page.
|
boolean |
isAnimationEnabled()
Returns true if animations are enabled, false if not.
|
boolean |
isAutoHideEnabled()
Returns
true if the popup should be automatically hidden when
the user clicks outside of it. |
boolean |
isAutoHideOnHistoryEventsEnabled()
Returns
true if the popup should be automatically hidden when
the history token changes, such as when the user presses the browser's back
button. |
boolean |
isGlassEnabled()
Returns
true if a glass element will be displayed under the
PopupPanel . |
boolean |
isModal()
Returns
true if keyboard or mouse events that do not target
the PopupPanel or its children should be ignored. |
boolean |
isPreviewingAllNativeEvents()
Returns
true if the popup should preview all native events,
even if the event has already been consumed by another popup. |
boolean |
isShowing()
Determines whether or not this popup is showing.
|
boolean |
isVisible()
Determines whether or not this popup is visible.
|
boolean |
onEventPreview(Event event)
Deprecated.
|
boolean |
onKeyDownPreview(char key,
int modifiers)
Deprecated.
|
boolean |
onKeyPressPreview(char key,
int modifiers)
Deprecated.
|
boolean |
onKeyUpPreview(char key,
int modifiers)
Deprecated.
|
protected void |
onPreviewNativeEvent(Event.NativePreviewEvent event) |
protected void |
onUnload()
This method is called immediately before a widget will be detached from the
browser's document.
|
void |
removeAutoHidePartner(Element partner)
Remove an autoHide partner.
|
void |
removePopupListener(PopupListener listener)
Deprecated.
Use the
HandlerRegistration.removeHandler() method on the
object returned by addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>) instead |
void |
setAnimationEnabled(boolean enable)
Enable or disable animations.
|
void |
setAutoHideEnabled(boolean autoHide)
Enable or disable the autoHide feature.
|
void |
setAutoHideOnHistoryEventsEnabled(boolean enabled)
Enable or disable autoHide on history change events.
|
void |
setGlassEnabled(boolean enabled)
When enabled, the background will be blocked with a semi-transparent pane
the next time it is shown.
|
void |
setGlassStyleName(String glassStyleName)
Sets the style name to be used on the glass element.
|
void |
setHeight(String height)
Sets the height of the panel's child widget.
|
void |
setModal(boolean modal)
When the popup is modal, keyboard or mouse events that do not target the
PopupPanel or its children will be ignored.
|
void |
setPopupPosition(int left,
int top)
Sets the popup's position relative to the browser's client area.
|
void |
setPopupPositionAndShow(PopupPanel.PositionCallback callback)
Sets the popup's position using a
PopupPanel.PositionCallback , and shows the
popup. |
void |
setPreviewingAllNativeEvents(boolean previewAllNativeEvents)
When enabled, the popup will preview all native events, even if another
popup was opened after this one.
|
void |
setTitle(String title)
Sets the title associated with this object.
|
void |
setVisible(boolean visible)
Sets whether this object is visible.
|
void |
setWidget(Widget w)
Sets this panel's widget.
|
void |
setWidth(String width)
Sets the width of the panel's child widget.
|
void |
show()
Shows the popup and attach it to the page.
|
void |
showRelativeTo(UIObject target)
Normally, the popup is positioned directly below the relative target, with
its left edge aligned with the left edge of the target.
|
add, getWidget, iterator, remove, setWidget
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, toString
fireEvent
public PopupPanel()
public PopupPanel(boolean autoHide)
autoHide
- true
if the popup should be automatically
hidden when the user clicks outside of it or the history token
changes.public PopupPanel(boolean autoHide, boolean modal)
autoHide
- true
if the popup should be automatically
hidden when the user clicks outside of it or the history token
changes.modal
- true
if keyboard or mouse events that do not
target the PopupPanel or its children should be ignoredpublic void addAutoHidePartner(Element partner)
partner
- the auto hide partner to addpublic HandlerRegistration addCloseHandler(CloseHandler<PopupPanel> handler)
HasCloseHandlers
CloseEvent
handler.addCloseHandler
in interface HasCloseHandlers<PopupPanel>
handler
- the handler@Deprecated public void addPopupListener(PopupListener listener)
addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>)
insteadSourcesPopupEvents
addPopupListener
in interface SourcesPopupEvents
listener
- the listener interface to add.public void center()
public String getGlassStyleName()
public int getOffsetHeight()
setHeight(String)
before the panel's child widget is set will not
influence the offset height.getOffsetHeight
in class UIObject
public int getOffsetWidth()
setWidth(String)
before the panel's child widget is set will not influence the offset width.getOffsetWidth
in class UIObject
public int getPopupLeft()
public int getPopupTop()
public String getTitle()
UIObject
public void hide()
public void hide(boolean autoClosed)
autoClosed
- the value that will be passed to
CloseHandler.onClose(CloseEvent)
when the popup is closedpublic boolean isAnimationEnabled()
HasAnimation
isAnimationEnabled
in interface HasAnimation
public boolean isAutoHideEnabled()
true
if the popup should be automatically hidden when
the user clicks outside of it.public boolean isAutoHideOnHistoryEventsEnabled()
true
if the popup should be automatically hidden when
the history token changes, such as when the user presses the browser's back
button.public boolean isGlassEnabled()
true
if a glass element will be displayed under the
PopupPanel
.public boolean isModal()
true
if keyboard or mouse events that do not target
the PopupPanel or its children should be ignored.public boolean isPreviewingAllNativeEvents()
true
if the popup should preview all native events,
even if the event has already been consumed by another popup.public boolean isShowing()
public boolean isVisible()
visibility
style attribute, which is set in the
setVisible(boolean)
method. If you want to know if the popup is
attached to the page, use isShowing()
instead.isVisible
in interface HasVisibility
isVisible
in class UIObject
true
if the object is visiblesetVisible(boolean)
@Deprecated public boolean onEventPreview(Event event)
onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent)
insteadEventPreview
onEventPreview
in interface EventPreview
event
- the browser eventfalse
to cancel the eventDOM.addEventPreview(EventPreview)
@Deprecated public boolean onKeyDownPreview(char key, int modifiers)
onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent)
insteadkey
- the key code of the depressed keymodifiers
- keyboard modifiers, as specified in
KeyCodes
.false
to suppress the event@Deprecated public boolean onKeyPressPreview(char key, int modifiers)
onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent)
insteadkey
- the unicode character pressedmodifiers
- keyboard modifiers, as specified in
KeyCodes
.false
to suppress the event@Deprecated public boolean onKeyUpPreview(char key, int modifiers)
onPreviewNativeEvent(com.google.gwt.user.client.Event.NativePreviewEvent)
insteadkey
- the key code of the released keymodifiers
- keyboard modifiers, as specified in
KeyCodes
.false
to suppress the eventpublic void removeAutoHidePartner(Element partner)
partner
- the auto hide partner to remove@Deprecated public void removePopupListener(PopupListener listener)
HandlerRegistration.removeHandler()
method on the
object returned by addCloseHandler(com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>)
insteadSourcesPopupEvents
removePopupListener
in interface SourcesPopupEvents
listener
- the listener interface to remove.public void setAnimationEnabled(boolean enable)
HasAnimation
setAnimationEnabled
in interface HasAnimation
enable
- true to enable, false to disablepublic void setAutoHideEnabled(boolean autoHide)
autoHide
- true to enable autoHide, false to disablepublic void setAutoHideOnHistoryEventsEnabled(boolean enabled)
enabled
- true to enable, false to disablepublic void setGlassEnabled(boolean enabled)
enabled
- true to enable, false to disablepublic void setGlassStyleName(String glassStyleName)
glassStyleName
- the glass element's style namepublic void setHeight(String height)
Note that subclasses may have a different behavior. A subclass may decide not to change the height of the child widget. It may instead decide to change the height of an internal panel widget, which contains the child widget.
public void setModal(boolean modal)
modal
- true to make the popup modalpublic void setPopupPosition(int left, int top)
show()
.left
- the left position, in pixelstop
- the top position, in pixelspublic void setPopupPositionAndShow(PopupPanel.PositionCallback callback)
PopupPanel.PositionCallback
, and shows the
popup. The callback allows positioning to be performed based on the
offsetWidth and offsetHeight of the popup, which are normally not available
until the popup is showing. By positioning the popup before it is shown,
the popup will not jump from its original position to the new position.callback
- the callback to set the position of the popupPopupPanel.PositionCallback.setPosition(int offsetWidth, int offsetHeight)
public void setPreviewingAllNativeEvents(boolean previewAllNativeEvents)
When enabled, the popup will preview all native events, even if another popup was opened after this one.
If autoHide is enabled, enabling this feature will cause the popup to autoHide even if another non-modal popup was shown after it. If this feature is disabled, the popup will only autoHide if it was the last popup opened.
previewAllNativeEvents
- true to enable, false to disablepublic void setTitle(String title)
UIObject
public void setVisible(boolean visible)
visibility
style attribute. You need to call show()
to actually attached/detach the PopupPanel
to the page.setVisible
in interface HasVisibility
setVisible
in class UIObject
visible
- true
to show the object, false
to
hide itshow()
,
hide()
public void setWidget(Widget w)
SimplePanel
setWidget
in interface HasOneWidget
setWidget
in class SimplePanel
w
- the panel's new widget, or null
to clear the panelpublic void setWidth(String width)
Note that subclasses may have a different behavior. A subclass may decide not to change the width of the child widget. It may instead decide to change the width of an internal panel widget, which contains the child widget.
public void show()
public final void showRelativeTo(UIObject target)
target
- the target to show the popup belowprotected Element getContainerElement()
SimplePanel
Element
class defined in the
User
module to maintain backwards compatibility.getContainerElement
in class SimplePanel
protected Element getGlassElement()
PopupPanel
. The element is not
created until it is enabled via setGlassEnabled(boolean)
.protected Element getStyleElement()
UIObject
getStyleElement
in class UIObject
protected void onPreviewNativeEvent(Event.NativePreviewEvent event)
Copyright © 2018. All rights reserved.