DecoratedPopupPanel class
A {@link PopupPanel} that wraps its content in a 3x3 grid, which allows users to add rounded corners.
Setting the Size:
If you set the width or height of the {@link DecoratedPopupPanel}, you need to set the height and width of the middleCenter cell to 100% so that the middleCenter cell takes up all of the available space. If you do not set the width and height of the {@link DecoratedPopupPanel}, it will wrap its contents tightly.
.dwt-DecoratedPopupPanel .popupMiddleCenter { height: 100%; width: 100%; }
CSS Style Rules
- .dwt-DecoratedPopupPanel { the outside of the popup }
- .dwt-DecoratedPopupPanel .popupContent { the wrapper around the content }
- .dwt-DecoratedPopupPanel .popupTopLeft { the top left cell }
- .dwt-DecoratedPopupPanel .popupTopLeftInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupTopCenter { the top center cell }
- .dwt-DecoratedPopupPanel .popupTopCenterInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupTopRight { the top right cell }
- .dwt-DecoratedPopupPanel .popupTopRightInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupMiddleLeft { the middle left cell }
- .dwt-DecoratedPopupPanel .popupMiddleLeftInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupMiddleCenter { the middle center cell }
- .dwt-DecoratedPopupPanel .popupMiddleCenterInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupMiddleRight { the middle right cell }
- .dwt-DecoratedPopupPanel .popupMiddleRightInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupBottomLeft { the bottom left cell }
- .dwt-DecoratedPopupPanel .popupBottomLeftInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupBottomCenter { the bottom center cell }
- .dwt-DecoratedPopupPanel .popupBottomCenterInner { the inner element of the cell }
- .dwt-DecoratedPopupPanel .popupBottomRight { the bottom right cell }
- .dwt-DecoratedPopupPanel .popupBottomRightInner { the inner element of the cell }
class DecoratedPopupPanel extends PopupPanel { static final String _DEFAULT_STYLENAME = "dwt-DecoratedPopupPanel"; /** * The panel used to nine box the contents. */ DecoratorPanel _decPanel; /** * Creates an empty decorated popup panel using the specified style names. * * @param autoHide <code>true</code> if the popup should be automatically * hidden when the user clicks outside of it * @param modal <code>true</code> if keyboard or mouse events that do not * target the PopupPanel or its children should be ignored * @param prefix the prefix applied to child style names */ DecoratedPopupPanel([bool autoHide = false, bool modal = false, String prefix = "popup"]) : super(autoHide, modal) { List<String> rowStyles = [prefix + "Top", prefix + "Middle", prefix + "Bottom"]; _decPanel = new DecoratorPanel(rowStyles, 1); _decPanel.clearAndSetStyleName(""); setStylePrimaryName(_DEFAULT_STYLENAME); super.setWidget(_decPanel); UiObject.manageElementStyleName(getContainerElement(), "popupContent", false); UiObject.manageElementStyleName(_decPanel.getContainerElement(), prefix + "Content", true); } void clear() { _decPanel.clear(); } Widget getWidget() { return _decPanel.getWidget(); } Iterator<Widget> iterator() { return _decPanel.iterator(); } bool remove(Widget w) { return _decPanel.remove(w); } void setWidget(Widget w) { _decPanel.setWidget(w); maybeUpdateSize(); } void doAttachChildren() { // See comment in doDetachChildren for an explanation of this call _decPanel.onAttach(); } void doDetachChildren() { // We need to detach the decPanel because it is not part of the iterator of // Widgets that this class returns (see the iterator() method override). // Detaching the decPanel detaches both itself and its children. We do not // call super.onDetachChildren() because that would detach the decPanel's // children (redundantly) without detaching the decPanel itself. // This is similar to a {@link ComplexPanel}, but we do not want to expose // the decPanel widget, as its just an internal implementation. _decPanel.onDetach(); } /** * Get a specific Element from the panel. * * @param row the row index * @param cell the cell index * @return the Element at the given row and cell */ dart_html.Element getCellElement(int row, int cell) { return _decPanel.getCellElement(row, cell); } }
Extends
UiObject > Widget > Panel > SimplePanel > PopupPanel > DecoratedPopupPanel
Subclasses
Constructors
new DecoratedPopupPanel([bool autoHide = false, bool modal = false, String prefix = "popup"]) #
Creates an empty decorated popup panel using the specified style names.
@param autoHide <code>true</code> if the popup should be automatically
hidden when the user clicks outside of it
@param modal <code>true</code> if keyboard or mouse events that do not
target the PopupPanel or its children should be ignored
@param prefix the prefix applied to child style names
DecoratedPopupPanel([bool autoHide = false, bool modal = false, String prefix = "popup"]) : super(autoHide, modal) { List<String> rowStyles = [prefix + "Top", prefix + "Middle", prefix + "Bottom"]; _decPanel = new DecoratorPanel(rowStyles, 1); _decPanel.clearAndSetStyleName(""); setStylePrimaryName(_DEFAULT_STYLENAME); super.setWidget(_decPanel); UiObject.manageElementStyleName(getContainerElement(), "popupContent", false); UiObject.manageElementStyleName(_decPanel.getContainerElement(), prefix + "Content", true); }
Properties
AnimationType animType #
If true, animate the opening of this popup from the center. If false, animate it open from top to bottom, and do not animate closing. Use false to animate menus.
AnimationType animType = AnimationType.CENTER
int eventsToSink #
A set og events that should be sunk when the widget is attached to the DOM. (We delay the sinking of events to improve startup performance.) When the widget is attached, this is set is empty
Package protected to allow Composite to see it.
int eventsToSink = 0
ResizeHandler glassResizer #
Window resize handler used to keep the glass the proper size.
ResizeHandler glassResizer
HandlerRegistration historyHandlerRegistration #
HandlerRegistration historyHandlerRegistration
bool modal #
bool autoHide = false, previewAllNativeEvents = false, modal = false
HandlerRegistration nativePreviewHandlerRegistration #
HandlerRegistration nativePreviewHandlerRegistration
bool previewAllNativeEvents #
bool autoHide = false, previewAllNativeEvents = false
ResizeAnimation resizeAnimation #
The {@link ResizeAnimation} used to open and close the {@link PopupPanel}s.
ResizeAnimation resizeAnimation
bool showing #
bool autoHide = false, previewAllNativeEvents = false, modal = false, showing = false
String get title #
Gets the title associated with this object. The title is the 'tool-tip' displayed to users when they hover over the object.
@return the object's title
String get title => getElement().title;
void set title(String value) #
Sets the element's title.
void set title(String value) { getElement().title = value; }
bool get visible #
Determines whether or not this popup is visible. Note that this just checks the <code>visibility</code> style attribute, which is set in the {@link #setVisible(bool)} method. If you want to know if the popup is attached to the page, use {@link #isShowing()} instead.
@return <code>true</code> if the object is visible @see #setVisible(bool)
bool get visible => getElement().style.visibility != "hidden";
void set visible(bool vis) #
Sets whether this object is visible. This method just sets the <code>visibility</code> style attribute. You need to call {@link #show()} to actually attached/detach the {@link PopupPanel} to the page.
@param visible <code>true</code> to show the object, <code>false</code> to
hide it
@see #show() @see #hide()
void set visible(bool vis) { // We use visibility here instead of UiObject's default of display // Because the panel is absolutely positioned, this will not create // "holes" in displayed contents and it allows normal layout passes // to occur so the size of the PopupPanel can be reliably determined. Dom.setStyleAttribute(getElement(), "visibility", vis ? "visible" : "hidden"); // If the PopupImpl creates an iframe shim, it's also necessary to hide it // as well. impl.setVisible(getElement(), vis); if (glass != null) { impl.setVisible(glass, vis); glass.style.visibility = vis ? "visible" : "hidden"; } }
Methods
void add(Widget w) #
Adds a widget to this panel.
@param w the child widget to be added
void add(Widget w) { // Can't add() more than one widget to a SimplePanel. if (getWidget() != null) { throw new Exception("SimplePanel can only contain one child widget"); } setWidget(w); }
HandlerRegistration addAttachHandler(AttachEventHandler handler) #
Adds an AttachEvent handler.
@param handler the handler @return the handler registration
HandlerRegistration addAttachHandler(AttachEventHandler handler) { return addHandler(handler, AttachEvent.TYPE); }
void addAutoHidePartner(Element partner) #
Mouse events that occur within an autoHide partner will not hide a panel set to autoHide.
@param partner the auto hide partner to add
void addAutoHidePartner(dart_html.Element partner) { assert (partner != null); // : "partner cannot be null"; if (autoHidePartners == null) { autoHidePartners = new List<dart_html.Element>(); } autoHidePartners.add(partner); }
HandlerRegistration addBitlessDomHandler(EventHandler handler, DomEventType type) #
For <a href= "http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks"
browsers which do not leak</a>, adds a native event handler to the widget.
Note that, unlike the {@link #addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)} implementation, there is no need to attach the widget to the DOM in order to cause the event handlers to be attached.
@param <H> the type of handler to add @param type the event key @param handler the handler @return {@link HandlerRegistration} used to remove the handler
HandlerRegistration addBitlessDomHandler(EventHandler handler, DomEventType type) { assert (handler != null);; // : "handler must not be null"; assert (type != null); // : "type must not be null"; sinkBitlessEvent(type.eventName); return ensureHandlers().addHandler(type, handler); }
HandlerRegistration addCloseHandler(CloseHandler handler) #
Adds a {@link CloseEvent} handler.
@param handler the handler @return the registration for the event
HandlerRegistration addCloseHandler(CloseHandler handler) { return addHandler(handler, CloseEvent.TYPE); }
HandlerRegistration addDomHandler(EventHandler handler, DomEventType type) #
Adds a native event handler to the widget and sinks the corresponding native event. If you do not want to sink the native event, use the generic addHandler method instead.
@param <H> the type of handler to add @param type the event key @param handler the handler @return {@link HandlerRegistration} used to remove the handler
HandlerRegistration addDomHandler(EventHandler handler, DomEventType type) { assert (handler != null); // : "handler must not be null"; assert (type != null); // : "type must not be null"; int typeInt = IEvent.getTypeInt(type.eventName); if (typeInt == -1) { sinkBitlessEvent(type.eventName); } else { sinkEvents(typeInt); } return ensureHandlers().addHandler(type, handler); }
HandlerRegistration addHandler(EventHandler handler, EventType<EventHandler> type) #
Adds this handler to the widget.
@param <H> the type of handler to add @param type the event type @param handler the handler @return {@link HandlerRegistration} used to remove the handler
HandlerRegistration addHandler(EventHandler handler, EventType<EventHandler> type) { return ensureHandlers().addHandler(type, handler); }
void addIsWidget(IsWidget child) #
void addIsWidget(IsWidget child) { this.add(Widget.asWidgetOrNull(child)); }
void addStyleDependentName(String styleSuffix) #
Adds a dependent style name by specifying the style name's suffix. The actual form of the style name that is added is:
getStylePrimaryName() + '-' + styleSuffix
@param styleSuffix the suffix of the dependent style to be added. @see #setStylePrimaryName(String) @see #removeStyleDependentName(String) @see #setStyleDependentName(String, boolean) @see #addStyleName(String)
void addStyleDependentName(String styleSuffix) { setStyleDependentName(styleSuffix, true); }
void addStyleName(String style) #
Adds a secondary or dependent style name to this object. A secondary style name is an additional style name that is, in HTML/CSS terms, included as a space-separated token in the value of the CSS <code>class</code> attribute for this object's root element.
The most important use for this method is to add a special kind of
secondary style name called a dependent style name. To add a
dependent style name, use {@link #addStyleDependentName(String)}, which
will prefix the 'style' argument with the result of
{@link #k()} (followed by a '-'). For example, suppose
the primary style name is gwt-TextBox
. If the following method
is called as obj.setReadOnly(true)
:
public void setReadOnly(boolean readOnly) { isReadOnlyMode = readOnly;// Create a dependent style name. String readOnlyStyle = "readonly";
if (readOnly) {
addStyleDependentName(readOnlyStyle);
} else {
removeStyleDependentName(readOnlyStyle);
} }</pre>
then both of the CSS style rules below will be applied:
// This rule is based on the primary style name and is always active. .gwt-TextBox { font-size: 12pt; }
// This rule is based on a dependent style name that is only active // when the widget has called addStyleName(getStylePrimaryName() + // "-readonly"). .gwt-TextBox-readonly { background-color: lightgrey; border: none; }</pre>
The code can also be simplified with {@link #setStyleDependentName(String, boolean)}:
public void setReadOnly(boolean readOnly) { isReadOnlyMode = readOnly; setStyleDependentName("readonly", readOnly); }Dependent style names are powerful because they are automatically updated whenever the primary style name changes. Continuing with the example above, if the primary style name changed due to the following call:
setStylePrimaryName("my-TextThingy");then the object would be re-associated with following style rules, removing those that were shown above.
.my-TextThingy { font-size: 20pt; }.my-TextThingy-readonly { background-color: red; border: 2px solid yellow; }</pre>
Secondary style names that are not dependent style names are not automatically updated when the primary style name changes.
@param style the secondary style name to be added @see UIObject @see #removeStyleName(String)
void addStyleName(String style) { setStyleName(style, true); }
void adopt(Widget child) #
Finalize the attachment of a Widget to this Panel. This method is the <b>last</b> step in adding or inserting a Widget into a Panel, and should be called after physical attachment in the DOM is complete. This Panel becomes the parent of the child Widget, and the child will now fire its {@link Widget#onAttach()} event if this Panel is currently attached.
@param child the widget to be adopted @see #add(Widget)
void adopt(Widget child) { assert (child.getParent() == null); child.setParent(this); }
Widget asWidget() #
Returns the Widget aspect of the receiver.
Widget asWidget() { return this; }
void blur(Element elt) #
Remove focus from an dart_html.Element.
@param elt The dart_html.Element on which <code>blur()</code> will be invoked
void blur(dart_html.Element elt) { // Issue 2390: blurring the body causes IE to disappear to the background if (elt.blur != null && elt != dart_html.document.body) { elt.blur(); } }
void center() #
Centers the popup in the browser window and shows it. If the popup was already showing, then the popup is centered.
void center() { bool initiallyShowing = showing; bool initiallyAnimated = _isAnimationEnabled; if (!initiallyShowing) { visible = false; setAnimationEnabled(false); show(); } // If left/top are set from a previous center() call, and our content // has changed, we may get a bogus getOffsetWidth because our new content // is wrapping (giving a lower offset width) then it would without the // previous left. Setting left/top back to 0 avoids this. dart_html.Element elem = getElement(); elem.style.left = "0px"; elem.style.top = "0px"; int left = (Dom.getClientWidth() - getOffsetWidth()) >> 1; int top = (Dom.getClientHeight() - getOffsetHeight()) >> 1; setPopupPosition(dart_math.max(Dom.getScrollLeft() + left, 0), dart_math.max(Dom.getScrollTop() + top, 0)); if (!initiallyShowing) { setAnimationEnabled(initiallyAnimated); // Run the animation. The popup is already visible, so we can skip the // call to setState. if (initiallyAnimated) { impl.setClip(getElement(), "rect(0px, 0px, 0px, 0px)"); visible = true; resizeAnimation.run(ANIMATION_DURATION); } else { visible = true; } } }
void clear() #
Removes all child widgets.
void clear() { _decPanel.clear(); }
void clearAndSetStyleName(String style) #
Clears all of the object's style names and sets it to the given style. You should normally use {@link #setStylePrimaryName(String)} unless you wish to explicitly remove all existing styles.
@param style the new style name @see #setStylePrimaryName(String)
void clearAndSetStyleName(String style) { setElementStyleName(getStyleElement(), style); }
EventBus createEventBus() #
Creates the SimpleEventBus used by this Widget. You can override this method to create a custom EventBus.
@return the EventBus you want to use.
EventBus createEventBus() { return new SimpleEventBus(); }
void delegateEvent(Widget target, DwtEvent event) #
Fires an event on a child widget. Used to delegate the handling of an event from one widget to another.
@param event the event @param target fire the event on the given target
void delegateEvent(Widget target, DwtEvent event) { target.fireEvent(event); }
void doAttachChildren() #
If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call {@link #onAttach()} for each of its child widgets.
@see #onAttach()
void doAttachChildren() { // See comment in doDetachChildren for an explanation of this call _decPanel.onAttach(); }
void doDetachChildren() #
If a widget contains one or more child widgets that are not in the logical widget hierarchy (the child is physically connected only on the DOM level), it must override this method and call {@link #onDetach()} for each of its child widgets.
@see #onDetach()
void doDetachChildren() { // We need to detach the decPanel because it is not part of the iterator of // Widgets that this class returns (see the iterator() method override). // Detaching the decPanel detaches both itself and its children. We do not // call super.onDetachChildren() because that would detach the decPanel's // children (redundantly) without detaching the decPanel itself. // This is similar to a {@link ComplexPanel}, but we do not want to expose // the decPanel widget, as its just an internal implementation. _decPanel.onDetach(); }
EventBus ensureHandlers() #
Ensures the existence of the event bus.
@return the EventBus.
EventBus ensureHandlers() { return _eventBus == null ? _eventBus = createEventBus() : _eventBus; }
bool eventTargetsPartner(Event event) #
Does the event target one of the partner elements?
@param event the event @return true if the event targets a partner
bool eventTargetsPartner(dart_html.Event event) { if (autoHidePartners == null) { return false; } dart_html.EventTarget target = event.target; if (target is dart_html.Element) { for (dart_html.Element elem in autoHidePartners) { if (Dom.isOrHasChild(elem, target as dart_html.Element)) { return true; } } } return false; }
bool eventTargetsPopup(Event event) #
Does the event target this popup?
@param event the event @return true if the event targets the popup
bool eventTargetsPopup(dart_html.Event event) { dart_html.EventTarget target = event.target; if (target is dart_html.Element) { return Dom.isOrHasChild(getElement(), target as dart_html.Element); } return false; }
double extractLengthValue(String s) #
Intended to be used to pull the value out of a CSS length. If the value is "auto" or "inherit", 0 will be returned.
@param s The CSS length string to extract @return The leading numeric portion of <code>s</code>, or 0 if "auto" or
"inherit" are passed in.
double extractLengthValue(String s) { if (s == "auto" || s == "inherit" || s == "") { return 0.0; } else { // numberRegex divides the string into a leading numeric portion // followed by an arbitrary portion. if(numberRegex.hasMatch(s)) { // Extract the leading numeric portion of string s = numberRegex.firstMatch(s)[0]; } return double.parse(s); } }
void fireEvent(DwtEvent event) #
Fires the given event to the handlers listening to the event's type.
Any exceptions thrown by handlers will be bundled into a UmbrellaException and then re-thrown after all handlers have completed. An exception thrown by a handler will not prevent other handlers from executing.
@param event the event
void fireEvent(DwtEvent event) { // if (_eventBus != null) { // _eventBus.fireEvent(event); // } if (_eventBus != null) { // If it not live we should revive it. if (!event.isLive()) { event.revive(); } Object oldSource = event.getSource(); event.overrideSource(getElement()); try { // May throw an UmbrellaException. _eventBus.fireEventFromSource(event, getElement()); } on UmbrellaException catch (e) { throw new UmbrellaException(e.causes); } finally { if (oldSource == null) { // This was my event, so I should kill it now that I'm done. event.kill(); } else { // Restoring the source for the next handler to use. event.overrideSource(oldSource); } } } }
int getAbsoluteLeft() #
Gets the object's absolute left position in pixels, as measured from the browser window's client area.
@return the object's absolute left position
int getAbsoluteLeft() { return Dom.getAbsoluteLeft(getElement()); }
int getAbsoluteTop() #
Gets the object's absolute top position in pixels, as measured from the browser window's client area.
@return the object's absolute top position
int getAbsoluteTop() { return Dom.getAbsoluteTop(getElement()); }
Element getCellElement(int row, int cell) #
Get a specific Element from the panel.
@param row the row index @param cell the cell index @return the Element at the given row and cell
dart_html.Element getCellElement(int row, int cell) { return _decPanel.getCellElement(row, cell); }
Element getContainerElement() #
Override this method to specify that an element other than the root element be the container for the panel's child widget. This can be useful when you want to create a simple panel that decorates its contents.
Note that this method continues to return the {@link com.google.gwt.user.client.Element} class defined in the <code>User</code> module to maintain backwards compatibility.
@return the element to be used as the panel's container
dart_html.Element getContainerElement() { return impl.getContainerElement(getPopupImplElement()); }
Element getElement() #
Gets this object's browser element.
dart_html.Element getElement() { assert (_element != null); // : MISSING_ELEMENT_ERROR; return _element; }
EventBus getEventBus() #
Return EventBus.
EventBus getEventBus() { return _eventBus; }
Element getGlassElement() #
Get the glass element used by this {@link PopupPanel}. The element is not created until it is enabled via {@link #setGlassEnabled(bool)}.
@return the glass element, or null if not created
dart_html.Element getGlassElement() { return glass; }
String getGlassStyleName() #
Gets the style name to be used on the glass element. By default, this is "gwt-PopupPanelGlass".
@return the glass element's style name
String getGlassStyleName() { return glassStyleName; }
Object getLayoutData() #
Gets the panel-defined layout data associated with this widget.
@return the widget's layout data @see #setLayoutData
Object getLayoutData() { return _layoutData; }
int getOffsetHeight() #
Gets the panel's offset height in pixels. Calls to {@link #setHeight(String)} before the panel's child widget is set will not influence the offset height.
@return the object's offset height
int getOffsetHeight() { return super.getOffsetHeight(); }
int getOffsetWidth() #
Gets the panel's offset width in pixels. Calls to {@link #setWidth(String)} before the panel's child widget is set will not influence the offset width.
@return the object's offset width
int getOffsetWidth() { return super.getOffsetWidth(); }
Widget getParent() #
Gets this widget's parent panel.
@return the widget's parent panel
Widget getParent() { return _parent; }
Element getPopupImplElement() #
Get the element that {@link PopupImpl} uses. PopupImpl creates an element that goes inside of the outer element, so all methods in PopupImpl are relative to the first child of the outer element, not the outer element itself.
@return the dart_html.Element that {@link PopupImpl} creates and expects
dart_html.Element getPopupImplElement() { return super.getContainerElement().firstChild; }
int getPopupLeft() #
Gets the popup's left position relative to the browser's client area.
@return the popup's left position
int getPopupLeft() { return Dom.getAbsoluteLeft(getElement()); }
int getPopupTop() #
Gets the popup's top position relative to the browser's client area.
@return the popup's top position
int getPopupTop() { return Dom.getAbsoluteTop(getElement()); }
Element getStyleElement() #
Template method that returns the element to which style names will be applied. By default it returns the root element, but this method may be overridden to apply styles to a child element.
@return the element to which style names will be applied
dart_html.Element getStyleElement() { return impl.getStyleElement(getPopupImplElement()); }
String getStyleName() #
Gets all of the object's style names, as a space-separated list. If you wish to retrieve only the primary style name, call {@link #getStylePrimaryName()}.
@return the objects's space-separated style names @see #getStylePrimaryName()
String getStyleName() { return getElementStyleName(getStyleElement()); }
String getStylePrimaryName() #
Gets the primary style name associated with the object.
@return the object's primary style name @see #setStyleName(String) @see #addStyleName(String) @see #removeStyleName(String)
String getStylePrimaryName() { return getElementStylePrimaryName(getStyleElement()); }
String getTitle() #
String getTitle() { return Dom.getElementProperty(getContainerElement(), "title"); }
Widget getWidget() #
Gets the panel's child widget.
@return the child widget, or <code>null</code> if none is present
Widget getWidget() { return _decPanel.getWidget(); }
void hide([bool autoClosed = false]) #
Hides the popup and detaches it from the page. This has no effect if it is not currently showing.
@param autoClosed the value that will be passed to
{@link CloseHandler#onClose(CloseEvent)} when the popup is closed
void hide([bool autoClosed = false]) { if (!isShowing()) { return; } resizeAnimation.setState(false, false); CloseEvent.fire(this, this, autoClosed); }
bool isAnimationEnabled() #
Returns true if animations are enabled, false if not.
bool isAnimationEnabled() { return _isAnimationEnabled; }
bool isAttached() #
Returns whether or not the receiver is attached to the {@link com.google.gwt.dom.client.Document Document}'s {@link com.google.gwt.dom.client.BodyElement BodyElement}.
@return true if attached, false otherwise
bool isAttached() { return _attached; }
bool isAutoHideEnabled() #
Returns <code>true</code> if the popup should be automatically hidden when the user clicks outside of it.
@return true if autoHide is enabled, false if disabled
bool isAutoHideEnabled() { return autoHide; }
bool isAutoHideOnHistoryEventsEnabled() #
Returns <code>true</code> if the popup should be automatically hidden when the history token changes, such as when the user presses the browser's back button.
@return true if enabled, false if disabled
bool isAutoHideOnHistoryEventsEnabled() { return autoHideOnHistoryEvents; }
bool isGlassEnabled() #
Returns <code>true</code> if a glass element will be displayed under the {@link PopupPanel}.
@return true if enabled
bool isGlassEnabled() { return _isGlassEnabled; }
bool isModal() #
Returns <code>true</code> if keyboard or mouse events that do not target the PopupPanel or its children should be ignored.
@return true if popup is modal, false if not
bool isModal() { return modal; }
bool isOrWasAttached() #
Has this widget ever been attached?
@return true if this widget ever been attached to the DOM, false otherwise
bool isOrWasAttached() { return eventsToSink == -1; }
bool isPreviewingAllNativeEvents() #
Returns <code>true</code> if the popup should preview all events, even if the event has already been consumed by another popup.
@return true if previewAllNativeEvents is enabled, false if disabled
bool isPreviewingAllNativeEvents() { return previewAllNativeEvents; }
bool isShowing() #
Determines whether or not this popup is showing.
@return <code>true</code> if the popup is showing @see #show() @see #hide()
bool isShowing() { return showing; }
Iterator<Widget> iterator() #
Returns an Iterator that iterates over this Iterable object.
Iterator<Widget> iterator() { return _decPanel.iterator(); }
void maybeUpdateSize() #
We control size by setting our child widget's size. However, if we don't currently have a child, we record the size the user wanted so that when we do get a child, we can set it correctly. Until size is explicitly cleared, any child put into the popup will be given that size.
void maybeUpdateSize() { // For subclasses of PopupPanel, we want the default behavior of setWidth // and setHeight to change the dimensions of PopupPanel's child widget. // We do this because PopupPanel's child widget is the first widget in // the hierarchy which provides structure to the panel. DialogBox is // an example of this. We want to set the dimensions on DialogBox's // FlexTable, which is PopupPanel's child widget. However, it is not // DialogBox's child widget. To make sure that we are actually getting // PopupPanel's child widget, we have to use super.getWidget(). Widget w = super.getWidget(); if (w != null) { if (desiredHeight != null) { w.setHeight(desiredHeight); } if (desiredWidth != null) { w.setWidth(desiredWidth); } } }
void onAttach() #
This method is called when a widget is attached to the browser's document. To receive notification after a Widget has been added to the document, override the {@link #onLoad} method or use {@link #addAttachHandler}.
It is strongly recommended that you override {@link #onLoad()} or {@link #doAttachChildren()} instead of this method to avoid inconsistencies between logical and physical attachment states.
Subclasses that override this method must call
super.onAttach()
to ensure that the Widget has been attached
to its underlying Element.
@throws IllegalStateException if this widget is already attached @see #onLoad() @see #doAttachChildren()
void onAttach() { if (isAttached()) { throw new Exception("Should only call onAttach when the widget is detached from the browser's document"); } _attached = true; // Event hookup code Dom.setEventListener(getElement(), this); int bitsToAdd = eventsToSink; eventsToSink = -1; if (bitsToAdd > 0) { sinkEvents(bitsToAdd); } doAttachChildren(); // onLoad() gets called only *after* all of the children are attached and // the attached flag is set. This allows widgets to be notified when they // are fully attached, and panels when all of their children are attached. onLoad(); AttachEvent.fire(this, true); }
void onBrowserEvent(Event event) #
Fired whenever a browser event is received.
@param event the event received
TODO
void onBrowserEvent(dart_html.Event event) { switch (Dom.eventGetType(event)) { case IEvent.ONMOUSEOVER: // Only fire the mouse over event if it's coming from outside this // widget. case IEvent.ONMOUSEOUT: // Only fire the mouse over event if it's coming from outside this widget. // Only fire the mouse out event if it's leaving this widget. dart_html.Element related = (event as dart_html.MouseEvent).relatedTarget as dart_html.Element; if (related != null && Dom.isOrHasChild(getElement(), related)) { return; } break; } DomEvent.fireNativeEvent(event, this, this.getElement()); }
void onDetach() #
This method is called when a widget is detached from the browser's document. To receive notification before a Widget is removed from the document, override the {@link #onUnload} method or use {@link #addAttachHandler}.
It is strongly recommended that you override {@link #onUnload()} or {@link #doDetachChildren()} instead of this method to avoid inconsistencies between logical and physical attachment states.
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
@throws IllegalStateException if this widget is already detached @see #onUnload() @see #doDetachChildren()
void onDetach() { if (!isAttached()) { throw new Exception("Should only call onDetach when the widget is attached to the browser's document"); } try { // onUnload() gets called *before* everything else (the opposite of // onLoad()). onUnload(); AttachEvent.fire(this, false); } finally { // Put this in a finally, just in case onUnload throws an exception. try { doDetachChildren(); } finally { // Put this in a finally, in case doDetachChildren throws an exception. Dom.setEventListener(getElement(), null); _attached = false; } } }
bool onEventPreview(NativePreviewEvent event) #
@deprecated Use {@link #onPreviewNativeEvent} instead
bool onEventPreview(NativePreviewEvent event) { return true; }
void onLoad() #
This method is called immediately after a widget becomes attached to the browser's document.
void onLoad() { }
void onPreviewNativeEvent(NativePreviewEvent event) #
void onPreviewNativeEvent(NativePreviewEvent event) { // Cancel the event based on the deprecated onEventPreview() method if (event.isFirstHandler() && !onEventPreview(event)) { event.cancel(); } }
void onUnload() #
This method is called immediately before a widget will be detached from the browser's document.
void onUnload() { super.onUnload(); // Just to be sure, we perform cleanup when the popup is unloaded (i.e. // removed from the Dom). This is normally taken care of in hide(), but it // can be missed if someone removes the popup directly from the RootPanel. if (isShowing()) { resizeAnimation.setState(false, true); } }
void orphan(Widget child) #
This method must be called as part of the remove method of any Panel. It ensures that the Widget's parent is cleared. This method should be called after verifying that the child Widget is an existing child of the Panel, but before physically removing the child Widget from the DOM. The child will now fire its {@link Widget#onDetach()} event if this Panel is currently attached.
Calls to {@link #orphan(Widget)} should be wrapped in a try/finally block to ensure that the widget is physically detached even if orphan throws an exception.
@param child the widget to be disowned @see #add(Widget)
void orphan(Widget child) { assert (child.getParent() == this); child.setParent(null); }
void position(UiObject relativeObject, int offsetWidth, int offsetHeight) #
Positions the popup, called after the offset width and height of the popup are known.
@param relativeObject the ui object to position relative to @param offsetWidth the drop down's offset width @param offsetHeight the drop down's offset height
void position(final UiObject relativeObject, int offsetWidth, int offsetHeight) { // Calculate left position for the popup. The computation for // the left position is bidi-sensitive. int textBoxOffsetWidth = relativeObject.getOffsetWidth(); // Compute the difference between the popup's width and the // textbox's width int offsetWidthDiff = offsetWidth - textBoxOffsetWidth; int left; if (LocaleInfo.getCurrentLocale().isRTL()) { // RTL case int textBoxAbsoluteLeft = relativeObject.getAbsoluteLeft(); // Right-align the popup. Note that this computation is // valid in the case where offsetWidthDiff is negative. left = textBoxAbsoluteLeft - offsetWidthDiff; // If the suggestion popup is not as wide as the text box, always // align to the right edge of the text box. Otherwise, figure out whether // to right-align or left-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Dom.getClientWidth() + Dom.getScrollLeft(); int windowLeft = Dom.getScrollLeft(); // Compute the left value for the right edge of the textbox int textBoxLeftValForRightEdge = textBoxAbsoluteLeft + textBoxOffsetWidth; // Distance from the right edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - textBoxLeftValForRightEdge; // Distance from the right edge of the text box to the left edge of the // window int distanceFromWindowLeft = textBoxLeftValForRightEdge - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of the text box and there IS enough space for the // overflow to the right of the text box, then left-align the popup. // However, if there is not enough space on either side, stick with // right-alignment. if (distanceFromWindowLeft < offsetWidth && distanceToWindowRight >= offsetWidthDiff) { // Align with the left edge of the text box. left = textBoxAbsoluteLeft; } } } else { // LTR case // Left-align the popup. left = relativeObject.getAbsoluteLeft(); // If the suggestion popup is not as wide as the text box, always align to // the left edge of the text box. Otherwise, figure out whether to // left-align or right-align the popup. if (offsetWidthDiff > 0) { // Make sure scrolling is taken into account, since // box.getAbsoluteLeft() takes scrolling into account. int windowRight = Dom.getClientWidth() + Dom.getScrollLeft(); int windowLeft = Dom.getScrollLeft(); // Distance from the left edge of the text box to the right edge // of the window int distanceToWindowRight = windowRight - left; // Distance from the left edge of the text box to the left edge of the // window int distanceFromWindowLeft = left - windowLeft; // If there is not enough space for the overflow of the popup's // width to the right of hte text box, and there IS enough space for the // overflow to the left of the text box, then right-align the popup. // However, if there is not enough space on either side, then stick with // left-alignment. if (distanceToWindowRight < offsetWidth && distanceFromWindowLeft >= offsetWidthDiff) { // Align with the right edge of the text box. left -= offsetWidthDiff; } } } // Calculate top position for the popup int top = relativeObject.getAbsoluteTop(); // Make sure scrolling is taken into account, since // box.getAbsoluteTop() takes scrolling into account. int windowTop = Dom.getScrollTop(); int windowBottom = Dom.getScrollTop() + Dom.getClientHeight(); // Distance from the top edge of the window to the top edge of the // text box int distanceFromWindowTop = top - windowTop; // Distance from the bottom edge of the window to the bottom edge of // the text box int distanceToWindowBottom = windowBottom - (top + relativeObject.getOffsetHeight()); // If there is not enough space for the popup's height below the text // box and there IS enough space for the popup's height above the text // box, then then position the popup above the text box. However, if there // is not enough space on either side, then stick with displaying the // popup below the text box. if (distanceToWindowBottom < offsetHeight && distanceFromWindowTop >= offsetHeight) { top -= offsetHeight; } else { // Position above the text box top += relativeObject.getOffsetHeight(); } setPopupPosition(left, top); }
void previewNativeEvent(NativePreviewEvent event) #
Preview the {@link dart_html.Event}.
@param event the {@link dart_html.Event}
void previewNativeEvent(NativePreviewEvent event) { // If the event has been canceled or consumed, ignore it if (event.isCanceled() || (!previewAllNativeEvents && event.isConsumed())) { // We need to ensure that we cancel the event even if its been consumed so // that popups lower on the stack do not auto hide if (modal) { event.cancel(); } return; } // Fire the event hook and return if the event is canceled onPreviewNativeEvent(event); if (event.isCanceled()) { return; } // If the event targets the popup or the partner, consume it dart_html.Event nativeEvent = event.getNativeEvent(); bool eventTargetsPopupOrPartner = eventTargetsPopup(nativeEvent) || eventTargetsPartner(nativeEvent); if (eventTargetsPopupOrPartner) { event.consume(); } // Cancel the event if it doesn't target the modal popup. Note that the // event can be both canceled and consumed. if (modal) { event.cancel(); } // Switch on the event type int type = IEvent.getTypeInt(nativeEvent.type); switch (type) { // case IEvent.ONKEYDOWN: // if (!onKeyDownPreview((char) nativeEvent.getKeyCode(), // KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) { // event.cancel(); // } // return; // case IEvent.ONKEYUP: // if (!onKeyUpPreview((char) nativeEvent.getKeyCode(), // KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) { // event.cancel(); // } // return; // case IEvent.ONKEYPRESS: // if (!onKeyPressPreview((char) nativeEvent.getKeyCode(), // KeyboardListenerCollection.getKeyboardModifiers(nativeEvent))) { // event.cancel(); // } // return; // case IEvent.ONMOUSEDOWN: // Don't eat events if event capture is enabled, as this can // interfere with dialog dragging, for example. if (Dom.getCaptureElement() != null) { event.consume(); return; } if (!eventTargetsPopupOrPartner && autoHide) { hide(true); return; } break; case IEvent.ONMOUSEUP: case IEvent.ONMOUSEMOVE: case IEvent.ONCLICK: case IEvent.ONDBLCLICK: // Don't eat events if event capture is enabled, as this can // interfere with dialog dragging, for example. if (Dom.getCaptureElement() != null) { event.consume(); return; } break; case IEvent.ONFOCUS: dart_html.Element target = nativeEvent.target as dart_html.Element; if (modal && !eventTargetsPopupOrPartner && (target != null)) { blur(target); event.cancel(); return; } break; } }
bool remove(Widget w) #
Removes a child widget.
How to Override this Method
There are several important things that must take place in the correct order to properly remove a Widget from a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
- Validate: Make sure this Panel is actually the parent of the
child Widget; return
false
if it is not. - Orphan: Call {@link #orphan(Widget)} first while the child Widget is still attached.
- Physical Detach: Adjust the DOM to account for the removal of the child Widget. The Widget's Element must be physically removed from the DOM.
- Logical Detach: Update the Panel's state variables to reflect the removal of the child Widget. Example: the Widget is removed from the Panel's {@link WidgetCollection}.
@param child the widget to be removed @return <code>true</code> if the child was present
bool remove(Widget w) { return _decPanel.remove(w); }
void removeAutoHidePartner(Element partner) #
Remove an autoHide partner.
@param partner the auto hide partner to remove
void removeAutoHidePartner(dart_html.Element partner) { assert (partner != null); // : "partner cannot be null"; if (autoHidePartners != null) { //autoHidePartners.remove(partner); partner.remove(); } }
void removeFromParent() #
Removes this widget from its parent widget, if one exists.
If it has no parent, this method does nothing. If it is a "root" widget (meaning it's been added to the detach list via {@link RootPanel#detachOnWindowClose(Widget)}), it will be removed from the detached immediately. This makes it possible for Composites and Panels to adopt root widgets.
@throws IllegalStateException if this widget's parent does not support
removal (e.g. {@link Composite})
void removeFromParent() { if (_parent == null) { // If the widget had no parent, check to see if it was in the detach list // and remove it if necessary. if (RootPanel.isInDetachList(this)) { RootPanel.detachNow(this); } } else if (_parent is HasWidgets) { (_parent as HasWidgets).remove(this); } else if (_parent != null) { throw new Exception("This widget's parent does not implement HasWidgets"); } }
bool removeIsWidget(IsWidget child) #
bool removeIsWidget(IsWidget child) { return remove(Widget.asWidgetOrNull(child)); }
void removeStyleDependentName(String styleSuffix) #
Removes a dependent style name by specifying the style name's suffix.
@param styleSuffix the suffix of the dependent style to be removed @see #setStylePrimaryName(Element, String) @see #addStyleDependentName(String) @see #setStyleDependentName(String, boolean)
void removeStyleDependentName(String styleSuffix) { setStyleDependentName(styleSuffix, false); }
void removeStyleName(String style) #
Removes a style name. This method is typically used to remove secondary style names, but it can be used to remove primary stylenames as well. That use is not recommended.
@param style the secondary style name to be removed @see #addStyleName(String) @see #setStyleName(String, boolean)
void removeStyleName(String style) { setStyleName(style, false); }
void replaceElement(Element elem) #
Replaces this object's browser element.
This method exists only to support a specific use-case in Image, and should not be used by other classes.
@param elem the object's new element
void replaceElement(dart_html.Element elem) { if (isAttached()) { // Remove old event listener to avoid leaking. onDetach will not do this // for us, because it is only called when the widget itself is detached // from the document. Dom.setEventListener(getElement(), null); } super.replaceElement(elem); if (isAttached()) { // Hook the event listener back up on the new element. onAttach will not // do this for us, because it is only called when the widget itself is // attached to the document. Dom.setEventListener(getElement(), this); } }
void setAnimation(ResizeAnimation animation) #
Sets the animation used to animate this popup. Used by gwt-incubator to allow DropDownPanel to override the default popup animation. Not protected because the exact API may change in gwt 1.6.
@param animation the animation to use for this popup
void setAnimation(ResizeAnimation animation) { resizeAnimation = animation; }
void setAnimationEnabled(bool enable) #
Enable or disable animations.
@param enable true to enable, false to disable
void setAnimationEnabled(bool enable) { _isAnimationEnabled = enable; }
void setAnimationType(AnimationType type) #
Enable or disable animation of the {@link PopupPanel}.
@param type the type of animation to use
void setAnimationType(AnimationType type) { animType = type; }
void setAutoHideEnabled(bool autoHide) #
Enable or disable the autoHide feature. When enabled, the popup will be automatically hidden when the user clicks outside of it.
@param autoHide true to enable autoHide, false to disable
void setAutoHideEnabled(bool autoHide) { this.autoHide = autoHide; }
void setAutoHideOnHistoryEventsEnabled(bool enabled) #
Enable or disable autoHide on history change events. When enabled, the popup will be automatically hidden when the history token changes, such as when the user presses the browser's back button. Disabled by default.
@param enabled true to enable, false to disable
void setAutoHideOnHistoryEventsEnabled(bool enabled) { this.autoHideOnHistoryEvents = enabled; }
void setElement(Element elem) #
Sets this object's browser element. UIObject subclasses must call this method before attempting to call any other methods, and it may only be called once.
@param elem the object's element
void setElement(dart_html.Element elem) { assert (_element == null); this._element = elem; }
void setGlassEnabled(bool enabled) #
When enabled, the background will be blocked with a semi-transparent pane the next time it is shown. If the PopupPanel is already visible, the glass will not be displayed until it is hidden and shown again.
@param enabled true to enable, false to disable
void setGlassEnabled(bool enabled) { this._isGlassEnabled = enabled; if (enabled && glass == null) { glass = new dart_html.DivElement(); glass.className = glassStyleName; glass.style.position = Position.ABSOLUTE.value; glass.style.left = "0" + Unit.PX.value; glass.style.top = "0" + Unit.PX.value; } }
void setGlassStyleName(String glassStyleName) #
Sets the style name to be used on the glass element. By default, this is "gwt-PopupPanelGlass".
@param glassStyleName the glass element's style name
void setGlassStyleName(String glassStyleName) { this.glassStyleName = glassStyleName; if (glass != null) { glass.className = glassStyleName; } }
void setHeight(String height) #
Sets the height of the panel's child widget. If the panel's child widget has not been set, the height passed in will be cached and used to set the height immediately after the child widget is set.
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.
@param height the object's new height, in CSS units (e.g. "10px", "1em")
void setHeight(String height) { desiredHeight = height; maybeUpdateSize(); // If the user cleared the size, revert to not trying to control children. if (height.length == 0) { desiredHeight = null; } }
void setLayoutData(Object value) #
Sets the panel-defined layout data associated with this widget. Only the panel that currently contains a widget should ever set this value. It serves as a place to store layout bookkeeping data associated with a widget.
@param layoutData the widget's layout data
void setLayoutData(Object value) { this._layoutData = value; }
void setModal(bool modal) #
When the popup is modal, keyboard or mouse events that do not target the PopupPanel or its children will be ignored.
@param modal true to make the popup modal
void setModal(bool modal) { this.modal = modal; }
void setParent(Widget parent) #
Sets this widget's parent. This method should only be called by {@link Panel} and {@link Composite}.
@param parent the widget's new parent @throws IllegalStateException if <code>parent</code> is non-null and the
widget already has a parent
void setParent(Widget parent) { Widget oldParent = this._parent; if (parent == null) { try { if (oldParent != null && oldParent.isAttached()) { onDetach(); assert (!isAttached()); // : "Failure of " + this.getClass().getName() + " to call super.onDetach()"; } } finally { // Put this in a finally in case onDetach throws an exception. this._parent = null; } } else { if (oldParent != null) { throw new Exception("Cannot set a new parent without first clearing the old parent"); } this._parent = parent; if (parent.isAttached()) { onAttach(); assert (isAttached()); // : "Failure of " + this.getClass().getName() + " to call super.onAttach()"; } } }
void setPixelSize(int width, int height) #
Sets the object's size, in pixels, not including decorations such as border, margin, and padding.
@param width the object's new width, in pixels @param height the object's new height, in pixels
void setPixelSize(int width, int height) { if (width >= 0) { setWidth(width.toString() + "px"); } if (height >= 0) { setHeight(height.toString() + "px"); } }
void setPopupPosition(int left, int top) #
Sets the popup's position relative to the browser's client area. The popup's position may be set before calling {@link #show()}.
@param left the left position, in pixels @param top the top position, in pixels
void setPopupPosition(int left, int top) { // Save the position of the popup leftPosition = left; topPosition = top; // Account for the difference between absolute position and the // body's positioning context. left -= dart_html.document.body.offset.left; top -= dart_html.document.body.offset.top; // Set the popup's position manually, allowing setPopupPosition() to be // called before show() is called (so a popup can be positioned without it // 'jumping' on the screen). dart_html.Element elem = getElement(); elem.style.left = left.toString() + Unit.PX.value; elem.style.top = top.toString() + Unit.PX.value; }
void setPopupPositionAndShow(PopupPanelPositionCallback callback) #
Sets the popup's position using a {@link 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 the popup will not jump from its original position to the new position.
@param callback the callback to set the position of the popup @see PositionCallback#setPosition(int offsetWidth, int offsetHeight)
void setPopupPositionAndShow(PopupPanelPositionCallback callback) { visible = false; show(); callback.setPosition(getOffsetWidth(), getOffsetHeight()); visible = true; }
void setPreviewingAllNativeEvents(bool previewAllNativeEvents) #
When enabled, the popup will preview all 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.
@param previewAllNativeEvents true to enable, false to disable
void setPreviewingAllNativeEvents(bool previewAllNativeEvents) { this.previewAllNativeEvents = previewAllNativeEvents; }
void setSize(String width, String height) #
Sets the object's size. This size does not include decorations such as border, margin, and padding.
@param width the object's new width, in CSS units (e.g. "10px", "1em") @param height the object's new height, in CSS units (e.g. "10px", "1em")
void setSize(String width, String height) { setWidth(width); setHeight(height); }
void setStyleDependentName(String styleSuffix, bool add) #
Adds or removes a dependent style name by specifying the style name's suffix. The actual form of the style name that is added is:
getStylePrimaryName() + '-' + styleSuffix
@param styleSuffix the suffix of the dependent style to be added or removed @param add <code>true</code> to add the given style, <code>false</code> to
remove it
@see #setStylePrimaryName(Element, String) @see #addStyleDependentName(String) @see #setStyleName(String, boolean) @see #removeStyleDependentName(String)
void setStyleDependentName(String styleSuffix, bool add) { setStyleName(getStylePrimaryName() + '-' + styleSuffix, add); }
void setStyleName(String style, bool add) #
Adds or removes a style name. This method is typically used to remove secondary style names, but it can be used to remove primary stylenames as well. That use is not recommended.
@param style the style name to be added or removed @param add <code>true</code> to add the given style, <code>false</code> to
remove it
@see #addStyleName(String) @see #removeStyleName(String)
void setStyleName(String style, bool add) { manageElementStyleName(getStyleElement(), style, add); }
void setStylePrimaryName(String style) #
Sets the object's primary style name and updates all dependent style names.
@param style the new primary style name @see #addStyleName(String) @see #removeStyleName(String)
void setStylePrimaryName(String style) { setElementStylePrimaryName(getStyleElement(), style); }
void setTitle(String title) #
void setTitle(String title) { dart_html.Element containerElement = getContainerElement(); if (title == null || title.length == 0) { containerElement.attributes.remove("title"); } else { containerElement.title = title; } }
void setWidget(Widget w) #
Sets this panel's widget. Any existing child widget will be removed.
@param w the panel's new widget, or <code>null</code> to clear the panel
void setWidget(Widget w) { _decPanel.setWidget(w); maybeUpdateSize(); }
void setWidgetIsWidget(IsWidget w) #
Set the only widget of the receiver, replacing the previous widget if there was one.
@param w the widget, or <code>null</code> to remove the widget
@see SimplePanel
void setWidgetIsWidget(IsWidget w) { setWidget(Widget.asWidgetOrNull(w)); }
void setWidth(String width) #
Sets the width of the panel's child widget. If the panel's child widget has not been set, the width passed in will be cached and used to set the width immediately after the child widget is set.
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.
@param width the object's new width, in CSS units (e.g. "10px", "1em")
void setWidth(String width) { desiredWidth = width; maybeUpdateSize(); // If the user cleared the size, revert to not trying to control children. if (width.length == 0) { desiredWidth = null; } }
void show() #
Shows the popup and attach it to the page. It must have a child widget before this method is called.
void show() { if (showing) { return; } else if (isAttached()) { // The popup is attached directly to another panel, so we need to remove // it from its parent before showing it. This is a weird use case, but // since PopupPanel is a Widget, its legal. this.removeFromParent(); } resizeAnimation.setState(true, false); }
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. Depending on the width and height of the popup and the distance from the target to the bottom and right edges of the window, the popup may be displayed directly above the target, and/or its right edge may be aligned with the right edge of the target.
@param target the target to show the popup below
void showRelativeTo(UiObject target) { // Set the position of the popup right before it is shown. setPopupPositionAndShow(new ShowPositionCallback(this, target)); }
void sinkBitlessEvent(String eventTypeName) #
Sinks a named event. Note that only {@link Widget widgets} may actually receive events, but can receive events from all objects contained within them.
@param eventTypeName name of the event to sink on this element @see com.google.gwt.user.client.Event
void sinkBitlessEvent(String eventTypeName) { Dom.sinkBitlessEvent(getElement(), eventTypeName); }
void sinkEvents(int eventBitsToAdd) #
Overridden to defer the call to super.sinkEvents until the first time this widget is attached to the dom, as a performance enhancement. Subclasses wishing to customize sinkEvents can preserve this deferred sink behavior by putting their implementation behind a check of <code>isOrWasAttached()</code>:
{@literal @}Override public void sinkEvents(int eventBitsToAdd) { if (isOrWasAttached()) { /{@literal *} customized sink code goes here {@literal *}/ } else { super.sinkEvents(eventBitsToAdd); } }
void sinkEvents(int eventBitsToAdd) { if (isOrWasAttached()) { super.sinkEvents(eventsToSink); } else { eventsToSink |= eventBitsToAdd; } }
String toString() #
This method is overridden so that any object can be viewed in the debugger as an HTML snippet.
@return a string representation of the object
String toString() { if (_element == null) { return "(null handle)"; } return getElement().toString(); }
void unsinkEvents(int eventBitsToRemove) #
Removes a set of events from this object's event list.
@param eventBitsToRemove a bitfield representing the set of events to be
removed from this element's event set
@see #sinkEvents @see com.google.gwt.user.client.Event
void unsinkEvents(int eventBitsToRemove) { Dom.sinkEvents(getElement(), Dom.getEventsSunk(getElement()) & (~eventBitsToRemove)); }
void updateHandlers() #
Register or unregister the handlers used by {@link PopupPanel}.
void updateHandlers() { // Remove any existing handlers. if (nativePreviewHandlerRegistration != null) { nativePreviewHandlerRegistration.removeHandler(); nativePreviewHandlerRegistration = null; } if (historyHandlerRegistration != null) { historyHandlerRegistration.removeHandler(); historyHandlerRegistration = null; } // Create handlers if showing. if (showing) { nativePreviewHandlerRegistration = IEvent.addNativePreviewHandler(new NativePreviewHandlerAdapter((NativePreviewEvent event) { previewNativeEvent(event); })); historyHandlerRegistration = History.addValueChangeHandler(new HistoryValueChangeHandler(this)); } }