public class TabPanel extends Component implements HasActiveWidget, BeforeCloseEvent.HasBeforeCloseHandlers<Widget>, CloseEvent.HasCloseHandlers<Widget>, HasLayout
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));
Modifier and Type | Class and Description |
---|---|
protected class |
TabPanel.DefaultTabPanelMessages |
static interface |
TabPanel.TabPanelAppearance |
static interface |
TabPanel.TabPanelBottomAppearance |
static interface |
TabPanel.TabPanelMessages |
Modifier and Type | Field and Description |
---|---|
protected Menu |
closeContextMenu |
adjustSize, allowTextSelection, cacheSizes, disableContextMenu, disabled, disabledStyle, ensureVisibilityOnSizing, height, hidden, lastSize, layer, left, mask, maskMessage, monitorWindowResize, pageX, pageY, resizeHandler, shim, tabIndex, toolTip, toolTipConfig, top, width, windowResizeDelay, windowResizeTask
Constructor and Description |
---|
TabPanel()
Creates a new tab panel with the default appearance.
|
TabPanel(TabPanel.TabPanelAppearance appearance)
Creates a new tab panel with the specified appearance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(IsWidget widget,
String text)
Adds an item to the tab panel with the specified text.
|
void |
add(IsWidget widget,
TabItemConfig config)
Adds an item to the tab panel with the specified tab configuration.
|
void |
add(Widget w) |
void |
add(Widget widget,
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(<any> handler) |
HandlerRegistration |
addCloseHandler(CloseEvent.CloseHandler<Widget> handler)
Adds a
CloseEvent.CloseHandler handler for CloseEvent events. |
HandlerRegistration |
addSelectionHandler(<any> handler) |
void |
clear() |
protected void |
close(Widget item) |
protected void |
doAttachChildren() |
protected void |
doDetachChildren() |
protected Element |
findItem(Element target) |
Widget |
findItem(String id,
boolean alsoCheckText)
Searches for a child widget based on its id and optionally the text of the
TabItemConfig . |
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.
|
TabPanel.TabPanelAppearance |
getAppearance() |
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.
|
protected XElement |
getStripWrap() |
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. |
protected int |
itemIndex(Element item) |
Iterator<Widget> |
iterator() |
protected void |
onAfterFirstAttach()
Called immediately after the first time the widget becomes attached to the browser's document only the first time.
|
protected void |
onAttach() |
protected void |
onBlur(Event event) |
void |
onBrowserEvent(Event event) |
protected void |
onClick(Event event) |
protected void |
onDetach() |
protected void |
onFocus(Event event) |
protected void |
onItemContextMenu(Widget item,
int x,
int y) |
protected void |
onItemTextChange(Widget tabItem,
String oldText,
String newText) |
protected void |
onResize(int width,
int height)
Called after the widget 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 |
onRightClick(Event event) |
protected void |
onTap(Event event) |
protected void |
onUnload() |
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 |
setActiveWidget(Widget item,
boolean fireEvents)
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.
|
addBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addGestureRecognizer, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleDependentName, addStyleOnOver, adjustPosition, adjustSize, applyState, assertAfterRender, assertPreRender, blur, clearSizeCache, disable, disableContextMenu, disableEvents, enable, enableEvents, fireCancellableEvent, fireEvent, focus, getData, getElement, getFocusEl, getFocusSupport, getGestureRecognizer, getGestureRecognizerCount, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getPositionEl, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideShadow, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, notifyHide, notifyShow, onDisable, onEnable, onHide, onHideContextMenu, onLoad, onPosition, onShow, onShowContextMenu, onTouch, onWindowResize, removeStyleDependentName, removeStyleOnOver, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setMonitorWindowResize, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setStyleDependentName, setTabIndex, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmask
protected Menu closeContextMenu
public TabPanel()
public TabPanel(TabPanel.TabPanelAppearance appearance)
appearance
- the appearance of the tab panelpublic void add(IsWidget widget, TabItemConfig config)
widget
- the widget to add to the tab panelconfig
- the configuration of the tabpublic void add(IsWidget widget, String text)
widget
- the widget to add to the tab paneltext
- the text for the tabpublic void add(Widget w)
public void add(Widget widget, String text)
add(Widget, TabItemConfig)
.widget
- the widget to add to the tab paneltext
- the text for the tabpublic void add(Widget widget, TabItemConfig config)
widget
- the item to add to the tab panelconfig
- the configuration of the tabpublic HandlerRegistration addBeforeCloseHandler(BeforeCloseEvent.BeforeCloseHandler<Widget> handler)
BeforeCloseEvent.HasBeforeCloseHandlers
BeforeCloseEvent.BeforeCloseHandler
handler for BeforeCloseEvent
events.addBeforeCloseHandler
in interface BeforeCloseEvent.HasBeforeCloseHandlers<Widget>
handler
- the handlerpublic HandlerRegistration addBeforeSelectionHandler(<any> handler)
public HandlerRegistration addCloseHandler(CloseEvent.CloseHandler<Widget> handler)
CloseEvent.HasCloseHandlers
CloseEvent.CloseHandler
handler for CloseEvent
events.addCloseHandler
in interface CloseEvent.HasCloseHandlers<Widget>
handler
- the handlerpublic HandlerRegistration addSelectionHandler(<any> handler)
public void clear()
public Widget findItem(String id, boolean alsoCheckText)
TabItemConfig
.
Iterates through each item and checks if its id matches the parameter id
. Then, if the
alsoCheckText
parameter is true, this also looks at the last passed in string of html or text for each
TabItemConfig
. If that content matches, then it returns that tab.
With alsoCheckText
set to true, the first matching item will be returned.
id
- the item idalsoCheckText
- false
to only compare with id, true
to compare both the items id and textpublic void forceLayout()
HasLayout
HasLayout
to lay out its child
widgets.forceLayout
in interface HasLayout
public Widget getActiveWidget()
HasActiveWidget
getActiveWidget
in interface HasActiveWidget
public TabPanel.TabPanelAppearance getAppearance()
public boolean getAnimScroll()
public boolean getBodyBorder()
public TabItemConfig getConfig(Widget widget)
widget
- the widgetpublic CardLayoutContainer getContainer()
public TabPanel.TabPanelMessages getMessages()
public int getMinTabWidth()
public boolean getResizeTabs()
public int getScrollDuration()
public int getTabMargin()
public boolean getTabScroll()
public int getTabWidth()
public Widget getWidget(int index)
public int getWidgetCount()
public int getWidgetIndex(IsWidget child)
public int getWidgetIndex(Widget widget)
public void insert(Widget widget, int index, TabItemConfig config)
widget
- the item to insertindex
- the insert indexconfig
- the configuration of the tab itempublic boolean isAutoSelect()
public boolean isCloseContextMenu()
public boolean isLayoutRunning()
HasLayout
HasLayout
is in the process of laying out it's children. Useful in avoiding recursive
lay out operations.isLayoutRunning
in interface HasLayout
public boolean isOrWasLayoutRunning()
HasLayout
HasLayout
is in the process of laying out it's children or has performed a lay out in
the past.isOrWasLayoutRunning
in interface HasLayout
public Iterator<Widget> iterator()
public void onBrowserEvent(Event event)
onBrowserEvent
in class Component
public boolean remove(int index)
public boolean remove(Widget child)
public void scrollToTab(Widget item, boolean animate)
item
- the item to scroll toanimate
- true to animate the scrollpublic void setActiveWidget(IsWidget widget)
setActiveWidget
in interface HasActiveWidget
widget
- the widgetpublic void setActiveWidget(Widget item, boolean fireEvents)
item
- the widgetfireEvents
- true
to fire eventspublic void setActiveWidget(Widget item)
HasActiveWidget
setActiveWidget
in interface HasActiveWidget
item
- the widgetpublic void setAnimScroll(boolean animScroll)
tabScroll
= true.animScroll
- the animation scroll statepublic void setAutoSelect(boolean autoSelect)
autoSelect
- the auto select statepublic void setBodyBorder(boolean bodyBorder)
bodyBorder
- the body border stylepublic void setCloseContextMenu(boolean closeMenu)
closeMenu
- true to show itpublic void setMessages(TabPanel.TabPanelMessages messages)
messages
- the messagespublic void setMinTabWidth(int minTabWidth)
resizeTabs
= true (defaults to 30).minTabWidth
- the minimum tab widthpublic void setResizeTabs(boolean resizeTabs)
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)
.resizeTabs
- true to enable tab resizingpublic void setScrollDuration(int scrollDuration)
scrollDuration
- the scroll durationpublic void setScrollIncrement(int scrollIncrement)
setResizeTabs(boolean)
= true, the calculated tab width). Only applies when setTabScroll(boolean)
= true.scrollIncrement
- the scroll incrementpublic void setTabMargin(int tabMargin)
tabMargin
- the tab marginpublic void setTabScroll(boolean tabScroll)
tabScroll
- true to enable tab scrollingpublic void setTabWidth(int tabWidth)
tabWidth
- the tab widthpublic void update(Widget widget, TabItemConfig config)
widget
- the widget for the tab to updateconfig
- the new or updated tab item configurationprotected void close(Widget item)
protected void doAttachChildren()
protected void doDetachChildren()
protected Element findItem(Element target)
protected XElement getStripWrap()
protected int itemIndex(Element item)
protected void onAfterFirstAttach()
Component
onAfterFirstAttach
in class Component
protected void onClick(Event event)
protected void onItemContextMenu(Widget item, int x, int y)
protected void onResize(int width, int height)
Component
protected void onRightClick(Event event)
onRightClick
in class Component
protected void onTap(Event event)
Copyright © 2018. All rights reserved.