Class DeckLayoutPanel
- 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.ComplexPanel
-
- com.google.gwt.user.client.ui.DeckLayoutPanel
-
- All Implemented Interfaces:
HasAttachHandlers,HasHandlers,EventListener,AcceptsOneWidget,AnimatedLayout,HasVisibility,HasWidgets,HasWidgets.ForIsWidget,IndexedPanel,IndexedPanel.ForIsWidget,InsertPanel,InsertPanel.ForIsWidget,IsWidget,ProvidesResize,RequiresResize,java.lang.Iterable<Widget>
public class DeckLayoutPanel extends ComplexPanel implements AnimatedLayout, RequiresResize, ProvidesResize, InsertPanel.ForIsWidget, AcceptsOneWidget
A panel that displays all of its child widgets in a 'deck', where only one can be visible at a time. It is used byTabLayoutPanel.This widget will only work in standards mode, which requires that the HTML page in which it is run have an explicit <!DOCTYPE> declaration.
Once a widget has been added to a DeckPanel, its visibility, width, and height attributes will be manipulated. When the widget is removed from the DeckPanel, it will be visible, and its width and height attributes will be cleared.
-
-
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
-
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.IndexedPanel
IndexedPanel.ForIsWidget
-
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.InsertPanel
InsertPanel.ForIsWidget
-
-
Field Summary
-
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 DeckLayoutPanel()Creates an empty deck panel.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Widget w)Adds a child widget.voidanimate(int duration)Layout children, animating over the specified period of time.voidanimate(int duration, Layout.AnimationCallback callback)Layout children, animating over the specified period of time.(package private) voidassertIsChild(Widget widget)Assert that the specified widget is null or a child of this widget.voidforceLayout()Layout children immediately.intgetAnimationDuration()Get the duration of the animated transition between tabs.WidgetgetVisibleWidget()Gets the currently-visible widget.intgetVisibleWidgetIndex()Gets the index of the currently-visible widget.voidinsert(IsWidget w, int beforeIndex)voidinsert(Widget widget, int beforeIndex)Inserts a child widget before the specified index.voidinsert(Widget widget, Widget before)Insert a widget before the specified widget.booleanisAnimationVertical()Check whether or not transitions slide in vertically or horizontally.protected voidonAttach()This method is called when a widget is attached to the browser's document.protected voidonDetach()This method is called when a widget is detached from the browser's document.voidonResize()This method must be called whenever the implementor's size has been modified.booleanremove(Widget w)Removes a child widget.voidsetAnimationDuration(int duration)Set the duration of the animated transition between tabs.voidsetAnimationVertical(boolean isVertical)Set whether or not transitions slide in vertically or horizontally.voidsetWidget(IsWidget w)Show the specified widget.voidshowWidget(int index)Shows the widget at the specified index.voidshowWidget(Widget widget)Shows the widget at the specified index.-
Methods inherited from class com.google.gwt.user.client.ui.ComplexPanel
add, add, adjustIndex, checkIndexBoundsForAccess, checkIndexBoundsForInsertion, doLogicalClear, getChildren, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, insert, iterator, remove
-
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, onBrowserEvent, 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, setVisible, setWidth, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel
getWidget, getWidgetCount, getWidgetIndex, remove
-
Methods inherited from interface com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget
getWidgetIndex
-
Methods inherited from interface com.google.gwt.user.client.ui.InsertPanel.ForIsWidget
add
-
-
-
-
Method Detail
-
add
public void add(Widget w)
Description copied from class:PanelAdds a child widget.How to Override this Method
There are several important things that must take place in the correct order to properly add or insert a Widget to a Panel. Not all of these steps will be relevant to every Panel, but all of the steps must be considered.
- Validate: Perform any sanity checks to ensure the Panel can accept a new Widget. Examples: checking for a valid index on insertion; checking that the Panel is not full if there is a max capacity.
- Adjust for Reinsertion: Some Panels need to handle the case
where the Widget is already a child of this Panel. Example: when performing
a reinsert, the index might need to be adjusted to account for the Widget's
removal. See
ComplexPanel.adjustIndex(Widget, int). - Detach Child: Remove the Widget from its existing parent, if
any. Most Panels will simply call
Widget.removeFromParent()on the Widget. - Logical Attach: Any state variables of the Panel should be
updated to reflect the addition of the new Widget. Example: the Widget is
added to the Panel's
WidgetCollectionat the appropriate index. - Physical Attach: The Widget's Element must be physically attached to the Panel's Element, either directly or indirectly.
- Adopt: Call
Panel.adopt(Widget)to finalize the add as the very last step.
- Specified by:
addin interfaceHasWidgets- Specified by:
addin interfaceInsertPanel- Overrides:
addin classPanel- Parameters:
w- the widget to be added- See Also:
HasWidgets.add(Widget)
-
animate
public void animate(int duration)
Description copied from interface:AnimatedLayoutLayout children, animating over the specified period of time.- Specified by:
animatein interfaceAnimatedLayout- Parameters:
duration- the animation duration, in milliseconds
-
animate
public void animate(int duration, Layout.AnimationCallback callback)Description copied from interface:AnimatedLayoutLayout children, animating over the specified period of time.This method provides a callback that will be informed of animation updates. This can be used to create more complex animation effects.
- Specified by:
animatein interfaceAnimatedLayout- Parameters:
duration- the animation duration, in millisecondscallback- the animation callback
-
forceLayout
public void forceLayout()
Description copied from interface:AnimatedLayoutLayout children immediately.This is not normally necessary, unless you want to update child widgets' positions explicitly to create a starting point for a subsequent call to
AnimatedLayout.animate(int).- Specified by:
forceLayoutin interfaceAnimatedLayout- See Also:
AnimatedLayout.animate(int),AnimatedLayout.animate(int, Layout.AnimationCallback)
-
getAnimationDuration
public int getAnimationDuration()
Get the duration of the animated transition between tabs.- Returns:
- the duration in milliseconds
-
getVisibleWidget
public Widget getVisibleWidget()
Gets the currently-visible widget.- Returns:
- the visible widget, or null if not visible
-
getVisibleWidgetIndex
public int getVisibleWidgetIndex()
Gets the index of the currently-visible widget.- Returns:
- the visible widget's index
-
insert
public void insert(IsWidget w, int beforeIndex)
- Specified by:
insertin interfaceInsertPanel.ForIsWidget
-
insert
public void insert(Widget widget, int beforeIndex)
Description copied from interface:InsertPanelInserts a child widget before the specified index. If the widget is already a child of this panel, it will be moved to the specified index.- Specified by:
insertin interfaceInsertPanel- Parameters:
widget- the child widget to be insertedbeforeIndex- the index before which it will be inserted
-
insert
public void insert(Widget widget, Widget before)
Insert a widget before the specified widget. If the widget is already a child of this panel, this method behaves as thoughremove(Widget)had already been called.- Parameters:
widget- the widget to be addedbefore- the widget before which to insert the new child, ornullto append
-
isAnimationVertical
public boolean isAnimationVertical()
Check whether or not transitions slide in vertically or horizontally. Defaults to horizontally.- Returns:
- true for vertical transitions, false for horizontal
-
onResize
public void onResize()
Description copied from interface:RequiresResizeThis method must be called whenever the implementor's size has been modified.- Specified by:
onResizein interfaceRequiresResize
-
remove
public boolean remove(Widget w)
Description copied from class:PanelRemoves 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
falseif it is not. - Orphan: Call
Panel.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
WidgetCollection.
- Specified by:
removein interfaceHasWidgets- Overrides:
removein classComplexPanel- Parameters:
w- the widget to be removed- Returns:
trueif the child was present
- Validate: Make sure this Panel is actually the parent of the
child Widget; return
-
setAnimationDuration
public void setAnimationDuration(int duration)
Set the duration of the animated transition between tabs.- Parameters:
duration- the duration in milliseconds.
-
setAnimationVertical
public void setAnimationVertical(boolean isVertical)
Set whether or not transitions slide in vertically or horizontally.- Parameters:
isVertical- true for vertical transitions, false for horizontal
-
setWidget
public void setWidget(IsWidget w)
Show the specified widget. If the widget is not a child of this panel, it is added to the end of the panel. If the specified widget is null, the currently-visible widget will be hidden.- Specified by:
setWidgetin interfaceAcceptsOneWidget- Parameters:
w- the widget to show, and add if not a child- See Also:
SimplePanel
-
showWidget
public void showWidget(int index)
Shows the widget at the specified index. This causes the currently- visible widget to be hidden.- Parameters:
index- the index of the widget to be shown
-
showWidget
public void showWidget(Widget widget)
Shows the widget at the specified index. This causes the currently- visible widget to be hidden.- Parameters:
widget- the widget to be shown
-
onAttach
protected void onAttach()
Description copied from class:WidgetThis 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
Widget.onLoad()method or useWidget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler).It is strongly recommended that you override
Widget.onLoad()orWidget.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.- Overrides:
onAttachin classWidget- See Also:
Widget.onLoad(),Widget.doAttachChildren()
-
onDetach
protected void onDetach()
Description copied from class:WidgetThis 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
Widget.onUnload()method or useWidget.addAttachHandler(com.google.gwt.event.logical.shared.AttachEvent.Handler).It is strongly recommended that you override
Widget.onUnload()orWidget.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.- Overrides:
onDetachin classWidget- See Also:
Widget.onUnload(),Widget.doDetachChildren()
-
assertIsChild
void assertIsChild(Widget widget)
Assert that the specified widget is null or a child of this widget.- Parameters:
widget- the widget to check
-
-