public class ContentPanel extends SimpleContainer implements BeforeExpandEvent.HasBeforeExpandHandlers, ExpandEvent.HasExpandHandlers, BeforeCollapseEvent.HasBeforeCollapseHandlers, CollapseEvent.HasCollapseHandlers, Collapsible
addButton(Widget)
. The body contains a single widget,
added using SimpleContainer.add(Widget)
. The widget is resized to match the size of the container. A content panel provides built-in
expandable and collapsible behavior.
Code snippet:
public void onModuleLoad() { ContentPanel cp = new ContentPanel(); cp.setHeading("Content Panel"); cp.setPixelSize(250, 140); cp.setPosition(10, 10); cp.setCollapsible(true); cp.addTool(new ToolButton(ToolButton.GEAR)); cp.addTool(new ToolButton(ToolButton.CLOSE)); cp.setWidget(new HTML("This is an HTML Widget in a ContentPanel.")); cp.addButton(new TextButton("Ok")); RootPanel.get().add(cp); }
Modifier and Type | Class and Description |
---|---|
static interface |
ContentPanel.ContentPanelAppearance
The appearance of a content panel.
|
static interface |
ContentPanel.ContentPanelMessages
Provides access to content panel messages.
|
protected class |
ContentPanel.DefaultContentPanelMessages |
static interface |
ContentPanel.PanelHeaderAppearance
Provides support for deferred binding for the panel header appearance.
|
Modifier and Type | Field and Description |
---|---|
protected ButtonBar |
buttonBar |
protected Header |
header |
protected boolean |
secondPassRequired |
resize, widget
forceLayoutCommand, forceLayoutOnResize, hadLayoutRunning, layoutCommand, layoutRequiredThisEventLoop, layoutRunning
adjustSize, allowTextSelection, cacheSizes, disableContextMenu, disabled, disabledStyle, ensureVisibilityOnSizing, height, hidden, lastSize, layer, left, mask, maskMessage, monitorWindowResize, pageX, pageY, resizeHandler, shim, tabIndex, toolTip, toolTipConfig, top, width, windowResizeDelay, windowResizeTask
Constructor and Description |
---|
ContentPanel()
Creates a content panel with default appearance.
|
ContentPanel(ContentPanel.ContentPanelAppearance appearance)
Creates a content panel with the specified appearance.
|
Modifier and Type | Method and Description |
---|---|
HandlerRegistration |
addBeforeCollapseHandler(BeforeCollapseEvent.BeforeCollapseHandler handler)
Adds a
BeforeCollapseEvent.BeforeCollapseHandler handler for BeforeCollapseEvent
events. |
HandlerRegistration |
addBeforeExpandHandler(BeforeExpandEvent.BeforeExpandHandler handler)
Adds a
BeforeExpandEvent.BeforeExpandHandler handler for BeforeExpandEvent
events. |
void |
addButton(Widget widget)
Adds a widget the the button bar.
|
HandlerRegistration |
addCollapseHandler(CollapseEvent.CollapseHandler handler)
Adds a
CollapseEvent.CollapseHandler handler for CollapseEvent
events. |
HandlerRegistration |
addExpandHandler(ExpandEvent.ExpandHandler handler)
Adds a
ExpandEvent.ExpandHandler handler for ExpandEvent events. |
void |
addTool(Widget tool)
Adds a Tool to Header
|
protected Size |
adjustBodySize() |
protected void |
afterCollapse() |
protected void |
afterExpand() |
void |
collapse()
Collapses the widget.
|
protected void |
doAttachChildren() |
protected void |
doDetachChildren() |
protected void |
doLayout() |
protected void |
doLayoutButtonBar() |
void |
expand()
Expands the widget.
|
void |
forceLayout()
Forces a class that implements
HasLayout to lay out its child
widgets. |
int |
getAnimationDuration()
Gets the duration for the expand/collapse animations
|
ContentPanel.ContentPanelAppearance |
getAppearance()
Gets a reference to the appearance this object was instantiated with
|
XElement |
getBody()
Returns the panel's body element.
|
BoxLayoutContainer.BoxLayoutPack |
getButtonAlign()
Returns the panel's button alignment.
|
ButtonBar |
getButtonBar()
Returns the content panel button bar.
|
protected XElement |
getContainerTarget() |
protected Size |
getFrameSize() |
Header |
getHeader()
Returns the content panel header.
|
SafeHtml |
getHeading()
Returns the heading html.
|
ContentPanel.ContentPanelMessages |
getMessages()
Returns the content panel messages.
|
int |
getMinButtonWidth()
Returns the minimum button width.
|
protected void |
initTools() |
boolean |
isAnimCollapse()
Returns true if animated collapsing is enabled.
|
boolean |
isCollapsed()
Returns true if the panel is collapsed.
|
boolean |
isCollapsible()
Returns true if the panel is collapsible.
|
boolean |
isExpanded()
Returns true if the widget is expanded.
|
boolean |
isHideCollapseTool()
Returns true if the collapse tool is hidden.
|
boolean |
isTitleCollapse()
Returns true if title collapsing has been enabled.
|
protected boolean |
layoutBars() |
protected void |
onAfterFirstAttach()
Called immediately after the first time the widget becomes attached to the browser's document only the first time.
|
void |
onBrowserEvent(Event event) |
protected void |
onClick(Event ce) |
protected void |
onCollapse() |
protected void |
onDisable() |
protected void |
onEnable() |
protected void |
onExpand() |
protected void |
onResize(int width,
int height)
Called after the widget is resized, this method is empty by default but can be implemented by any subclass that
needs to perform custom logic after a resize occurs.
|
void |
setAnimationDuration(int animationDuration)
Sets the duration for the expand/collapse animations.
|
void |
setAnimCollapse(boolean animCollapse)
Sets whether expand and collapse is animating (defaults to true).
|
void |
setBodyBorder(boolean border)
Displays or hides the body border.
|
void |
setBodyStyle(String style)
Sets multiple style properties on the body element.
|
void |
setBodyStyleName(String style)
Adds a style class name to the body element.
|
void |
setButtonAlign(BoxLayoutContainer.BoxLayoutPack buttonAlign)
Sets the button alignment of any buttons added to this panel (defaults to RIGHT, pre-render).
|
void |
setCollapsible(boolean collapsible)
True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into the
header tool button area (defaults to false, pre-render).
|
void |
setExpanded(boolean expanded)
Sets the panel's expand state.
|
void |
setHeaderVisible(boolean visible)
Shows or hides the content panel header.
|
void |
setHeading(SafeHtml html)
Sets the heading html.
|
void |
setHideCollapseTool(boolean hideCollapseTool)
Sets whether the collapse tool should be displayed (when
setCollapsible(boolean) = true) (defaults to false, pre-render). |
void |
setMessages(ContentPanel.ContentPanelMessages messages)
Sets the content panel messages.
|
void |
setMinButtonWidth(int width)
Sets the minimum button width.
|
void |
setTitleCollapse(boolean titleCollapse)
True to allow expanding and collapsing the panel (when
setCollapsible(boolean) = true) by clicking
anywhere in the header bar, false to allow it only by clicking to tool button (defaults to false). |
add, add, getWidget, isResize, onRemove, setElement, setResize, setWidget, setWidget
applyLayout, applyLayout, forceLayoutOnChildren, forceLayoutOnChildren, getLeftRightMargins, getParentLayoutWidget, getSideMargins, getTopBottomMargins, isLayoutRunning, isOrWasLayoutRunning, isWidgetVisible, onBeforeDoLayout, onLoad, onResize
addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, adjustIndex, adopt, checkIndexBoundsForInsertion, clear, disable, doPhysicalAttach, doPhysicalDetach, enable, ensureGroupingHandlerRegistration, findWidget, getChildren, getItemByItemId, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, insert, iterator, onInsert, onWidgetHide, onWidgetShow, orphan, remove, remove, remove
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleDependentName, addStyleOnOver, adjustPosition, adjustSize, applyState, assertAfterRender, assertPreRender, blur, clearSizeCache, disableContextMenu, disableEvents, enableEvents, fireCancellableEvent, fireEvent, focus, getData, getElement, getFocusEl, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getPositionEl, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideShadow, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, notifyHide, notifyShow, onAttach, onBlur, onDetach, onFocus, onHide, onHideContextMenu, onPosition, onRightClick, onShow, onShowContextMenu, onTouch, onUnload, onWindowResize, removeStyleDependentName, removeStyleOnOver, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setMonitorWindowResize, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setStyleDependentName, setTabIndex, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
protected Header header
protected ButtonBar buttonBar
protected boolean secondPassRequired
public ContentPanel()
public ContentPanel(ContentPanel.ContentPanelAppearance appearance)
appearance
- the appearance of the content panel.public HandlerRegistration addBeforeCollapseHandler(BeforeCollapseEvent.BeforeCollapseHandler handler)
BeforeCollapseEvent.HasBeforeCollapseHandlers
BeforeCollapseEvent.BeforeCollapseHandler
handler for BeforeCollapseEvent
events.addBeforeCollapseHandler
in interface BeforeCollapseEvent.HasBeforeCollapseHandlers
handler
- the handlerpublic HandlerRegistration addBeforeExpandHandler(BeforeExpandEvent.BeforeExpandHandler handler)
BeforeExpandEvent.HasBeforeExpandHandlers
BeforeExpandEvent.BeforeExpandHandler
handler for BeforeExpandEvent
events.addBeforeExpandHandler
in interface BeforeExpandEvent.HasBeforeExpandHandlers
handler
- the handlerpublic void addButton(Widget widget)
widget
- the widget to addpublic HandlerRegistration addCollapseHandler(CollapseEvent.CollapseHandler handler)
CollapseEvent.HasCollapseHandlers
CollapseEvent.CollapseHandler
handler for CollapseEvent
events.addCollapseHandler
in interface CollapseEvent.HasCollapseHandlers
handler
- the handlerpublic HandlerRegistration addExpandHandler(ExpandEvent.ExpandHandler handler)
ExpandEvent.HasExpandHandlers
ExpandEvent.ExpandHandler
handler for ExpandEvent
events.addExpandHandler
in interface ExpandEvent.HasExpandHandlers
handler
- the handlerpublic void addTool(Widget tool)
tool
- the tool to addpublic void collapse()
Collapsible
collapse
in interface Collapsible
public void expand()
Collapsible
expand
in interface Collapsible
public void forceLayout()
HasLayout
HasLayout
to lay out its child
widgets.forceLayout
in interface HasLayout
forceLayout
in class ResizeContainer
public int getAnimationDuration()
public void setAnimationDuration(int animationDuration)
animationDuration
- the duration of the expand/collapse animations in millisecondspublic ContentPanel.ContentPanelAppearance getAppearance()
public XElement getBody()
public BoxLayoutContainer.BoxLayoutPack getButtonAlign()
public void setButtonAlign(BoxLayoutContainer.BoxLayoutPack buttonAlign)
buttonAlign
- the button alignmentpublic ButtonBar getButtonBar()
public ContentPanel.ContentPanelMessages getMessages()
public void setMessages(ContentPanel.ContentPanelMessages messages)
messages
- the messagespublic int getMinButtonWidth()
public void setMinButtonWidth(int width)
width
- the button widthpublic boolean isAnimCollapse()
public void setAnimCollapse(boolean animCollapse)
animCollapse
- true to enable animationspublic boolean isCollapsed()
public boolean isCollapsible()
public void setCollapsible(boolean collapsible)
collapsible
- the collapsible statepublic boolean isExpanded()
Collapsible
isExpanded
in interface Collapsible
public void setExpanded(boolean expanded)
expanded
- true true to expand
public boolean isHideCollapseTool()
public void setHideCollapseTool(boolean hideCollapseTool)
setCollapsible(boolean)
= true) (defaults to false, pre-render).hideCollapseTool
- true if the tool is hiddenpublic boolean isTitleCollapse()
public void setTitleCollapse(boolean titleCollapse)
setCollapsible(boolean)
= true) by clicking
anywhere in the header bar, false to allow it only by clicking to tool button (defaults to false).titleCollapse
- the titleCollapse to setpublic void onBrowserEvent(Event event)
onBrowserEvent
in class Component
public void setBodyBorder(boolean border)
border
- true to display the borderpublic void setBodyStyle(String style)
style
- the style(s) to setpublic void setBodyStyleName(String style)
style
- the style class namepublic Header getHeader()
public void setHeaderVisible(boolean visible)
visible
- true to show the header.public SafeHtml getHeading()
public void setHeading(SafeHtml html)
html
- the heading htmlprotected Size adjustBodySize()
protected void afterCollapse()
protected void afterExpand()
protected void doAttachChildren()
doAttachChildren
in class Container
protected void doDetachChildren()
doDetachChildren
in class Container
protected void doLayout()
doLayout
in class SimpleContainer
protected void doLayoutButtonBar()
protected XElement getContainerTarget()
getContainerTarget
in class Container
protected Size getFrameSize()
protected void initTools()
protected boolean layoutBars()
protected void onAfterFirstAttach()
Component
onAfterFirstAttach
in class Component
protected void onClick(Event ce)
protected void onCollapse()
protected void onExpand()
protected void onResize(int width, int height)
Component
onResize
in class ResizeContainer
width
- the widthheight
- the heightCopyright © 2018. All rights reserved.