com.sencha.gxt.widget.core.client
Class ContentPanel

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.sencha.gxt.widget.core.client.Component
              extended by com.sencha.gxt.widget.core.client.container.Container
                  extended by com.sencha.gxt.widget.core.client.container.ResizeContainer
                      extended by com.sencha.gxt.widget.core.client.container.SimpleContainer
                          extended by com.sencha.gxt.widget.core.client.ContentPanel
All Implemented Interfaces:
HasAttachHandlers, HasResizeHandlers, HasHandlers, EventListener, AcceptsOneWidget, HasOneWidget, HasVisibility, HasWidgets, HasWidgets.ForIsWidget, IndexedPanel, IndexedPanel.ForIsWidget, IsWidget, ProvidesResize, RequiresResize, 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<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 using #addButton(CellButtonBase). The body contains a single widget, added using SimpleContainer.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.setHeadingText("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
static interface ContentPanel.ContentPanelAppearance
          The appearance of a content panel.
static interface ContentPanel.ContentPanelMessages
          Provides access to content panel messages.
static interface ContentPanel.PanelHeaderAppearance
          Provides support for deferred binding for the panel header appearance.
 
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
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
ContentPanel()
          Creates a content panel with default appearance.
ContentPanel(ContentPanel.ContentPanelAppearance appearance)
          Creates a content panel with the specified appearance.
 
Method Summary
 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
 void collapse()
          Collapses the widget.
 void expand()
          Expands the widget.
 int getAnimationDuration()
          Gets the duration for the expand/collapse animations
 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.
 Header getHeader()
          Returns the content panel header.
 String getHTML()
          Returns the HTML displayed in the header.
 ContentPanel.ContentPanelMessages getMessages()
          Returns the content panel messages.
 int getMinButtonWidth()
          Returns the minimum button width.
 String getText()
          Returns the content panel header text set by a previous call to setHeadingText(String).
 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.
 void onBrowserEvent(Event event)
           
 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 setHeadingHtml(SafeHtml html)
          Sets the heading.
 void setHeadingHtml(String html)
          Sets the heading.
 void setHeadingText(String text)
          Sets the heading.
 void setHideCollapseTool(boolean hideCollapseTool)
          Sets whether the collapse tool should be displayed when the panel is collapsible.
 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).
 
Methods inherited from class com.sencha.gxt.widget.core.client.container.SimpleContainer
add, add, getWidget, isResize, setResize, setWidget, setWidget
 
Methods inherited from class com.sencha.gxt.widget.core.client.container.ResizeContainer
forceLayout, 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, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disableEvents, enableEvents, fireEvent, focus, getData, getElement, getFocusSupport, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getStateId, getToolTip, hide, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setSize, setStateful, setStateId, setTabIndex, 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
 
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, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 HandlerRegistration addBeforeCollapseHandler(BeforeCollapseEvent.BeforeCollapseHandler handler)
Description copied from interface: BeforeCollapseEvent.HasBeforeCollapseHandlers
Adds a BeforeCollapseEvent.BeforeCollapseHandler handler for BeforeCollapseEvent events.

Specified by:
addBeforeCollapseHandler in interface BeforeCollapseEvent.HasBeforeCollapseHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addBeforeExpandHandler

public HandlerRegistration addBeforeExpandHandler(BeforeExpandEvent.BeforeExpandHandler handler)
Description copied from interface: BeforeExpandEvent.HasBeforeExpandHandlers
Adds a BeforeExpandEvent.BeforeExpandHandler handler for BeforeExpandEvent events.

Specified by:
addBeforeExpandHandler in interface BeforeExpandEvent.HasBeforeExpandHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addButton

@UiChild
public void addButton(Widget widget)
Adds a widget the the button bar.

Parameters:
widget - the widget to add

addCollapseHandler

public HandlerRegistration addCollapseHandler(CollapseEvent.CollapseHandler handler)
Description copied from interface: CollapseEvent.HasCollapseHandlers
Adds a CollapseEvent.CollapseHandler handler for CollapseEvent events.

Specified by:
addCollapseHandler in interface CollapseEvent.HasCollapseHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addExpandHandler

public HandlerRegistration addExpandHandler(ExpandEvent.ExpandHandler handler)
Description copied from interface: ExpandEvent.HasExpandHandlers
Adds a ExpandEvent.ExpandHandler handler for ExpandEvent events.

Specified by:
addExpandHandler in interface ExpandEvent.HasExpandHandlers
Parameters:
handler - the handler
Returns:
the registration for the event

addTool

@UiChild
public void addTool(Widget tool)
Adds a Tool to Header

Parameters:
tool - the tool to add

collapse

public void collapse()
Description copied from interface: Collapsible
Collapses the widget.

Specified by:
collapse in interface Collapsible

expand

public void expand()
Description copied from interface: Collapsible
Expands the widget.

Specified by:
expand in interface Collapsible

getAnimationDuration

public int getAnimationDuration()
Gets the duration for the expand/collapse animations

Returns:
the duration for the expand/collapse animations in milliseconds.

getBody

public XElement getBody()
Returns the panel's body element.

Returns:
the body

getButtonAlign

public BoxLayoutContainer.BoxLayoutPack getButtonAlign()
Returns the panel's button alignment.

Returns:
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

getHeader

public Header getHeader()
Returns the content panel header.

Returns:
the header

getHTML

public String getHTML()
Returns the HTML displayed in the header.

Returns:
the header HTML

getMessages

public ContentPanel.ContentPanelMessages getMessages()
Returns the content panel messages.

Returns:
the content panel messages

getMinButtonWidth

public int getMinButtonWidth()
Returns the minimum button width.

Returns:
the minimum button width

getText

public String getText()
Returns the content panel header text set by a previous call to setHeadingText(String).

Returns:
the header text

isAnimCollapse

public boolean isAnimCollapse()
Returns true if animated collapsing is enabled.

Returns:
true if animating

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

isExpanded

public boolean isExpanded()
Description copied from interface: Collapsible
Returns true if the widget is expanded.

Specified by:
isExpanded in interface Collapsible
Returns:
true for expanded

isHideCollapseTool

public boolean isHideCollapseTool()
Returns true if the collapse tool is hidden.

Returns:
the hide collapse tool state

isTitleCollapse

public boolean isTitleCollapse()
Returns true if title collapsing has been enabled.

Returns:
true for title collapse

onBrowserEvent

public void onBrowserEvent(Event event)
Specified by:
onBrowserEvent in interface EventListener
Overrides:
onBrowserEvent in class Component

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

setAnimCollapse

public void setAnimCollapse(boolean animCollapse)
Sets whether expand and collapse is animating (defaults to true).

Parameters:
animCollapse - true to enable animations

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

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

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 (defaults to false, pre-render).

Parameters:
collapsible - the collapsible state

setExpanded

public void setExpanded(boolean expanded)
Sets the panel's expand state.

Parameters:
expanded - true true to expand

setHeaderVisible

public void setHeaderVisible(boolean visible)
Shows or hides the content panel header.

Parameters:
visible - true to show the header.

setHeadingHtml

public void setHeadingHtml(SafeHtml html)
Sets the heading.

Parameters:
html - the heading as HTML

setHeadingHtml

public void setHeadingHtml(String html)
Sets the heading.

Parameters:
html - the heading as HTML

setHeadingText

public void setHeadingText(String text)
Sets the heading.

Parameters:
text - the heading text

setHideCollapseTool

public void setHideCollapseTool(boolean hideCollapseTool)
Sets whether the collapse tool should be displayed when the panel is collapsible.

Parameters:
hideCollapseTool - true if the tool is hidden

setMessages

public void setMessages(ContentPanel.ContentPanelMessages messages)
Sets the content panel messages.

Parameters:
messages - the messages

setMinButtonWidth

public void setMinButtonWidth(int width)
Sets the minimum button width.

Parameters:
width - the button width

setTitleCollapse

public 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).

Parameters:
titleCollapse - the titleCollapse to set


Copyright © 2012. All Rights Reserved.