com.sencha.gxt.widget.core.client
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.sencha.gxt.widget.core.client.Component
              extended by com.sencha.gxt.widget.core.client.TabPanel
All Implemented Interfaces:
HasAttachHandlers, HasBeforeSelectionHandlers<Widget>, HasResizeHandlers, HasSelectionHandlers<Widget>, HasHandlers, EventListener, HasEnabled, HasVisibility, HasWidgets, IndexedPanel, IndexedPanel.ForIsWidget, IsWidget, HasActiveWidget, HasLayout, BeforeCloseEvent.HasBeforeCloseHandlers<Widget>, BeforeHideEvent.HasBeforeHideHandlers, BeforeShowContextMenuEvent.HasBeforeShowContextMenuHandler, BeforeShowEvent.HasBeforeShowHandlers, BlurEvent.HasBlurHandlers, CloseEvent.HasCloseHandlers<Widget>, DisableEvent.HasDisableHandlers, EnableEvent.HasEnableHandlers, FocusEvent.HasFocusHandlers, HideEvent.HasHideHandlers, MoveEvent.HasMoveHandlers, ShowContextMenuEvent.HasShowContextMenuHandler, ShowEvent.HasShowHandlers, HasFocusSupport, HasItemId, java.lang.Iterable<Widget>
Direct Known Subclasses:
PlainTabPanel

public class TabPanel
extends Component
implements IndexedPanel.ForIsWidget, HasActiveWidget, HasBeforeSelectionHandlers<Widget>, HasSelectionHandlers<Widget>, BeforeCloseEvent.HasBeforeCloseHandlers<Widget>, CloseEvent.HasCloseHandlers<Widget>, HasLayout, HasWidgets

A basic tab container.

Code snippet:

   TabPanel panel = new TabPanel();
   panel.setTabScroll(true);
   panel.setAnimScroll(true);
   panel.add(new Label("Tab 1 Content"), new TabItemConfig("Tab 1", true));
   panel.add(new Label("Tab 2 Content"), new TabItemConfig("Tab 2", true));
 


Nested Class Summary
static interface TabPanel.TabPanelAppearance
           
static interface TabPanel.TabPanelMessages
           
 
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.IndexedPanel
IndexedPanel.ForIsWidget
 
Nested classes/interfaces inherited from interface com.google.gwt.user.client.ui.HasWidgets
HasWidgets.ForIsWidget
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
TabPanel()
          Creates a new tab panel with the default appearance.
TabPanel(TabPanel.TabPanelAppearance appearance)
          Creates a new tab panel with the specified appearance.
 
Method Summary
 void add(IsWidget widget, TabItemConfig config)
          Adds an item to the tab panel with the specified text.
 void add(Widget w)
           
 void add(Widget widget, java.lang.String text)
          Adds an item to the tab panel with the specified text.
 void add(Widget widget, TabItemConfig config)
          Adds an item to the tab panel with the specified tab configuration.
 HandlerRegistration addBeforeCloseHandler(BeforeCloseEvent.BeforeCloseHandler<Widget> handler)
          Adds a BeforeCloseEvent.BeforeCloseHandler handler for BeforeCloseEvent events.
 HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Widget> handler)
           
 HandlerRegistration addCloseHandler(CloseEvent.CloseHandler<Widget> handler)
          Adds a CloseEvent.CloseHandler handler for CloseEvent events.
 HandlerRegistration addSelectionHandler(SelectionHandler<Widget> handler)
           
 void clear()
           
 Widget findItem(java.lang.String id, boolean checkText)
          Searches for an item based on its id and optionally the item's text.
 void forceLayout()
          Forces a class that implements HasLayout to lay out its child widgets.
 Widget getActiveWidget()
          Returns the active widget.
 boolean getAnimScroll()
          Returns true if scrolling is animated.
 boolean getBodyBorder()
          Returns true if the body border is enabled.
 TabItemConfig getConfig(Widget widget)
          Returns the tab item config for the given widget.
 CardLayoutContainer getContainer()
          Returns the internal card layout container.
 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.
 int getTabMargin()
          Returns the panel's tab margin.
 boolean getTabScroll()
          Returns true if tab scrolling is enabled.
 int getTabWidth()
          Returns the default tab width.
 Widget getWidget(int index)
           
 int getWidgetCount()
           
 int getWidgetIndex(IsWidget child)
           
 int getWidgetIndex(Widget widget)
           
 void insert(Widget widget, int index, TabItemConfig config)
          Inserts the specified item into the tab panel.
 boolean isAutoSelect()
          Returns true if auto select is enabled.
 boolean isCloseContextMenu()
          Returns true if close context menu is enabled.
 boolean isLayoutRunning()
          Returns true if invoked when a class that implements HasLayout is in the process of laying out it's children.
 boolean isOrWasLayoutRunning()
          Returns true if invoked when a class that implements HasLayout is in the process of laying out it's children or has performed a lay out in the past.
 java.util.Iterator<Widget> iterator()
           
 void onBrowserEvent(Event event)
           
 boolean remove(int index)
           
 boolean remove(Widget child)
           
 void scrollToTab(Widget item, boolean animate)
          Scrolls to a particular tab if tab scrolling is enabled.
 void setActiveWidget(IsWidget widget)
          Sets the active widget.
 void setActiveWidget(Widget item)
          Sets the active widget.
 void setAnimScroll(boolean animScroll)
          True to animate tab scrolling so that hidden tabs slide smoothly into view (defaults to true).
 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 setCloseContextMenu(boolean closeMenu)
          True to show the close context menu (defaults to false).
 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 setResizeTabs(boolean resizeTabs)
          True to automatically resize tabs.
 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 setTabMargin(int tabMargin)
          The number of pixels of space to calculate into the sizing and scrolling of tabs (defaults to 2).
 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).
 void update(Widget widget, TabItemConfig config)
          Updates the appearance of the specified tab item.
 
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, disable, disableEvents, enable, 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
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

TabPanel

public TabPanel()
Creates a new tab panel with the default appearance.


TabPanel

public TabPanel(TabPanel.TabPanelAppearance appearance)
Creates a new tab panel with the specified appearance.

Parameters:
appearance - the appearance of the tab panel
Method Detail

add

@UiChild(tagname="child")
public void add(IsWidget widget,
                               TabItemConfig config)
Adds an item to the tab panel with the specified text.

Parameters:
widget -
config - the configuration of the tab

add

public void add(Widget w)
Specified by:
add in interface HasWidgets

add

public void add(Widget widget,
                java.lang.String text)
Adds an item to the tab panel with the specified text. Shorthand for add(Widget, TabItemConfig).

Parameters:
widget - the widget to add to the tab panel
text - the text for the tab

add

public void add(Widget widget,
                TabItemConfig config)
Adds an item to the tab panel with the specified tab configuration.

Parameters:
widget - the item to add to the tab panel
config - the configuration of the tab

addBeforeCloseHandler

public HandlerRegistration addBeforeCloseHandler(BeforeCloseEvent.BeforeCloseHandler<Widget> handler)
Description copied from interface: BeforeCloseEvent.HasBeforeCloseHandlers
Adds a BeforeCloseEvent.BeforeCloseHandler handler for BeforeCloseEvent events.

Specified by:
addBeforeCloseHandler in interface BeforeCloseEvent.HasBeforeCloseHandlers<Widget>
Parameters:
handler - the handler
Returns:
the registration for the event

addBeforeSelectionHandler

public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Widget> handler)
Specified by:
addBeforeSelectionHandler in interface HasBeforeSelectionHandlers<Widget>

addCloseHandler

public HandlerRegistration addCloseHandler(CloseEvent.CloseHandler<Widget> handler)
Description copied from interface: CloseEvent.HasCloseHandlers
Adds a CloseEvent.CloseHandler handler for CloseEvent events.

Specified by:
addCloseHandler in interface CloseEvent.HasCloseHandlers<Widget>
Parameters:
handler - the handler
Returns:
the registration for the event

addSelectionHandler

public HandlerRegistration addSelectionHandler(SelectionHandler<Widget> handler)
Specified by:
addSelectionHandler in interface HasSelectionHandlers<Widget>

clear

public void clear()
Specified by:
clear in interface HasWidgets

findItem

public Widget 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

forceLayout

public void forceLayout()
Description copied from interface: HasLayout
Forces a class that implements HasLayout to lay out its child widgets.

Specified by:
forceLayout in interface HasLayout

getActiveWidget

public Widget getActiveWidget()
Description copied from interface: HasActiveWidget
Returns the active widget.

Specified by:
getActiveWidget in interface HasActiveWidget
Returns:
the active widget

getAnimScroll

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

Returns:
the animation scroll state

getBodyBorder

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

Returns:
the body border state

getConfig

public TabItemConfig getConfig(Widget widget)
Returns the tab item config for the given widget.

Parameters:
widget - the widget
Returns:
the config or null

getContainer

public CardLayoutContainer getContainer()
Returns the internal card layout container.

Returns:
the card layout container

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

getTabMargin

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

Returns:
the margin

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

getWidget

public Widget getWidget(int index)
Specified by:
getWidget in interface IndexedPanel

getWidgetCount

public int getWidgetCount()
Specified by:
getWidgetCount in interface IndexedPanel

getWidgetIndex

public int getWidgetIndex(IsWidget child)
Specified by:
getWidgetIndex in interface IndexedPanel.ForIsWidget

getWidgetIndex

public int getWidgetIndex(Widget widget)
Specified by:
getWidgetIndex in interface IndexedPanel

insert

public void insert(Widget widget,
                   int index,
                   TabItemConfig config)
Inserts the specified item into the tab panel.

Parameters:
widget - the item to insert
index - the insert index
config - the configuration of the tab item

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

isLayoutRunning

public boolean isLayoutRunning()
Description copied from interface: HasLayout
Returns true if invoked when a class that implements HasLayout is in the process of laying out it's children. Useful in avoiding recursive lay out operations.

Specified by:
isLayoutRunning in interface HasLayout
Returns:
true if in the process of performing a lay out operation

isOrWasLayoutRunning

public boolean isOrWasLayoutRunning()
Description copied from interface: HasLayout
Returns true if invoked when a class that implements HasLayout is in the process of laying out it's children or has performed a lay out in the past.

Specified by:
isOrWasLayoutRunning in interface HasLayout
Returns:
true if a layout is running or has run, false if a layout has not yet been performed.

iterator

public java.util.Iterator<Widget> iterator()
Specified by:
iterator in interface HasWidgets
Specified by:
iterator in interface java.lang.Iterable<Widget>

onBrowserEvent

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

remove

public boolean remove(int index)
Specified by:
remove in interface IndexedPanel

remove

public boolean remove(Widget child)
Specified by:
remove in interface HasWidgets

scrollToTab

public void scrollToTab(Widget 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

setActiveWidget

public void setActiveWidget(IsWidget widget)
Sets the active widget.

Parameters:
widget - the widget

setActiveWidget

public void setActiveWidget(Widget item)
Description copied from interface: HasActiveWidget
Sets the active widget.

Specified by:
setActiveWidget in interface HasActiveWidget
Parameters:
item - the widget

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 animation scroll state

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

setCloseContextMenu

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

Parameters:
closeMenu - true to show it

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

setResizeTabs

public void setResizeTabs(boolean resizeTabs)
True to automatically resize tabs. The resize operation takes into consideration the current width of the tab panel as well as the current values of setTabWidth(int) and setMinTabWidth(int). The resulting tab width will not be less than the value specified by setMinTabWidth nor greater than the value specified by setTabWidth. To automatically resize the tabs to completely fill the tab strip, use setTabWidth(Integer.MAX_VALUE) and setResizeTabs(true).

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

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

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 - the tab width

update

public void update(Widget widget,
                   TabItemConfig config)
Updates the appearance of the specified tab item. Must be invoked after changing the tab item configuration.

Parameters:
widget - the widget for the tab to update
config - the new or updated tab item configuration


Copyright © 2012. All Rights Reserved.