public class Widget extends UIObject implements EventListener, HasAttachHandlers, IsWidget
panels.UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled| Modifier and Type | Field and Description | 
|---|---|
| (package private) int | eventsToSinkA bit-map of the events that should be sunk when the widget is attached to
 the DOM. | 
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR| Constructor and Description | 
|---|
| Widget() | 
| Modifier and Type | Method and Description | 
|---|---|
| HandlerRegistration | addAttachHandler(AttachEvent.Handler handler)Adds an  AttachEventhandler. | 
| <H extends EventHandler> | addBitlessDomHandler(H handler,
                    DomEvent.Type<H> type)For browsers which do not leak, adds a native event handler to the widget. | 
| <H extends EventHandler> | addDomHandler(H handler,
             DomEvent.Type<H> type)Adds a native event handler to the widget and sinks the corresponding
 native event. | 
| <H extends EventHandler> | addHandler(H handler,
          GwtEvent.Type<H> type)Adds this handler to the widget. | 
| Widget | asWidget()Returns the  Widgetaspect of the receiver. | 
| static Widget | asWidgetOrNull(IsWidget w)This convenience method makes a null-safe call to
  IsWidget.asWidget(). | 
| protected HandlerManager | createHandlerManager()Creates the  HandlerManagerused by this Widget. | 
| protected void | delegateEvent(Widget target,
             GwtEvent<?> event)Fires an event on a child widget. | 
| protected 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  onAttach()for each of its
 child widgets. | 
| protected 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  onDetach()for each of its
 child widgets. | 
| (package private) HandlerManager | ensureHandlers()Ensures the existence of the handler manager. | 
| void | fireEvent(GwtEvent<?> event)Fires the given event to the handlers listening to the event's type. | 
| protected int | getHandlerCount(GwtEvent.Type<?> type)Gets the number of handlers listening to the event type. | 
| (package private) HandlerManager | getHandlerManager() | 
| java.lang.Object | getLayoutData()Gets the panel-defined layout data associated with this widget. | 
| Widget | getParent()Gets this widget's parent panel. | 
| boolean | isAttached()Determines whether this widget is currently attached to the browser's
 document (i.e., there is an unbroken chain of widgets between this widget
 and the underlying browser document). | 
| protected boolean | isOrWasAttached()Has this widget ever been attached? | 
| protected void | onAttach()
 This method is called when a widget is attached to the browser's document. | 
| void | onBrowserEvent(Event event)Fired whenever a browser event is received. | 
| protected void | onDetach()
 This method is called when a widget is detached from the browser's
 document. | 
| protected void | onLoad()This method is called immediately after a widget becomes attached to the
 browser's document. | 
| protected void | onUnload()This method is called immediately before a widget will be detached from the
 browser's document. | 
| void | removeFromParent()Removes this widget from its parent widget, if one exists. | 
| (package private) void | replaceElement(Element elem)Replaces this object's browser element. | 
| void | setLayoutData(java.lang.Object layoutData)Sets the panel-defined layout data associated with this widget. | 
| (package private) void | setParent(Widget parent)Sets this widget's parent. | 
| 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. | 
| void | unsinkEvents(int eventBitsToRemove)Removes a set of events from this object's event list. | 
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringint eventsToSink
Package protected to allow Composite to see it.
public static Widget asWidgetOrNull(IsWidget w)
IsWidget.asWidget().null if w is nullpublic HandlerRegistration addAttachHandler(AttachEvent.Handler handler)
HasAttachHandlersAttachEvent handler.addAttachHandler in interface HasAttachHandlershandler - the handlerpublic final <H extends EventHandler> HandlerRegistration addBitlessDomHandler(H handler, DomEvent.Type<H> type)
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.H - the type of handler to addtype - the event keyhandler - the handlerHandlerRegistration used to remove the handlerpublic final <H extends EventHandler> HandlerRegistration addDomHandler(H handler, DomEvent.Type<H> type)
H - the type of handler to addtype - the event keyhandler - the handlerHandlerRegistration used to remove the handlerpublic final <H extends EventHandler> HandlerRegistration addHandler(H handler, GwtEvent.Type<H> type)
H - the type of handler to addtype - the event typehandler - the handlerHandlerRegistration used to remove the handlerpublic Widget asWidget()
IsWidgetWidget aspect of the receiver.public void fireEvent(GwtEvent<?> event)
HasHandlers
 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.
fireEvent in interface HasHandlersevent - the eventpublic java.lang.Object getLayoutData()
setLayoutData(java.lang.Object)public Widget getParent()
public boolean isAttached()
isAttached in interface HasAttachHandlerstrue if the widget is attachedpublic void onBrowserEvent(Event event)
EventListeneronBrowserEvent in interface EventListenerevent - the event receivedpublic void removeFromParent()
 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
 RootPanel.detachOnWindowClose(Widget)), it will be removed from the
 detached immediately. This makes it possible for Composites and Panels to
 adopt root widgets.
 
java.lang.IllegalStateException - if this widget's parent does not support
           removal (e.g. Composite)public void setLayoutData(java.lang.Object layoutData)
layoutData - the widget's layout datapublic void sinkEvents(int eventBitsToAdd)
isOrWasAttached():
 
  @Override
 public void sinkEvents(int eventBitsToAdd) {
   if (isOrWasAttached()) {
     / * customized sink code goes here  */
   } else {
     super.sinkEvents(eventBitsToAdd);
  }
} sinkEvents in class UIObjecteventBitsToAdd - a bitfield representing the set of events to be added
          to this element's event setEventpublic void unsinkEvents(int eventBitsToRemove)
UIObjectunsinkEvents in class UIObjecteventBitsToRemove - a bitfield representing the set of events to be
          removed from this element's event setUIObject.sinkEvents(int), 
Eventprotected HandlerManager createHandlerManager()
HandlerManager used by this Widget. You can override
 this method to create a custom HandlerManager.HandlerManager you want to useprotected void delegateEvent(Widget target, GwtEvent<?> event)
event - the eventtarget - fire the event on the given targetprotected void doAttachChildren()
onAttach() for each of its
 child widgets.onAttach()protected void doDetachChildren()
onDetach() for each of its
 child widgets.onDetach()protected int getHandlerCount(GwtEvent.Type<?> type)
type - the event typeprotected final boolean isOrWasAttached()
protected 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 onLoad() method or use addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler).
 
 It is strongly recommended that you override onLoad() or
 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.
 
java.lang.IllegalStateException - if this widget is already attachedonLoad(), 
doAttachChildren()protected 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 onUnload() method or use addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler).
 
 It is strongly recommended that you override onUnload() or
 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.
 
java.lang.IllegalStateException - if this widget is already detachedonUnload(), 
doDetachChildren()protected void onLoad()
protected void onUnload()
HandlerManager ensureHandlers()
HandlerManager getHandlerManager()
void replaceElement(Element elem)
UIObjectreplaceElement in class UIObjectelem - the object's new elementvoid setParent(Widget parent)
parent - the widget's new parentjava.lang.IllegalStateException - if parent is non-null and the
           widget already has a parent