Package com.google.gwt.user.client.ui
Class LazyPanel
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- com.google.gwt.user.client.ui.Panel
-
- com.google.gwt.user.client.ui.SimplePanel
-
- com.google.gwt.user.client.ui.LazyPanel
-
- All Implemented Interfaces:
HasAttachHandlers
,HasHandlers
,EventListener
,AcceptsOneWidget
,HasOneWidget
,HasVisibility
,HasWidgets
,HasWidgets.ForIsWidget
,IsWidget
,java.lang.Iterable<Widget>
public abstract class LazyPanel extends SimplePanel
Convenience class to help lazy loading. The bulk of a LazyPanel is not instantiated untilsetVisible(boolean)
(true) orensureWidget()
is called.Example
public class LazyPanelExample implements EntryPoint { private static class HelloLazyPanel extends LazyPanel { @Override protected Widget createWidget() { return new Label("Well hello there!"); } } public void onModuleLoad() { final Widget lazy = new HelloLazyPanel(); // Not strictly necessary, but keeps the empty outer div // from effecting layout before it is of any use lazy.setVisible(false); PushButton b = new PushButton("Click me"); b.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { lazy.setVisible(true); } }); RootPanel root = RootPanel.get(); root.add(b); root.add(lazy); } }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
-
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
HasWidgets.ForIsWidget
-
-
Field Summary
-
Fields inherited from class com.google.gwt.user.client.ui.SimplePanel
widget
-
Fields inherited from class com.google.gwt.user.client.ui.Widget
eventsToSink
-
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR
-
-
Constructor Summary
Constructors Constructor Description LazyPanel()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract Widget
createWidget()
Create the widget contained within theLazyPanel
.void
ensureWidget()
Ensures that the widget has been created by callingcreateWidget()
ifSimplePanel.getWidget()
returnsnull
.void
setVisible(boolean visible)
Sets whether this object is visible.-
Methods inherited from class com.google.gwt.user.client.ui.SimplePanel
add, getContainerElement, getWidget, iterator, remove, setWidget, setWidget
-
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, clear, doAttachChildren, doDetachChildren, orphan, remove
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents
-
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, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setWidth, sinkBitlessEvent, toString
-
-
-
-
Method Detail
-
createWidget
protected abstract Widget createWidget()
Create the widget contained within theLazyPanel
.- Returns:
- the lazy widget
-
ensureWidget
public void ensureWidget()
Ensures that the widget has been created by callingcreateWidget()
ifSimplePanel.getWidget()
returnsnull
. Typically it is not necessary to call this directly, as it is called as a side effect of asetVisible(true)
call.
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:HasVisibility
Sets whether this object is visible.- Specified by:
setVisible
in interfaceHasVisibility
- Overrides:
setVisible
in classUIObject
- Parameters:
visible
-true
to show the object,false
to hide it
-
-