public class TabSheet extends AbstractComponentContainer implements Component.Focusable, FieldEvents.FocusNotifier, FieldEvents.BlurNotifier, SelectiveRenderer
ComponentContainer
), and tab metadata (including caption, icon,
visibility, enabledness, closability etc.) is kept in separate TabSheet.Tab
instances.
Tabs added with addComponent(Component)
get the caption and the icon
of the component at the time when the component is created, and these are not
automatically updated after tab creation.
A tab sheet can have multiple tab selection listeners and one tab close
handler (TabSheet.CloseHandler
), which by default removes the tab from the
TabSheet.
The TabSheet
can be styled with the .v-tabsheet, .v-tabsheet-tabs and
.v-tabsheet-content styles. Themes may also have pre-defined variations of
the tab sheet presentation, such as Reindeer.TABSHEET_BORDERLESS
,
Runo.TABSHEET_SMALL
and several other styles in Reindeer
.
The current implementation does not load the tabs to the UI before the first
time they are shown, but this may change in future releases.Modifier and Type | Class and Description |
---|---|
static interface |
TabSheet.CloseHandler
CloseHandler is used to process tab closing events.
|
static class |
TabSheet.SelectedTabChangeEvent
Selected tab change event.
|
static interface |
TabSheet.SelectedTabChangeListener
Selected tab change event listener.
|
static interface |
TabSheet.Tab
Tab meta-data for a component in a
TabSheet . |
protected class |
TabSheet.TabsheetServerRpcImpl
Client to server RPC implementation for TabSheet.
|
class |
TabSheet.TabSheetTabImpl
TabSheet's implementation of
TabSheet.Tab - tab metadata. |
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
Sizeable.Unit
DESIGN_ATTR_PLAIN_TEXT
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
Constructor and Description |
---|
TabSheet()
Constructs a new TabSheet.
|
TabSheet(Component... components)
Constructs a new TabSheet containing the given components.
|
Modifier and Type | Method and Description |
---|---|
void |
addBlurListener(FieldEvents.BlurListener listener)
Adds a
BlurListener to the Component which gets fired
when a Field loses keyboard focus. |
void |
addComponent(Component c)
Adds a new tab into TabSheet.
|
void |
addFocusListener(FieldEvents.FocusListener listener)
Adds a
FocusListener to the Component which gets fired
when a Field receives keyboard focus. |
void |
addListener(FieldEvents.BlurListener listener)
Deprecated.
As of 7.0, replaced by
#addBlurListener(BlurListener) |
void |
addListener(FieldEvents.FocusListener listener)
Deprecated.
As of 7.0, replaced by
#addFocusListener(FocusListener) |
void |
addListener(TabSheet.SelectedTabChangeListener listener)
Deprecated.
As of 7.0, replaced by
addSelectedTabChangeListener(SelectedTabChangeListener) |
void |
addSelectedTabChangeListener(TabSheet.SelectedTabChangeListener listener)
Adds a tab selection listener
|
TabSheet.Tab |
addTab(Component c)
Adds a new tab into TabSheet.
|
TabSheet.Tab |
addTab(Component component,
int position)
Adds a new tab into TabSheet.
|
TabSheet.Tab |
addTab(Component c,
String caption)
Adds a new tab into TabSheet.
|
TabSheet.Tab |
addTab(Component c,
String caption,
Resource icon)
Adds a new tab into TabSheet.
|
TabSheet.Tab |
addTab(Component tabComponent,
String caption,
Resource icon,
int position)
Adds a new tab into TabSheet.
|
boolean |
areTabsHidden()
Deprecated.
as of 7.5, use
isTabsVisible() instead |
protected void |
fireSelectedTabChange()
Sends an event that the currently selected tab has changed.
|
void |
focus()
Sets the focus for this component if the component is
Focusable . |
int |
getComponentCount()
Gets the number of contained components (tabs).
|
protected Collection<String> |
getCustomAttributes()
Returns a collection of attributes that should not be handled by the
basic implementation of the
readDesign and writeDesign
methods. |
Component |
getSelectedTab()
Gets the selected tab content component.
|
protected TabsheetState |
getState()
Returns the shared state bean with information to be sent from the server
to the client.
|
protected TabsheetState |
getState(boolean markAsDirty)
Returns the shared state for this connector.
|
TabSheet.Tab |
getTab(Component c)
Returns the
TabSheet.Tab (metadata) for a component. |
TabSheet.Tab |
getTab(int position)
Returns the
TabSheet.Tab (metadata) for a component. |
int |
getTabIndex()
Gets the tabulator index of the
Focusable component. |
int |
getTabPosition(TabSheet.Tab tab)
Gets the position of the tab
|
void |
hideTabs(boolean tabsHidden)
Deprecated.
as of 7.5, use
setTabsVisible(boolean) instead |
boolean |
isRendered(Component childComponent)
Checks if the child component should be rendered (sent to the client
side).
|
boolean |
isTabCaptionsAsHtml()
Checks whether HTML is allowed in the tab captions.
|
boolean |
isTabsVisible()
Checks if the tab selection part should be shown in the UI
|
Iterator<Component> |
iterator()
Gets the component container iterator for going through all the
components (tab contents).
|
void |
moveComponentsFrom(ComponentContainer source)
Moves all components from another container to this container.
|
void |
readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Reads the component state from the given design.
|
void |
removeBlurListener(FieldEvents.BlurListener listener)
Removes a
BlurListener from the Component. |
void |
removeComponent(Component component)
Removes a component and its corresponding tab.
|
void |
removeFocusListener(FieldEvents.FocusListener listener)
Removes a
FocusListener from the Component. |
void |
removeListener(FieldEvents.BlurListener listener)
Deprecated.
As of 7.0, replaced by
#removeBlurListener(BlurListener) |
void |
removeListener(FieldEvents.FocusListener listener)
Deprecated.
As of 7.0, replaced by
#removeFocusListener(FocusListener) |
void |
removeListener(TabSheet.SelectedTabChangeListener listener)
Deprecated.
As of 7.0, replaced by
removeSelectedTabChangeListener(SelectedTabChangeListener) |
void |
removeSelectedTabChangeListener(TabSheet.SelectedTabChangeListener listener)
Removes a tab selection listener
|
void |
removeTab(TabSheet.Tab tab)
Removes a
TabSheet.Tab and the component associated with it, as previously
added with addTab(Component) ,
addTab(Component, String, Resource) or
addComponent(Component) . |
void |
replaceComponent(Component oldComponent,
Component newComponent)
Replaces a component (tab content) with another.
|
protected int |
selectedTabIndexAfterTabRemove(int removedTabIndex)
Called when a selected tab is removed to specify the new tab to select.
|
void |
setCloseHandler(TabSheet.CloseHandler handler)
Provide a custom
TabSheet.CloseHandler for this TabSheet if you wish to
perform some additional tasks when a user clicks on a tabs close button,
e.g. |
void |
setSelectedTab(Component c)
Sets the selected tab.
|
void |
setSelectedTab(int position)
Sets the selected tab, identified by its position.
|
void |
setSelectedTab(TabSheet.Tab tab)
Sets the selected tab.
|
void |
setTabCaptionsAsHtml(boolean tabCaptionsAsHtml)
Sets whether HTML is allowed in the tab captions.
|
void |
setTabIndex(int tabIndex)
Sets the tabulator index of the
Focusable component. |
void |
setTabPosition(TabSheet.Tab tab,
int position)
Sets the position of the tab.
|
void |
setTabsVisible(boolean tabsVisible)
Sets whether the tab selection part should be shown in the UI
|
void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the component state to the given design.
|
addComponentAttachListener, addComponentDetachListener, addComponents, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, setHeight, setWidth
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidthUndefined
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
getConnectorId
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
forEach, spliterator
public TabSheet()
public TabSheet(Component... components)
components
- The components to add to the tab sheet. Each component will be
added to a separate tab.public Iterator<Component> iterator()
iterator
in interface HasComponents
iterator
in interface Iterable<Component>
public int getComponentCount()
AbstractComponentContainer.getComponentIterator()
.getComponentCount
in interface ComponentContainer
public void removeComponent(Component component)
removeComponent
in interface ComponentContainer
removeComponent
in class AbstractComponentContainer
component
- the component to be removed.ComponentContainer.removeComponent(Component)
protected int selectedTabIndexAfterTabRemove(int removedTabIndex)
removedTabIndex
- the index of the selected tab which was just remove.public void removeTab(TabSheet.Tab tab)
TabSheet.Tab
and the component associated with it, as previously
added with addTab(Component)
,
addTab(Component, String, Resource)
or
addComponent(Component)
.
If the tab was selected, the first eligible (visible and enabled) remaining tab is selected.
tab
- the Tab to removeaddTab(Component)
,
addTab(Component, String, Resource)
,
addComponent(Component)
,
removeComponent(Component)
public void addComponent(Component c)
addComponent
in interface ComponentContainer
addComponent
in class AbstractComponentContainer
c
- the component to be added.addTab(Component)
public TabSheet.Tab addTab(Component c, String caption)
c
- the component to be added onto tab - should not be null.caption
- the caption to be set for the component and used rendered in
tab barTabSheet.Tab
public TabSheet.Tab addTab(Component c, String caption, Resource icon)
c
- the component to be added onto tab - should not be null.caption
- the caption to be set for the component and used rendered in
tab baricon
- the icon to be set for the component and used rendered in tab
barTabSheet.Tab
public TabSheet.Tab addTab(Component tabComponent, String caption, Resource icon, int position)
tabComponent
- the component to be added onto tab - should not be null.caption
- the caption to be set for the component and used rendered in
tab baricon
- the icon to be set for the component and used rendered in tab
barposition
- the position at where the the tab should be added.TabSheet.Tab
public TabSheet.Tab addTab(Component c)
c
- the component to be added onto tab - should not be null.TabSheet.Tab
public TabSheet.Tab addTab(Component component, int position)
component
- the component to be added onto tab - should not be null.position
- The position where the tab should be addedTabSheet.Tab
public void moveComponentsFrom(ComponentContainer source)
TabSheet
, component captions and
icons are copied from it.moveComponentsFrom
in interface ComponentContainer
moveComponentsFrom
in class AbstractComponentContainer
source
- the container components are removed from.@Deprecated public boolean areTabsHidden()
isTabsVisible()
instead@Deprecated public void hideTabs(boolean tabsHidden)
setTabsVisible(boolean)
insteadtabsHidden
- true if the tabs should be hiddenpublic void setTabsVisible(boolean tabsVisible)
tabsVisible
- true if the tabs should be shown in the UI, false otherwisepublic boolean isTabsVisible()
public TabSheet.Tab getTab(Component c)
TabSheet.Tab
(metadata) for a component. The TabSheet.Tab
object can be used for setting caption,icon, etc for the tab.c
- the componentpublic TabSheet.Tab getTab(int position)
TabSheet.Tab
(metadata) for a component. The TabSheet.Tab
object can be used for setting caption,icon, etc for the tab.position
- the position of the tabpublic void setSelectedTab(Component c)
c
- public void setSelectedTab(TabSheet.Tab tab)
Tab
instance. Does nothing if the tabsheet doesn't contain
the given tab.tab
- public void setSelectedTab(int position)
position
- public Component getSelectedTab()
public void replaceComponent(Component oldComponent, Component newComponent)
TabSheet
.
If the oldComponent is not present in the tab sheet, the new one is added
at the end.
If the oldComponent is already in the tab sheet but the newComponent
isn't, the old tab is replaced with a new one, and the caption and icon
of the old one are copied to the new tab.
If both old and new components are present, their positions are swapped.
Replaces the component in the container with another one without changing
position.
This method replaces component with another one is such way that the new component overtakes the position of the old component. If the old component is not in the container, the new component is added to the container. If the both component are already in the container, their positions are swapped. Component attach and detach events should be taken care as with add and remove.
replaceComponent
in interface ComponentContainer
oldComponent
- the old component that will be replaced.newComponent
- the new component to be replaced.public void addSelectedTabChangeListener(TabSheet.SelectedTabChangeListener listener)
listener
- the Listener to be added.@Deprecated public void addListener(TabSheet.SelectedTabChangeListener listener)
addSelectedTabChangeListener(SelectedTabChangeListener)
public void removeSelectedTabChangeListener(TabSheet.SelectedTabChangeListener listener)
listener
- the Listener to be removed.@Deprecated public void removeListener(TabSheet.SelectedTabChangeListener listener)
removeSelectedTabChangeListener(SelectedTabChangeListener)
protected void fireSelectedTabChange()
public void setCloseHandler(TabSheet.CloseHandler handler)
TabSheet.CloseHandler
for this TabSheet if you wish to
perform some additional tasks when a user clicks on a tabs close button,
e.g. show a confirmation dialogue before removing the tab.
To remove the tab, if you provide your own close handler, you must call
removeComponent(Component)
yourself.
The default CloseHandler for TabSheet will only remove the tab.handler
- public void setTabPosition(TabSheet.Tab tab, int position)
tab
- The tabposition
- The new position of the tabpublic int getTabPosition(TabSheet.Tab tab)
tab
- The tabpublic void focus()
AbstractComponent
Focusable
.focus
in interface Component.Focusable
focus
in class AbstractComponent
FieldEvents
,
FieldEvents.FocusEvent
,
FieldEvents.FocusListener
,
FieldEvents.BlurEvent
,
FieldEvents.BlurListener
public int getTabIndex()
Component.Focusable
Focusable
component.getTabIndex
in interface Component.Focusable
Focusable
componentComponent.Focusable.setTabIndex(int)
public void setTabIndex(int tabIndex)
Component.Focusable
Focusable
component.
The tab index property is used to specify the order in which the
fields are focused when the user presses the Tab key. Components with
a defined tab index are focused sequentially first, and then the
components with no tab index.
Form loginBox = new Form(); loginBox.setCaption("Login"); layout.addComponent(loginBox); // Create the first field which will be focused TextField username = new TextField("User name"); loginBox.addField("username", username); // Set focus to the user name username.focus(); TextField password = new TextField("Password"); loginBox.addField("password", password); Button login = new Button("Login"); loginBox.getFooter().addComponent(login); // An additional component which natural focus order would // be after the button. CheckBox remember = new CheckBox("Remember me"); loginBox.getFooter().addComponent(remember); username.setTabIndex(1); password.setTabIndex(2); remember.setTabIndex(3); // Different than natural place login.setTabIndex(4);
After all focusable user interface components are done, the browser can begin again from the component with the smallest tab index, or it can take the focus out of the page, for example, to the location bar.
If the tab index is not set (is set to zero), the default tab order is used. The order is somewhat browser-dependent, but generally follows the HTML structure of the page.
A negative value means that the component is completely removed from the tabulation order and can not be reached by pressing the Tab key at all.
setTabIndex
in interface Component.Focusable
tabIndex
- the tab order of this component. Indexes usually start
from 1. Zero means that default tab order should be used.
A negative value means that the field should not be
included in the tabbing sequence.Component.Focusable.getTabIndex()
public void addBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
to the Component which gets fired
when a Field
loses keyboard focus.addBlurListener
in interface FieldEvents.BlurNotifier
FieldEvents.BlurListener
@Deprecated public void addListener(FieldEvents.BlurListener listener)
#addBlurListener(BlurListener)
addListener
in interface FieldEvents.BlurNotifier
public void removeBlurListener(FieldEvents.BlurListener listener)
FieldEvents.BlurNotifier
BlurListener
from the Component.removeBlurListener
in interface FieldEvents.BlurNotifier
FieldEvents.BlurListener
@Deprecated public void removeListener(FieldEvents.BlurListener listener)
#removeBlurListener(BlurListener)
removeListener
in interface FieldEvents.BlurNotifier
public void addFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
to the Component which gets fired
when a Field
receives keyboard focus.addFocusListener
in interface FieldEvents.FocusNotifier
FieldEvents.FocusListener
@Deprecated public void addListener(FieldEvents.FocusListener listener)
#addFocusListener(FocusListener)
addListener
in interface FieldEvents.FocusNotifier
public void removeFocusListener(FieldEvents.FocusListener listener)
FieldEvents.FocusNotifier
FocusListener
from the Component.removeFocusListener
in interface FieldEvents.FocusNotifier
FieldEvents.FocusListener
@Deprecated public void removeListener(FieldEvents.FocusListener listener)
#removeFocusListener(FocusListener)
removeListener
in interface FieldEvents.FocusNotifier
public boolean isRendered(Component childComponent)
SelectiveRenderer
This method can only prevent updates from reaching the client, not force child components to reach the client. If the child is set to visible, returning false will prevent the child from being sent to the client. If a child is set to invisible, this method has no effect.
isRendered
in interface SelectiveRenderer
childComponent
- The child component to checkprotected TabsheetState getState(boolean markAsDirty)
AbstractClientConnector
getState
in class AbstractComponent
markAsDirty
- true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()
protected TabsheetState getState()
AbstractComponent
getState
in class AbstractComponent
public void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
The component is responsible not only for updating its own state but also for ensuring that its children update their state based on the design.
It is assumed that the component is in its default state when this method is called. Reading should only take into consideration attributes specified in the design and not reset any unspecified attributes to their defaults.
This method must not modify the design.
readDesign
in interface Component
readDesign
in class AbstractComponent
design
- The element to obtain the state fromdesignContext
- The DesignContext instance used for parsing the designprotected Collection<String> getCustomAttributes()
AbstractComponent
readDesign
and writeDesign
methods. Typically these are handled in a custom way in the overridden
versions of the above methodsgetCustomAttributes
in class AbstractComponent
public void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Component
The component is responsible not only for writing its own state but also for ensuring that its children write their state to the design.
This method must not modify the component state.
writeDesign
in interface Component
writeDesign
in class AbstractComponent
design
- The element to write the component state to. Any previous
attributes or child nodes are not cleared.designContext
- The DesignContext instance used for writing the designpublic void setTabCaptionsAsHtml(boolean tabCaptionsAsHtml)
If set to true, the captions are rendered in the browser as HTML and the developer is responsible for ensuring no harmful HTML is used. If set to false, the content is rendered in the browser as plain text.
The default is false, i.e. render tab captions as plain text
tabCaptionsAsHtml
- true if the tab captions are rendered as HTML, false if
rendered as plain textpublic boolean isTabCaptionsAsHtml()
The default is false, i.e. render tab captions as plain text
Copyright © 2019 Vaadin Ltd. All rights reserved.