com.extjs.gxt.ui.client.widget
Class TabPanel

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<TabItem>
                      extended by com.extjs.gxt.ui.client.widget.TabPanel
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

public class TabPanel
extends Container<TabItem>

A basic tab container.

 TabPanel panel = new TabPanel();
 panel.setResizeTabs(true);
 panel.setEnableTabScroll(true);
 panel.setAnimScroll(true);
 
 TabItem item = new TabItem();
 item.setClosable(true);
 item.setText("Tab Item");
 
 item.setLayout(new FitLayout());
 item.add(new Label("Test Content"));
 
 panel.add(item);
 
Events:
BeforeSelect : TabPanelEvent(container, item)
Fires after an item is selected. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Select : TabPanelEvent(container, item)
Fires after a item is selected.
BeforeAdd : TabPanelEvent(container, item, index)
Fires before a item is added or inserted. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
BeforeRemove : TabPanelEvent(container, item)
Fires before a item is removed. Listeners can cancel the action by calling BaseEvent.setCancelled(boolean).
Add : TabPanelEvent(container, item, index)
Fires after a item has been added or inserted.
Remove : TabPanelEvent(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
 class TabPanel.TabPanelMessages
          TabPanel messages.
static class TabPanel.TabPosition
          Tab position enumeration.
 
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  Menu closeContextMenu
           
static Template itemTemplate
          Default tab item template.
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Container
attachChildren, enableLayout, layoutExecuted, layoutNeeded, layoutOnAttach, layoutOnChange
 
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
TabPanel()
          Creates a new tab panel.
 
Method Summary
 boolean add(TabItem item)
          Adds a tab item.
protected  void close(TabItem item)
           
protected  ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
           
protected  ContainerEvent createContainerEvent(TabItem item)
           
protected  void doAttachChildren()
           
protected  void doDetachChildren()
           
 TabItem findItem(java.lang.String id, boolean checkText)
          Searches for an item based on its id and optionally the item's text.
 boolean getAnimScroll()
          Returns true if scrolling is animated.
 boolean getBodyBorder()
          Returns true if the body border is enabled.
 boolean getBorderStyle()
          Returns true if the border style is enabled.
 CardLayout getLayout()
           
 El getLayoutTarget()
          Returns the container's layout target.
 TabPanel.TabPanelMessages getMessages()
          Returns the tab panel messages.
 int getMinTabWidth()
          Returns the minimum tab width.
 boolean getResizeTabs()
          Returns true if tab resizing is enabled.
 int getScrollDuration()
          Returns the scroll duration in milliseconds.
 TabItem getSelectedItem()
          Returns the current selection tab item.
 int getTabMargin()
          Returns the panel's tab margin.
 TabPanel.TabPosition getTabPosition()
          Returns the tab position.
 boolean getTabScroll()
          Returns true if tab scrolling is enabled.
 int getTabWidth()
          Returns the default tab width.
 boolean insert(TabItem item, int index)
          Adds a tab item.
 boolean isAutoSelect()
          Returns true if auto select is enabled.
 boolean isCloseContextMenu()
          Returns true if close context menu is enabled.
 boolean isDeferredRender()
          Returns true if children items are rendered when first accessed.
 boolean isPlain()
          Returns true if the tab strip will be rendered without a background.
protected  void onAfterLayout()
           
protected  void onAttach()
           
protected  void onBlur(ComponentEvent ce)
           
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
protected  void onDetach()
           
protected  void onFocus(ComponentEvent ce)
           
protected  void onInsert(TabItem item, int index)
           
protected  void onItemContextMenu(TabItem item, int x, int y)
           
protected  void onItemTextChange(TabItem tabItem, java.lang.String oldText, java.lang.String newText)
           
protected  void onKeyPress(ComponentEvent ce)
           
protected  void onLeft(ComponentEvent ce)
           
protected  void onRemove(TabItem item)
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onResize(int width, int height)
          Called after the component 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.
protected  void onRight(ComponentEvent ce)
           
protected  void onUnload()
           
 boolean remove(TabItem item)
          Removes the tab item.
 boolean removeAll()
          Removes all the container's items.
 void scrollToTab(TabItem item, boolean animate)
          Scrolls to a particular tab if tab scrolling is enabled.
 void setAnimScroll(boolean animScroll)
          True to animate tab scrolling so that hidden tabs slide smoothly into view (defaults to true).
 void setAutoHeight(boolean autoHeight)
          Sets the component's auto height value (defaults to false).
 void setAutoSelect(boolean autoSelect)
          True to have the first item selected when the panel is displayed for the first time if there is not selection (defaults to true).
 void setBodyBorder(boolean bodyBorder)
          True to display an interior border on the body element of the panel, false to hide it (defaults to true, pre-render).
 void setBorderStyle(boolean border)
          True to display a border around the tabs (defaults to true).
 void setCloseContextMenu(boolean closeMenu)
          True to show the close context menu (defaults to false).
 void setDeferredRender(boolean deferredRender)
          True to render each child tab item when it accessed, false to render all (defaults to true).
 void setMessages(TabPanel.TabPanelMessages messages)
          Sets the tab panel messages.
 void setMinTabWidth(int minTabWidth)
          The minimum width in pixels for each tab when resizeTabs = true (defaults to 30).
 void setPlain(boolean plain)
          True to render the tab strip without a background container image (defaults to false, pre-render).
 void setResizeTabs(boolean resizeTabs)
          True to automatically resize each tab so that the tabs will completely fill the tab strip (defaults to false).
 void setScrollDuration(int scrollDuration)
          Sets the number of milliseconds that each scroll animation should last (defaults to 150).
 void setScrollIncrement(int scrollIncrement)
          Sets the number of pixels to scroll each time a tab scroll button is pressed (defaults to 100, or if setResizeTabs(boolean) = true, the calculated tab width).
 void setSelection(TabItem item)
          Sets the selected tab item.
 void setTabMargin(int tabMargin)
          The number of pixels of space to calculate into the sizing and scrolling of tabs (defaults to 2).
 void setTabPosition(TabPanel.TabPosition tabPosition)
          Sets the position where the tab strip should be rendered (defaults to TOP, pre-render).
 void setTabScroll(boolean tabScroll)
          True to enable scrolling to tabs that may be invisible due to overflowing the overall TabPanel width.
 void setTabWidth(int tabWidth)
          Sets the initial width in pixels of each new tab (defaults to 120).
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Container
adjustIndex, adopt, disable, doLayout, doLayout, enable, findItem, getItem, getItemByItemId, getItemCount, getItems, getWidget, indexOf, isLayoutNeeded, iterator, layout, layout, notifyHide, notifyShow, onBeforeLayoutExcecuted, onLayoutExcecuted, orphan, remove, removeAll, scrollIntoView, setLayout, setLayoutNeeded, setLayoutOnChange, wrapWidget
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, afterRender, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onHide, onPosition, onShow, 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, onDetachHelper, onDisable, onEnable, onEnsureDebugId, onHideContextMenu, onLoad, 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

itemTemplate

public static Template itemTemplate
Default tab item template.


closeContextMenu

protected Menu closeContextMenu
Constructor Detail

TabPanel

public TabPanel()
Creates a new tab panel.

Method Detail

add

public boolean add(TabItem item)
Adds a tab item. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Overrides:
add in class Container<TabItem>
Parameters:
item - the item to be added

findItem

public TabItem findItem(java.lang.String id,
                        boolean checkText)
Searches for an item based on its id and optionally the item's text.

Parameters:
id - the item id
checkText - true to match the items id and text
Returns:
the item

getAnimScroll

public boolean getAnimScroll()
Returns true if scrolling is animated.

Returns:
the anim scroll state

getBodyBorder

public boolean getBodyBorder()
Returns true if the body border is enabled.

Returns:
the body border state

getBorderStyle

public boolean getBorderStyle()
Returns true if the border style is enabled.

Returns:
the border style

getLayout

public CardLayout getLayout()
Overrides:
getLayout in class Container<TabItem>

getLayoutTarget

public El getLayoutTarget()
Description copied from class: Container
Returns the container's layout target. Only applies to container's with layouts.

Overrides:
getLayoutTarget in class Container<TabItem>
Returns:
the layout target

getMessages

public TabPanel.TabPanelMessages getMessages()
Returns the tab panel messages.

Returns:
the messages

getMinTabWidth

public int getMinTabWidth()
Returns the minimum tab width.

Returns:
the minimum tab width

getResizeTabs

public boolean getResizeTabs()
Returns true if tab resizing is enabled.

Returns:
the tab resizing state

getScrollDuration

public int getScrollDuration()
Returns the scroll duration in milliseconds.

Returns:
the duration

getSelectedItem

public TabItem getSelectedItem()
Returns the current selection tab item.

Returns:
the selected item

getTabMargin

public int getTabMargin()
Returns the panel's tab margin.

Returns:
the margin

getTabPosition

public TabPanel.TabPosition getTabPosition()
Returns the tab position.

Returns:
the tab position

getTabScroll

public boolean getTabScroll()
Returns true if tab scrolling is enabled.

Returns:
the tab scroll state

getTabWidth

public int getTabWidth()
Returns the default tab width.

Returns:
the width

insert

public boolean insert(TabItem item,
                      int index)
Adds a tab item. Fires the BeforeAdd event before inserting, then fires the Add event after the widget has been inserted.

Overrides:
insert in class Container<TabItem>
Parameters:
item - the item to be inserted
index - the insert position

isAutoSelect

public boolean isAutoSelect()
Returns true if auto select is enabled.

Returns:
the auto select state

isCloseContextMenu

public boolean isCloseContextMenu()
Returns true if close context menu is enabled.

Returns:
the close menu state

isDeferredRender

public boolean isDeferredRender()
Returns true if children items are rendered when first accessed.

Returns:
true to defer rendering

isPlain

public boolean isPlain()
Returns true if the tab strip will be rendered without a background.

Returns:
the plain state

onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class Component
Parameters:
ce - the base event

remove

public boolean remove(TabItem item)
Removes the tab item. Fires the BeforeRemove event before removing, then fires the Remove event after the widget has been removed.

Overrides:
remove in class Container<TabItem>
Parameters:
item - the item to be removed
Returns:
true if the item was removed

removeAll

public boolean removeAll()
Description copied from class: Container
Removes all the container's items.

Overrides:
removeAll in class Container<TabItem>
Returns:
true if all items where removed

scrollToTab

public void scrollToTab(TabItem item,
                        boolean animate)
Scrolls to a particular tab if tab scrolling is enabled.

Parameters:
item - the item to scroll to
animate - true to animate the scroll

setAnimScroll

public void setAnimScroll(boolean animScroll)
True to animate tab scrolling so that hidden tabs slide smoothly into view (defaults to true). Only applies when tabScroll = true.

Parameters:
animScroll - the anim scroll state

setAutoHeight

public void setAutoHeight(boolean autoHeight)
Description copied from class: BoxComponent
Sets the component's auto height value (defaults to false).

Overrides:
setAutoHeight in class BoxComponent
Parameters:
autoHeight - true to enable auto height

setAutoSelect

public void setAutoSelect(boolean autoSelect)
True to have the first item selected when the panel is displayed for the first time if there is not selection (defaults to true).

Parameters:
autoSelect - the auto select state

setBodyBorder

public void setBodyBorder(boolean bodyBorder)
True to display an interior border on the body element of the panel, false to hide it (defaults to true, pre-render).

Parameters:
bodyBorder - the body border style

setBorderStyle

public void setBorderStyle(boolean border)
True to display a border around the tabs (defaults to true).

Parameters:
border - true for borders

setCloseContextMenu

public void setCloseContextMenu(boolean closeMenu)
True to show the close context menu (defaults to false).

Parameters:
closeMenu - true to show it

setDeferredRender

public void setDeferredRender(boolean deferredRender)
True to render each child tab item when it accessed, false to render all (defaults to true). Setting to false would be useful when using forms as validation would need to be applied to all children even if they had not been selected.

Parameters:
deferredRender - true to defer rendering

setMessages

public void setMessages(TabPanel.TabPanelMessages messages)
Sets the tab panel messages.

Parameters:
messages - the messages

setMinTabWidth

public void setMinTabWidth(int minTabWidth)
The minimum width in pixels for each tab when resizeTabs = true (defaults to 30).

Parameters:
minTabWidth - the minimum tab width

setPlain

public void setPlain(boolean plain)
True to render the tab strip without a background container image (defaults to false, pre-render).

Parameters:
plain -

setResizeTabs

public void setResizeTabs(boolean resizeTabs)
True to automatically resize each tab so that the tabs will completely fill the tab strip (defaults to false). Setting this to true may cause specific widths that might be set per tab to be overridden in order to fit them all into view (although minTabWidth will always be honored).

Parameters:
resizeTabs - true to enable tab resizing

setScrollDuration

public void setScrollDuration(int scrollDuration)
Sets the number of milliseconds that each scroll animation should last (defaults to 150).

Parameters:
scrollDuration - the scroll duration

setScrollIncrement

public void setScrollIncrement(int scrollIncrement)
Sets the number of pixels to scroll each time a tab scroll button is pressed (defaults to 100, or if setResizeTabs(boolean) = true, the calculated tab width). Only applies when setTabScroll(boolean) = true.

Parameters:
scrollIncrement - the scroll increment

setSelection

public void setSelection(TabItem item)
Sets the selected tab item. Fires the BeforeSelect event before selecting, then fires the Select event after the widget has been selected.

Parameters:
item - the item to be selected

setTabMargin

public void setTabMargin(int tabMargin)
The number of pixels of space to calculate into the sizing and scrolling of tabs (defaults to 2).

Parameters:
tabMargin - the tab margin

setTabPosition

public void setTabPosition(TabPanel.TabPosition tabPosition)
Sets the position where the tab strip should be rendered (defaults to TOP, pre-render). The only other supported value is BOTTOM. Note that tab scrolling is only supported for position TOP.

Parameters:
tabPosition - the tab position

setTabScroll

public void setTabScroll(boolean tabScroll)
True to enable scrolling to tabs that may be invisible due to overflowing the overall TabPanel width. Only available with tabs on top. (defaults to false).

Parameters:
tabScroll - true to enable tab scrolling

setTabWidth

public void setTabWidth(int tabWidth)
Sets the initial width in pixels of each new tab (defaults to 120).

Parameters:
tabWidth -

close

protected void close(TabItem item)

createComponentEvent

protected ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class BoxComponent

createContainerEvent

protected ContainerEvent createContainerEvent(TabItem item)
Overrides:
createContainerEvent in class Container<TabItem>

doAttachChildren

protected void doAttachChildren()
Overrides:
doAttachChildren in class Container<TabItem>

doDetachChildren

protected void doDetachChildren()
Overrides:
doDetachChildren in class Container<TabItem>

onAfterLayout

protected void onAfterLayout()
Overrides:
onAfterLayout in class Container<TabItem>

onAttach

protected void onAttach()
Overrides:
onAttach in class Container<TabItem>

onBlur

protected void onBlur(ComponentEvent ce)

onDetach

protected void onDetach()
Overrides:
onDetach in class Component

onFocus

protected void onFocus(ComponentEvent ce)

onInsert

protected void onInsert(TabItem item,
                        int index)
Overrides:
onInsert in class Container<TabItem>

onItemContextMenu

protected void onItemContextMenu(TabItem item,
                                 int x,
                                 int y)

onItemTextChange

protected void onItemTextChange(TabItem tabItem,
                                java.lang.String oldText,
                                java.lang.String newText)

onKeyPress

protected void onKeyPress(ComponentEvent ce)

onLeft

protected void onLeft(ComponentEvent ce)

onRemove

protected void onRemove(TabItem item)
Overrides:
onRemove in class Container<TabItem>

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Component
Parameters:
target - the target element
index - the insert location

onResize

protected void onResize(int width,
                        int height)
Description copied from class: BoxComponent
Called after the component 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.

Overrides:
onResize in class BoxComponent
Parameters:
width - the width
height - the height

onRight

protected void onRight(ComponentEvent ce)

onUnload

protected void onUnload()
Overrides:
onUnload in class BoxComponent