public final class

DisclosurePanel

extends Composite
implements HasCloseHandlers<T> HasOpenHandlers<T> FiresDisclosureEvents HasAnimation HasWidgets
java.lang.Object
   ↳ com.google.gwt.user.client.ui.UIObject
     ↳ com.google.gwt.user.client.ui.Widget
       ↳ com.google.gwt.user.client.ui.Composite
         ↳ com.google.gwt.user.client.ui.DisclosurePanel

Class Overview

A widget that consists of a header and a content panel that discloses the content when a user clicks on the header.

CSS Style Rules

.gwt-DisclosurePanel
the panel's primary style
.gwt-DisclosurePanel-open
dependent style set when panel is open
.gwt-DisclosurePanel-closed
dependent style set when panel is closed

The header and content sections can be easily selected using css with a child selector:
.gwt-DisclosurePanel-open .header { ... }

Use in UiBinder Templates

DisclosurePanel elements in UiBinder templates can have one widget child and one of two types of header elements. A <g:header> element can hold text (not html), or a <g:customHeader> element can hold a widget. (Note that the tags of the header elements are not capitalized. This is meant to signal that the header is not a runtime object, and so cannot have a ui:field attribute.)

For example:

 <g:DisclosurePanel>
   <g:header>Text header</g:header>
   <g:Label>Widget body</g:Label>
 </g:DisclosurePanel>

 <g:DisclosurePanel>
   <g:customHeader>
     <g:Label>Widget header</g:Label>
   </g:customHeader>
   <g:Label>Widget body</g:Label>
 </g:DisclosurePanel>
 

Summary

[Expand]
Inherited Constants
From class com.google.gwt.user.client.ui.UIObject
Public Constructors
DisclosurePanel()
Creates an empty DisclosurePanel that is initially closed.
DisclosurePanel(DisclosurePanelImages images, String headerText, boolean isOpen)
DisclosurePanel(ImageResource openImage, ImageResource closedImage, String headerText)
Creates a DisclosurePanel with the specified header text, an initial open/close state and a bundle of images to be used in the default header widget.
DisclosurePanel(String headerText)
Creates a DisclosurePanel that will be initially closed using the specified text in the header.
DisclosurePanel(String headerText, boolean isOpen)
This constructor is deprecated. use DisclosurePanel(String) and setOpen(boolean)
DisclosurePanel(Widget header)
This constructor is deprecated. use DisclosurePanel() and setHeader(Widget)
DisclosurePanel(Widget header, boolean isOpen)
This constructor is deprecated. use DisclosurePanel(), setOpen(boolean) and setHeader(Widget) instead
Public Methods
void add(Widget w)
Adds a child widget.
HandlerRegistration addCloseHandler(CloseHandler<DisclosurePanel> handler)
void addEventHandler(DisclosureHandler handler)
This method is deprecated. Use addOpenHandler(OpenHandler) and addCloseHandler(CloseHandler) instead
HandlerRegistration addOpenHandler(OpenHandler<DisclosurePanel> handler)
void clear()
Removes all child widgets.
Widget getContent()
Gets the widget that was previously set in setContent(Widget).
Widget getHeader()
Gets the widget that is currently being used as a header.
HasText getHeaderTextAccessor()
Gets a HasText instance to provide access to the headers's text, if the header widget does provide such access.
boolean isAnimationEnabled()
Returns true if animations are enabled, false if not.
boolean isOpen()
Determines whether the panel is open.
Iterator<Widget> iterator()
Gets an iterator for the contained widgets.
boolean remove(Widget w)
Removes a child widget.
void removeEventHandler(DisclosureHandler handler)
This method is deprecated. Use the removeHandler() method on the object returned by an add*Handler method instead
void setAnimationEnabled(boolean enable)
Enable or disable animations.
void setContent(Widget content)
Sets the content widget which can be opened and closed by this panel.
void setHeader(Widget headerWidget)
Sets the widget used as the header for the panel.
void setOpen(boolean isOpen)
Changes the visible state of this DisclosurePanel.
Protected Methods
void onEnsureDebugId(String baseID)
Affected Elements:
  • -header = the clickable header.
[Expand]
Inherited Methods
From class com.google.gwt.user.client.ui.Composite
From class com.google.gwt.user.client.ui.Widget
From class com.google.gwt.user.client.ui.UIObject
From class java.lang.Object
From interface com.google.gwt.event.logical.shared.HasAttachHandlers
From interface com.google.gwt.event.logical.shared.HasCloseHandlers
From interface com.google.gwt.event.logical.shared.HasOpenHandlers
From interface com.google.gwt.event.shared.HasHandlers
From interface com.google.gwt.user.client.EventListener
From interface com.google.gwt.user.client.ui.FiresDisclosureEvents
From interface com.google.gwt.user.client.ui.HasAnimation
From interface com.google.gwt.user.client.ui.HasWidgets
From interface com.google.gwt.user.client.ui.IsWidget
From interface java.lang.Iterable

Public Constructors

public DisclosurePanel ()

Creates an empty DisclosurePanel that is initially closed.

public DisclosurePanel (DisclosurePanelImages images, String headerText, boolean isOpen)

This constructor is deprecated.
use DisclosurePanel(ImageResource, ImageResource, String) and setOpen(boolean)

Creates a DisclosurePanel with the specified header text, an initial open/close state and a bundle of images to be used in the default header widget.

Parameters
images a bundle that provides disclosure panel specific images
headerText the text to be displayed in the header
isOpen the initial open/close state of the content panel

public DisclosurePanel (ImageResource openImage, ImageResource closedImage, String headerText)

Creates a DisclosurePanel with the specified header text, an initial open/close state and a bundle of images to be used in the default header widget.

Parameters
openImage the open state image resource
closedImage the closed state image resource
headerText the text to be displayed in the header

public DisclosurePanel (String headerText)

Creates a DisclosurePanel that will be initially closed using the specified text in the header.

Parameters
headerText the text to be displayed in the header

public DisclosurePanel (String headerText, boolean isOpen)

This constructor is deprecated.
use DisclosurePanel(String) and setOpen(boolean)

Creates a DisclosurePanel with the specified header text and an initial open/close state.

Parameters
headerText the text to be displayed in the header
isOpen the initial open/close state of the content panel

public DisclosurePanel (Widget header)

This constructor is deprecated.
use DisclosurePanel() and setHeader(Widget)

Creates a DisclosurePanel that will be initially closed using a widget as the header.

Parameters
header the widget to be used as a header

public DisclosurePanel (Widget header, boolean isOpen)

This constructor is deprecated.
use DisclosurePanel(), setOpen(boolean) and setHeader(Widget) instead

Creates a DisclosurePanel using a widget as the header and an initial open/close state.

Parameters
header the widget to be used as a header
isOpen the initial open/close state of the content panel

Public Methods

public void add (Widget w)

Adds a child widget.

Parameters
w the widget to be added

public HandlerRegistration addCloseHandler (CloseHandler<DisclosurePanel> handler)

public void addEventHandler (DisclosureHandler handler)

This method is deprecated.
Use addOpenHandler(OpenHandler) and addCloseHandler(CloseHandler) instead

Attaches an event handler to the panel to receive DisclosureEvent notification.

Parameters
handler the handler to be added (should not be null)

public HandlerRegistration addOpenHandler (OpenHandler<DisclosurePanel> handler)

public void clear ()

Removes all child widgets.

public Widget getContent ()

Gets the widget that was previously set in setContent(Widget).

Returns
  • the panel's current content widget

public Widget getHeader ()

Gets the widget that is currently being used as a header.

Returns
  • the widget currently being used as a header

public HasText getHeaderTextAccessor ()

Gets a HasText instance to provide access to the headers's text, if the header widget does provide such access.

Returns
  • a reference to the header widget if it implements HasText, null otherwise

public boolean isAnimationEnabled ()

Returns true if animations are enabled, false if not.

public boolean isOpen ()

Determines whether the panel is open.

Returns
  • true if panel is in open state

public Iterator<Widget> iterator ()

Gets an iterator for the contained widgets. This iterator is required to implement remove().

public boolean remove (Widget w)

Removes a child widget.

Parameters
w the widget to be removed
Returns
  • true if the widget was present

public void removeEventHandler (DisclosureHandler handler)

This method is deprecated.
Use the removeHandler() method on the object returned by an add*Handler method instead

Removes an event handler from the panel.

Parameters
handler the handler to be removed

public void setAnimationEnabled (boolean enable)

Enable or disable animations.

Parameters
enable true to enable, false to disable

public void setContent (Widget content)

Sets the content widget which can be opened and closed by this panel. If there is a preexisting content widget, it will be detached.

Parameters
content the widget to be used as the content panel

public void setHeader (Widget headerWidget)

Sets the widget used as the header for the panel.

Parameters
headerWidget the widget to be used as the header

public void setOpen (boolean isOpen)

Changes the visible state of this DisclosurePanel.

Parameters
isOpen true to open the panel, false to close

Protected Methods

protected void onEnsureDebugId (String baseID)

Affected Elements:

  • -header = the clickable header.

Parameters
baseID the base ID used by the main element