Class DisclosurePanel

public final class DisclosurePanel
extends Composite
implements FiresDisclosureEvents, HasWidgets
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

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

Constructors

DisclosurePanel()Creates an empty DisclosurePanel that is initially closed.
DisclosurePanel(DisclosurePanelImages, String, 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.
DisclosurePanel(String)Creates a DisclosurePanel that will be initially closed using the specified text in the header.
DisclosurePanel(String, boolean)Creates a DisclosurePanel with the specified header text and an initial open/close state.
DisclosurePanel(Widget)Creates a DisclosurePanel that will be initially closed using a widget as the header.
DisclosurePanel(Widget, boolean)Creates a DisclosurePanel using a widget as the header and an initial open/close state.

Methods

add(Widget)Adds a child widget.
addEventHandler(DisclosureHandler)Attaches an event handler to the panel to receive DisclosureEvent notification.
clear()Removes all child widgets.
getContent()Gets the widget that was previously set in setContent(Widget).
getHeader()Gets the widget that is currently being used as a header.
getHeaderTextAccessor()Gets a HasText instance to provide access to the headers's text, if the header widget does provide such access.
isOpen()Determines whether the panel is open.
iterator()Gets an iterator for the contained widgets.
remove(Widget)Removes a child widget.
removeEventHandler(DisclosureHandler)Removes an event handler from the panel.
setContent(Widget)Sets the content widget which can be opened and closed by this panel.
setHeader(Widget)Sets the widget used as the header for the panel.
setOpen(boolean)Changes the visible state of this DisclosurePanel.

Constructor Detail

DisclosurePanel

public DisclosurePanel()
Creates an empty DisclosurePanel that is initially closed.

DisclosurePanel

public DisclosurePanel(DisclosurePanelImages images, String headerText, boolean isOpen)
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

DisclosurePanel

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.

DisclosurePanel

public DisclosurePanel(String headerText, boolean isOpen)
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

DisclosurePanel

public DisclosurePanel(Widget header)
Creates a DisclosurePanel that will be initially closed using a widget as the header.

Parameters

header
the widget to be used as a header

DisclosurePanel

public DisclosurePanel(Widget header, boolean isOpen)
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

Method Detail

add

public void add(Widget w)
Adds a child widget.

Parameters

w
the widget to be added

addEventHandler

public final void addEventHandler(DisclosureHandler handler)
Attaches an event handler to the panel to receive DisclosureEvent notification.

Parameters

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

clear

public void clear()
Removes all child widgets.

getContent

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

Return Value

the panel's current content widget

getHeader

public final Widget getHeader()
Gets the widget that is currently being used as a header.

Return Value

the widget currently being used as a header

getHeaderTextAccessor

public final HasText getHeaderTextAccessor()
Gets a HasText instance to provide access to the headers's text, if the header widget does provide such access.

Return Value

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

isOpen

public final boolean isOpen()
Determines whether the panel is open.

Return Value

true if panel is in open state

iterator

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

remove

public boolean remove(Widget w)
Removes a child widget.

Parameters

w
the widget to be removed

Return Value

true if the widget was present

removeEventHandler

public final void removeEventHandler(DisclosureHandler handler)
Removes an event handler from the panel.

Parameters

handler
the handler to be removed

setContent

public final 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

setHeader

public final void setHeader(Widget headerWidget)
Sets the widget used as the header for the panel.

Parameters

headerWidget
the widget to be used as the header

setOpen

public final void setOpen(boolean isOpen)
Changes the visible state of this DisclosurePanel.

Parameters

isOpen
true to open the panel, false to close