com.extjs.gxt.ui.client.widget
Class Container<T extends Component>

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Container<T>
Type Parameters:
T - the child component type
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
HtmlContainer, Menu, MenuBar, ScrollContainer, Table, TabPanel, ToolBar, Tree

public abstract class Container<T extends Component>
extends BoxComponent

Class for any BoxComponent that can contain other components. Containers handle the basic behavior of containing components, namely managing, attaching, and detaching the child widgets.

When children are added to a container they are not physically added to the DOM of the container. Subclasses are responsible for connecting the child components.

Container does not define a root element. setElement must be called by any subclass to ensure the container has an element.

Events:
BeforeAdd : ContainerEvent(container, item, index)
Fires before a item is added or inserted. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
BeforeRemove : ContainerEvent(container, item)
Fires before a item is removed. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Add : ContainerEvent(container, item, index)
Fires after a item has been added or inserted.
Remove : ContainerEvent(container, item)
Fires after a item has been removed.
Inherited Events:
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState


Nested Class Summary
 
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
 
Field Summary
protected  boolean attachChildren
          True to attach the container's children (defaults to true).
protected  boolean enableLayout
          False to disable the container's layout, stopping it from executing (defaults to false).
protected  boolean layoutExecuted
           
protected  boolean layoutNeeded
           
protected  boolean layoutOnAttach
           
protected  boolean layoutOnChange
          True to execute the container's layout when children are inserted and removed (defaults to false).
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Container()
          Creates a new container.
 
Method Summary
protected  boolean add(T item)
          Adds a item to the container.
protected  int adjustIndex(T child, int beforeIndex)
           
protected  void adopt(T child)
          Sets the child's parent to this container.
protected  ContainerEvent createContainerEvent(T item)
           
 void disable()
          Disable this component.
protected  void doAttachChildren()
           
protected  void doDetachChildren()
           
protected  boolean doLayout()
           
protected  boolean doLayout(boolean force)
           
 void enable()
          Enable this component.
 T findItem(com.google.gwt.user.client.Element elem)
          Returns the component whose element, or child element, matches the given element.
 T getItem(int index)
          Returns the item at the given index or null if index out of bounds.
 T getItemByItemId(java.lang.String itemId)
          Returns the item with the specified item id.
 int getItemCount()
          Returns the number of children.
 java.util.List<T> getItems()
          Returns the child items.
protected  Layout getLayout()
           
 El getLayoutTarget()
          Returns the container's layout target.
 com.google.gwt.user.client.ui.Widget getWidget(int index)
          Returns the widget at the given index.
 int indexOf(T item)
          Returns the index of the item.
protected  boolean insert(T item, int index)
          Adds a item into the container.
protected  boolean isLayoutNeeded()
           
 java.util.Iterator<T> iterator()
          Returns an iterator over the container's children.
protected  boolean layout()
          Executes the container's layout.
protected  boolean layout(boolean force)
          * Executes the container's layout.
protected  void notifyHide()
           
protected  void notifyShow()
           
protected  void onAfterLayout()
           
protected  void onAttach()
           
protected  void onBeforeLayoutExcecuted(Layout layout)
           
protected  void onInsert(T item, int index)
           
protected  void onLayoutExcecuted(Layout layout)
           
protected  void onRemove(T item)
           
protected  void orphan(T child)
           
protected  boolean remove(T item)
          Removes the item from the container.
protected  boolean remove(T component, boolean force)
           
 boolean removeAll()
          Removes all the container's items.
protected  boolean removeAll(boolean force)
           
 void scrollIntoView(T item)
          Scrolls the item into view.
protected  void setLayout(Layout layout)
          Sets the container's layout.
protected  void setLayoutNeeded(boolean layoutNeeded)
           
protected  void setLayoutOnChange(boolean change)
           
protected  Component wrapWidget(com.google.gwt.user.client.ui.Widget widget)
          Helper Method for the subclasses that wish to support automatic wrapping of Widget instances in WidgetComponents

If the widget is a component, no wrapping is performed

 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, afterRender, createComponentEvent, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onHide, onPosition, onResize, onShow, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disableContextMenu, disableEvents, disableTextSelection, el, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusEl, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, onBrowserEvent, onComponentEvent, onDetach, onDetachHelper, onDisable, onEnable, onEnsureDebugId, onHideContextMenu, onLoad, onRender, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

attachChildren

protected boolean attachChildren
True to attach the container's children (defaults to true).


enableLayout

protected boolean enableLayout
False to disable the container's layout, stopping it from executing (defaults to false).


layoutOnChange

protected boolean layoutOnChange
True to execute the container's layout when children are inserted and removed (defaults to false).


layoutExecuted

protected boolean layoutExecuted

layoutNeeded

protected boolean layoutNeeded

layoutOnAttach

protected boolean layoutOnAttach
Constructor Detail

Container

public Container()
Creates a new container.

Method Detail

disable

public void disable()
Description copied from class: Component
Disable this component. Fires the Disable event.

Overrides:
disable in class Component

enable

public void enable()
Description copied from class: Component
Enable this component. Fires the Enable event.

Overrides:
enable in class Component

findItem

public T findItem(com.google.gwt.user.client.Element elem)
Returns the component whose element, or child element, matches the given element.

Parameters:
elem - the element
Returns:
the matching component or null if no match

getItem

public T getItem(int index)
Returns the item at the given index or null if index out of bounds.

Parameters:
index - the index
Returns:
the item

getItemByItemId

public T getItemByItemId(java.lang.String itemId)
Returns the item with the specified item id.

Parameters:
itemId - the item id
Returns:
the button or null if no match

getItemCount

public int getItemCount()
Returns the number of children.

Returns:
the component count

getItems

public java.util.List<T> getItems()
Returns the child items.

Returns:
the children

getLayoutTarget

public El getLayoutTarget()
Returns the container's layout target. Only applies to container's with layouts.

Returns:
the layout target

getWidget

public com.google.gwt.user.client.ui.Widget getWidget(int index)
Returns the widget at the given index. If the child is a WidgetComponent, the wrapped widget is returned.

Parameters:
index - the index
Returns:
the widget

indexOf

public int indexOf(T item)
Returns the index of the item.

Parameters:
item - the item
Returns:
the index

iterator

public java.util.Iterator<T> iterator()
Returns an iterator over the container's children.

Returns:
an iterator

removeAll

public boolean removeAll()
Removes all the container's items.

Returns:
true if all items where removed

scrollIntoView

public void scrollIntoView(T item)
Scrolls the item into view.

Parameters:
item - the item

add

protected boolean add(T item)
Adds a item to the container. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
item - the item to be added

adjustIndex

protected int adjustIndex(T child,
                          int beforeIndex)

adopt

protected void adopt(T child)
Sets the child's parent to this container. In order to support lazy rendering this method uses JSNI to simply set the child parent without effecting the attached state of the child.

Parameters:
child - the child widget

createContainerEvent

protected ContainerEvent createContainerEvent(T item)

doAttachChildren

protected void doAttachChildren()
Overrides:
doAttachChildren in class Component

doDetachChildren

protected void doDetachChildren()
Overrides:
doDetachChildren in class Component

doLayout

protected boolean doLayout()

doLayout

protected boolean doLayout(boolean force)

getLayout

protected Layout getLayout()

insert

protected boolean insert(T item,
                         int index)
Adds a item into the container. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Parameters:
item - the item to insert
index - the insert location

isLayoutNeeded

protected boolean isLayoutNeeded()

layout

protected boolean layout()
Executes the container's layout. If a layout has not been set a FlowLayout will be used.

Returns:
true if layout was executed.

layout

protected boolean layout(boolean force)
* Executes the container's layout. If a layout has not been set a FlowLayout will be used.

Parameters:
force - true to force the layout call, also if caching things it is not needed
Returns:
true if layout was executed.

notifyHide

protected void notifyHide()
Overrides:
notifyHide in class Component

notifyShow

protected void notifyShow()
Overrides:
notifyShow in class Component

onAfterLayout

protected void onAfterLayout()

onAttach

protected void onAttach()
Overrides:
onAttach in class Component

onBeforeLayoutExcecuted

protected void onBeforeLayoutExcecuted(Layout layout)

onInsert

protected void onInsert(T item,
                        int index)

onLayoutExcecuted

protected void onLayoutExcecuted(Layout layout)

onRemove

protected void onRemove(T item)

orphan

protected final void orphan(T child)

remove

protected boolean remove(T item)
Removes the item from the container. Fires the BeforeRemove event before removing, then fires the Remove event after the widget has been removed.

Parameters:
item - the item to remove
Returns:
true if the item was removed

remove

protected boolean remove(T component,
                         boolean force)

removeAll

protected boolean removeAll(boolean force)

setLayout

protected void setLayout(Layout layout)
Sets the container's layout.

Parameters:
layout - the new layout

setLayoutNeeded

protected void setLayoutNeeded(boolean layoutNeeded)

setLayoutOnChange

protected void setLayoutOnChange(boolean change)

wrapWidget

protected Component wrapWidget(com.google.gwt.user.client.ui.Widget widget)
Helper Method for the subclasses that wish to support automatic wrapping of Widget instances in WidgetComponents

If the widget is a component, no wrapping is performed

Parameters:
widget - the widget to be wrapped
Returns:
the new component