Class ContentPanel
- java.lang.Object
-
- com.google.gwt.user.client.ui.UIObject
-
- com.google.gwt.user.client.ui.Widget
-
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.logical.shared.HasResizeHandlers,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.AcceptsOneWidget,com.google.gwt.user.client.ui.HasEnabled,com.google.gwt.user.client.ui.HasOneWidget,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.HasWidgets,com.google.gwt.user.client.ui.HasWidgets.ForIsWidget,com.google.gwt.user.client.ui.IndexedPanel,com.google.gwt.user.client.ui.IndexedPanel.ForIsWidget,com.google.gwt.user.client.ui.IsWidget,com.google.gwt.user.client.ui.ProvidesResize,com.google.gwt.user.client.ui.RequiresResize,HasGestureRecognizers,Collapsible,HasLayout,AddEvent.HasAddHandlers,BeforeAddEvent.HasBeforeAddHandlers,BeforeCollapseEvent.HasBeforeCollapseHandlers,BeforeExpandEvent.HasBeforeExpandHandlers,BeforeHideEvent.HasBeforeHideHandlers,BeforeRemoveEvent.HasBeforeRemoveHandlers,BeforeShowContextMenuEvent.HasBeforeShowContextMenuHandler,BeforeShowEvent.HasBeforeShowHandlers,BlurEvent.HasBlurHandlers,CollapseEvent.HasCollapseHandlers,ContainerHandler.HasContainerHandlers,DisableEvent.HasDisableHandlers,EnableEvent.HasEnableHandlers,ExpandEvent.HasExpandHandlers,FocusEvent.HasFocusHandlers,HideEvent.HasHideHandlers,MoveEvent.HasMoveHandlers,RemoveEvent.HasRemoveHandlers,ShowContextMenuEvent.HasShowContextMenuHandler,ShowEvent.HasShowHandlers,HasFocusSupport,HasItemId,Iterable<com.google.gwt.user.client.ui.Widget>
- Direct Known Subclasses:
FramedPanel,Window
public class ContentPanel extends SimpleContainer implements BeforeExpandEvent.HasBeforeExpandHandlers, ExpandEvent.HasExpandHandlers, BeforeCollapseEvent.HasBeforeCollapseHandlers, CollapseEvent.HasCollapseHandlers, Collapsible
ContentPanel is a component container that has specific functionality and structural components that make it the perfect building block for application-oriented user interfaces. A content panel contains separate header, footer and body sections. The header may contain an icon, text and a tool area that can be wired up to provide customized behavior. The footer contains buttons added usingaddButton(Widget). The body contains a single widget, added usingSimpleContainer.add(com.google.gwt.user.client.ui.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); }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceContentPanel.ContentPanelAppearanceThe appearance of a content panel.static interfaceContentPanel.ContentPanelMessagesProvides access to content panel messages.static interfaceContentPanel.PanelHeaderAppearanceProvides support for deferred binding for the panel header appearance.-
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
-
-
Constructor Summary
Constructors Constructor Description ContentPanel()Creates a content panel with default appearance.ContentPanel(ContentPanel.ContentPanelAppearance appearance)Creates a content panel with the specified appearance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.google.gwt.event.shared.HandlerRegistrationaddBeforeCollapseHandler(BeforeCollapseEvent.BeforeCollapseHandler handler)Adds aBeforeCollapseEvent.BeforeCollapseHandlerhandler forBeforeCollapseEventevents.com.google.gwt.event.shared.HandlerRegistrationaddBeforeExpandHandler(BeforeExpandEvent.BeforeExpandHandler handler)Adds aBeforeExpandEvent.BeforeExpandHandlerhandler forBeforeExpandEventevents.voidaddButton(com.google.gwt.user.client.ui.Widget widget)Adds a widget the the button bar.com.google.gwt.event.shared.HandlerRegistrationaddCollapseHandler(CollapseEvent.CollapseHandler handler)Adds aCollapseEvent.CollapseHandlerhandler forCollapseEventevents.com.google.gwt.event.shared.HandlerRegistrationaddExpandHandler(ExpandEvent.ExpandHandler handler)Adds aExpandEvent.ExpandHandlerhandler forExpandEventevents.voidaddTool(com.google.gwt.user.client.ui.Widget tool)Adds a Tool to Headervoidcollapse()Collapses the widget.voidexpand()Expands the widget.voidforceLayout()Forces a class that implements HasLayout to lay out its child widgets.intgetAnimationDuration()Gets the duration for the expand/collapse animationsContentPanel.ContentPanelAppearancegetAppearance()Gets a reference to the appearance this object was instantiated withXElementgetBody()Returns the panel's body element.XElementgetBodyWrap()Returns the panel's body wrap element.BoxLayoutContainer.BoxLayoutPackgetButtonAlign()Returns the panel's button alignment.ButtonBargetButtonBar()Returns the content panel button bar.HeadergetHeader()Returns the content panel header.com.google.gwt.safehtml.shared.SafeHtmlgetHeading()Returns the heading html.ContentPanel.ContentPanelMessagesgetMessages()Returns the content panel messages.intgetMinButtonWidth()Returns the minimum button width.voidinitTools()booleanisAnimCollapse()Returns true if animated collapsing is enabled.booleanisCollapsed()Returns true if the panel is collapsed.booleanisCollapsible()Returns true if the panel is collapsible.booleanisExpanded()Returns true if the widget is expanded.booleanisHeaderVisible()Returns true if the header is visible.booleanisHideCollapseTool()Returns true if the collapse tool is hidden.booleanisTitleCollapse()Returns true if title collapsing has been enabled.voidonBrowserEvent(com.google.gwt.user.client.Event event)voidsetAnimationDuration(int animationDuration)Sets the duration for the expand/collapse animations.voidsetAnimCollapse(boolean animCollapse)Sets whether expand and collapse is animating (defaults to true).voidsetBodyBorder(boolean border)Displays or hides the body border.voidsetBodyStyle(String style)Sets multiple style properties on the body element.voidsetBodyStyleName(String style)Adds a style class name to the body element.voidsetButtonAlign(BoxLayoutContainer.BoxLayoutPack buttonAlign)Sets the button alignment of any buttons added to this panel (defaults to RIGHT, pre-render).voidsetCollapsible(boolean collapsible)True to make the panel collapsible and have the expand/collapse toggle button automatically rendered into the header tool button area.voidsetExpanded(boolean expanded)Sets the panel's expand state.voidsetHeaderVisible(boolean visible)Shows or hides the content panel header.voidsetHeading(com.google.gwt.safehtml.shared.SafeHtml html)Sets the heading html.voidsetHeading(String text)Sets the heading text.voidsetHideCollapseTool(boolean hideCollapseTool)Sets whether the collapse tool should be displayed (whensetCollapsible(boolean)= true)voidsetMessages(ContentPanel.ContentPanelMessages messages)Sets the content panel messages.voidsetMinButtonWidth(int width)Sets the minimum button width.voidsetTitleCollapse(boolean titleCollapse)True to allow expanding and collapsing the panel (whensetCollapsible(boolean)= true) by clicking anywhere in the header bar, false to allow it only by clicking to tool button (defaults to false).-
Methods inherited from class com.sencha.gxt.widget.core.client.container.SimpleContainer
add, add, add, getWidget, isResize, setResize, setWidget, setWidget
-
Methods inherited from class com.sencha.gxt.widget.core.client.container.ResizeContainer
isLayoutRunning, isOrWasLayoutRunning, onResize
-
Methods inherited from class com.sencha.gxt.widget.core.client.container.Container
add, addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, clear, disable, enable, findWidget, getItemByItemId, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, iterator, remove, remove, remove
-
Methods inherited from class com.sencha.gxt.widget.core.client.Component
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disableEvents, enableEvents, fireEvent, focus, getData, getElement, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideToolTip, isAdjustSize, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, removeGestureRecognizer, removeToolTip, setAdjustSize, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setTabIndex, setToolTip, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
-
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
-
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toString
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ContentPanel
public ContentPanel()
Creates a content panel with default appearance.
-
ContentPanel
public ContentPanel(ContentPanel.ContentPanelAppearance appearance)
Creates a content panel with the specified appearance.- Parameters:
appearance- the appearance of the content panel.
-
-
Method Detail
-
addBeforeCollapseHandler
public com.google.gwt.event.shared.HandlerRegistration addBeforeCollapseHandler(BeforeCollapseEvent.BeforeCollapseHandler handler)
Description copied from interface:BeforeCollapseEvent.HasBeforeCollapseHandlersAdds aBeforeCollapseEvent.BeforeCollapseHandlerhandler forBeforeCollapseEventevents.- Specified by:
addBeforeCollapseHandlerin interfaceBeforeCollapseEvent.HasBeforeCollapseHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addBeforeExpandHandler
public com.google.gwt.event.shared.HandlerRegistration addBeforeExpandHandler(BeforeExpandEvent.BeforeExpandHandler handler)
Description copied from interface:BeforeExpandEvent.HasBeforeExpandHandlersAdds aBeforeExpandEvent.BeforeExpandHandlerhandler forBeforeExpandEventevents.- Specified by:
addBeforeExpandHandlerin interfaceBeforeExpandEvent.HasBeforeExpandHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addButton
@UiChild public void addButton(com.google.gwt.user.client.ui.Widget widget)
Adds a widget the the button bar.- Parameters:
widget- the widget to add
-
addCollapseHandler
public com.google.gwt.event.shared.HandlerRegistration addCollapseHandler(CollapseEvent.CollapseHandler handler)
Description copied from interface:CollapseEvent.HasCollapseHandlersAdds aCollapseEvent.CollapseHandlerhandler forCollapseEventevents.- Specified by:
addCollapseHandlerin interfaceCollapseEvent.HasCollapseHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addExpandHandler
public com.google.gwt.event.shared.HandlerRegistration addExpandHandler(ExpandEvent.ExpandHandler handler)
Description copied from interface:ExpandEvent.HasExpandHandlersAdds aExpandEvent.ExpandHandlerhandler forExpandEventevents.- Specified by:
addExpandHandlerin interfaceExpandEvent.HasExpandHandlers- Parameters:
handler- the handler- Returns:
- the registration for the event
-
addTool
@UiChild public void addTool(com.google.gwt.user.client.ui.Widget tool)
Adds a Tool to Header- Parameters:
tool- the tool to add
-
collapse
public void collapse()
Description copied from interface:CollapsibleCollapses the widget.- Specified by:
collapsein interfaceCollapsible
-
expand
public void expand()
Description copied from interface:CollapsibleExpands the widget.- Specified by:
expandin interfaceCollapsible
-
forceLayout
public void forceLayout()
Description copied from interface:HasLayoutForces a class that implements HasLayout to lay out its child widgets.- Specified by:
forceLayoutin interfaceHasLayout- Overrides:
forceLayoutin classResizeContainer
-
getAnimationDuration
public int getAnimationDuration()
Gets the duration for the expand/collapse animations- Returns:
- the duration for the expand/collapse animations in milliseconds.
-
setAnimationDuration
public void setAnimationDuration(int animationDuration)
Sets the duration for the expand/collapse animations.- Parameters:
animationDuration- the duration of the expand/collapse animations in milliseconds
-
getAppearance
public ContentPanel.ContentPanelAppearance getAppearance()
Gets a reference to the appearance this object was instantiated with- Returns:
- the appearance impl used by this component
-
getBody
public XElement getBody()
Returns the panel's body element.- Returns:
- the body
-
getBodyWrap
public XElement getBodyWrap()
Returns the panel's body wrap element.- Returns:
- the body wrap
- Since:
- 4.0.3
-
getButtonAlign
public BoxLayoutContainer.BoxLayoutPack getButtonAlign()
Returns the panel's button alignment.- Returns:
- the button alignment
-
setButtonAlign
public void setButtonAlign(BoxLayoutContainer.BoxLayoutPack buttonAlign)
Sets the button alignment of any buttons added to this panel (defaults to RIGHT, pre-render).- Parameters:
buttonAlign- the button alignment
-
getButtonBar
public ButtonBar getButtonBar()
Returns the content panel button bar. In the default implementation, the button bar is displayed in the content panel's footer.- Returns:
- the button bar
-
getMessages
public ContentPanel.ContentPanelMessages getMessages()
Returns the content panel messages.- Returns:
- the content panel messages
-
setMessages
public void setMessages(ContentPanel.ContentPanelMessages messages)
Sets the content panel messages.- Parameters:
messages- the messages
-
getMinButtonWidth
public int getMinButtonWidth()
Returns the minimum button width.- Returns:
- the minimum button width
-
setMinButtonWidth
public void setMinButtonWidth(int width)
Sets the minimum button width.- Parameters:
width- the button width
-
isAnimCollapse
public boolean isAnimCollapse()
Returns true if animated collapsing is enabled.- Returns:
- true if animating
-
setAnimCollapse
public void setAnimCollapse(boolean animCollapse)
Sets whether expand and collapse is animating (defaults to true).- Parameters:
animCollapse- true to enable animations
-
isCollapsed
public boolean isCollapsed()
Returns true if the panel is collapsed.- Returns:
- the collapsed state
-
isCollapsible
public boolean isCollapsible()
Returns true if the panel is collapsible.- Returns:
- the collapsible state
-
setCollapsible
public 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.- Parameters:
collapsible- the collapsible state
-
isExpanded
public boolean isExpanded()
Description copied from interface:CollapsibleReturns true if the widget is expanded.- Specified by:
isExpandedin interfaceCollapsible- Returns:
- true for expanded
-
isHeaderVisible
public boolean isHeaderVisible()
Returns true if the header is visible.- Returns:
- header visibility
- Since:
- 4.0.3
-
setExpanded
public void setExpanded(boolean expanded)
Sets the panel's expand state.- Parameters:
expanded- true to expand
-
isHideCollapseTool
public boolean isHideCollapseTool()
Returns true if the collapse tool is hidden.- Returns:
- the hide collapse tool state
-
setHideCollapseTool
public void setHideCollapseTool(boolean hideCollapseTool)
Sets whether the collapse tool should be displayed (whensetCollapsible(boolean)= true)- Parameters:
hideCollapseTool- true if the tool is hidden
-
isTitleCollapse
public boolean isTitleCollapse()
Returns true if title collapsing has been enabled.- Returns:
- true for title collapse
-
setTitleCollapse
public void setTitleCollapse(boolean titleCollapse)
True to allow expanding and collapsing the panel (whensetCollapsible(boolean)= true) by clicking anywhere in the header bar, false to allow it only by clicking to tool button (defaults to false).- Parameters:
titleCollapse- the titleCollapse to set
-
onBrowserEvent
public void onBrowserEvent(com.google.gwt.user.client.Event event)
- Specified by:
onBrowserEventin interfacecom.google.gwt.user.client.EventListener- Overrides:
onBrowserEventin classComponent
-
setBodyBorder
public void setBodyBorder(boolean border)
Displays or hides the body border.- Parameters:
border- true to display the border
-
setBodyStyle
public void setBodyStyle(String style)
Sets multiple style properties on the body element. Style attribute names must be in lower camel case, e.g. "backgroundColor:white; color:red;"- Parameters:
style- the style(s) to set
-
setBodyStyleName
public void setBodyStyleName(String style)
Adds a style class name to the body element.- Parameters:
style- the style class name
-
getHeader
public Header getHeader()
Returns the content panel header.- Returns:
- the header
-
setHeaderVisible
public void setHeaderVisible(boolean visible)
Shows or hides the content panel header.- Parameters:
visible- true to show the header.
-
getHeading
public com.google.gwt.safehtml.shared.SafeHtml getHeading()
Returns the heading html.- Returns:
- the heading html
-
setHeading
public void setHeading(com.google.gwt.safehtml.shared.SafeHtml html)
Sets the heading html.- Parameters:
html- the heading html
-
setHeading
public void setHeading(String text)
Sets the heading text. Text that contains reserved html characters will be escaped.- Parameters:
text- the text
-
initTools
public void initTools()
-
-