|
GWT 2.0.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
public class Widget
The base class for the majority of user-interface objects. Widget adds
support for receiving events from the browser and being added directly to
panels
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject |
---|
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled |
Field Summary |
---|
Fields inherited from class com.google.gwt.user.client.ui.UIObject |
---|
DEBUG_ID_PREFIX |
Constructor Summary | |
---|---|
Widget()
|
Method Summary | ||
---|---|---|
protected
|
addDomHandler(H handler,
DomEvent.Type<H> type)
Adds a native event handler to the widget and sinks the corresponding native event. |
|
protected
|
addHandler(H handler,
GwtEvent.Type<H> type)
Adds this handler to the 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. |
|
void |
fireEvent(GwtEvent<?> event)
Fires the given event to all the appropriate handlers. |
|
protected int |
getHandlerCount(GwtEvent.Type<?> type)
Gets the number of handlers listening to the event type. |
|
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. |
|
void |
setLayoutData(java.lang.Object layoutData)
Sets the panel-defined layout data associated with this widget. |
|
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. |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Widget()
Method Detail |
---|
public void fireEvent(GwtEvent<?> event)
HasHandlers
fireEvent
in interface HasHandlers
event
- the event to be firedpublic java.lang.Object getLayoutData()
setLayoutData(java.lang.Object)
public Widget getParent()
public boolean isAttached()
true
if the widget is attachedpublic void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
event
- 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 UIObject
eventBitsToAdd
- a bitfield representing the set of events to be added
to this element's event setEvent
protected final <H extends EventHandler> HandlerRegistration addDomHandler(H handler, DomEvent.Type<H> type)
H
- the type of handler to addtype
- the event keyhandler
- the handler
HandlerRegistration
used to remove the handlerprotected final <H extends EventHandler> HandlerRegistration addHandler(H handler, GwtEvent.Type<H> type)
H
- the type of handler to addtype
- the event typehandler
- the handler
HandlerRegistration
used to remove the handlerprotected 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 type
protected 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.
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.
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()
|
GWT 2.0.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |