Interface TabbedViewsContainer<C extends com.vaadin.flow.component.Component & TabbedViewsContainer<C>>
- Type Parameters:
C- the component type that extends bothComponentandTabbedViewsContainer
- All Superinterfaces:
com.vaadin.flow.component.HasElement,Serializable
- All Known Implementing Classes:
MainTabSheet
public interface TabbedViewsContainer<C extends com.vaadin.flow.component.Component & TabbedViewsContainer<C>>
extends com.vaadin.flow.component.HasElement
Interface representing a container for tabbed views, allowing
management of tabs and their associated content.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classTabbedViewsContainer.SelectedChangeEvent<C extends com.vaadin.flow.component.Component & TabbedViewsContainer<C>>An event to mark that the selected tab has changed.static classTabbedViewsContainer.TabsCollectionChangeEvent<C extends com.vaadin.flow.component.Component & TabbedViewsContainer<C>>An event that is fired every time tabs collection is changed.static enumDefines the type of tab change. -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.component.tabs.Tabadd(com.vaadin.flow.component.Component tabContent, com.vaadin.flow.component.Component content) Adds a tab created from the given tab content and content.com.vaadin.flow.component.tabs.Tabadd(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) Adds a tab with the given content.com.vaadin.flow.component.tabs.Tabadd(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content, int position) Adds a tab with the given content to the given position.com.vaadin.flow.component.tabs.TabAdds a tab created from the given text and content.com.vaadin.flow.shared.RegistrationaddSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.SelectedChangeEvent<C>> listener) Adds a listener forTabbedViewsContainer.SelectedChangeEvent.com.vaadin.flow.shared.RegistrationaddTabsCollectionChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.TabsCollectionChangeEvent<C>> listener) Adds a listener forTabbedViewsContainer.TabsCollectionChangeEvent.Optional<com.vaadin.flow.component.Component>findComponent(com.vaadin.flow.component.tabs.Tab tab) Returns theComponentinstance associated with the given tab.Optional<com.vaadin.flow.component.tabs.Tab>findTab(com.vaadin.flow.component.Component content) Returns theTabassociated with the given component.Optional<com.vaadin.flow.component.tabs.Tab>Returns theTabassociated with the given ID.com.vaadin.flow.component.ComponentgetComponent(com.vaadin.flow.component.tabs.Tab tab) Returns theComponentinstance associated with the given tab.intgetIndexOf(com.vaadin.flow.component.tabs.Tab tab) Returns the index of the given tab.intGets the zero-based index of the currently selected tab.com.vaadin.flow.component.tabs.TabGets the currently selected tab.default com.vaadin.flow.component.tabs.TabgetTab(com.vaadin.flow.component.Component content) Returns theTabassociated with the given component.default com.vaadin.flow.component.tabs.TabReturns theTabassociated with the given ID.com.vaadin.flow.component.tabs.TabgetTabAt(int position) Returns the tab at the given position.Stream<com.vaadin.flow.component.Component>Returns a stream ofComponentinstances representing the tab content.intGets the number of tabs.Stream<com.vaadin.flow.component.tabs.Tab>Returns a stream of all the tabs in this container.voidremove(int position) Removes the tab at the given position.voidremove(com.vaadin.flow.component.Component content) Removes a tab based on the contentvoidremove(com.vaadin.flow.component.tabs.Tab tab) Removes a tab.voidsetSelectedIndex(int selectedIndex) Selects a tab based on its zero-based index.voidsetSelectedTab(com.vaadin.flow.component.tabs.Tab selectedTab) Selects the given tab.Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
-
Method Details
-
add
Adds a tab created from the given text and content.- Parameters:
tabText- the text of the tabcontent- the content related to the tab- Returns:
- the created tab
-
add
com.vaadin.flow.component.tabs.Tab add(com.vaadin.flow.component.Component tabContent, com.vaadin.flow.component.Component content) Adds a tab created from the given tab content and content.- Parameters:
tabContent- the content of the tabcontent- the content related to the tab- Returns:
- the created tab
-
add
com.vaadin.flow.component.tabs.Tab add(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) Adds a tab with the given content.- Parameters:
tab- the tabcontent- the content related to the tab- Returns:
- the added tab
-
add
com.vaadin.flow.component.tabs.Tab add(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content, int position) Adds a tab with the given content to the given position.- Parameters:
tab- the tabcontent- the content related to the tabposition- the position where the tab should be added. If negative, the tab is added at the end.- Returns:
- the added tab
-
remove
void remove(com.vaadin.flow.component.tabs.Tab tab) Removes a tab.- Parameters:
tab- the non-null tab to be removed
-
remove
void remove(com.vaadin.flow.component.Component content) Removes a tab based on the content- Parameters:
content- the non-null content related to the tab to be removed
-
remove
void remove(int position) Removes the tab at the given position.- Parameters:
position- the position of the tab to be removed
-
getSelectedIndex
int getSelectedIndex()Gets the zero-based index of the currently selected tab.- Returns:
- the zero-based index of the selected tab, or -1 if none of the tabs is selected
-
setSelectedIndex
void setSelectedIndex(int selectedIndex) Selects a tab based on its zero-based index.- Parameters:
selectedIndex- the zero-based index of the selected tab, -1 to unselect all
-
getSelectedTab
@Nullable com.vaadin.flow.component.tabs.Tab getSelectedTab()Gets the currently selected tab.- Returns:
- the selected tab, or
nullif none is selected
-
setSelectedTab
void setSelectedTab(@Nullable com.vaadin.flow.component.tabs.Tab selectedTab) Selects the given tab.- Parameters:
selectedTab- the tab to select,nullto unselect all- Throws:
IllegalArgumentException- ifselectedTabis not a child of this component
-
getTabCount
int getTabCount()Gets the number of tabs.- Returns:
- the number of tabs
-
getTabsStream
Stream<com.vaadin.flow.component.tabs.Tab> getTabsStream()Returns a stream of all the tabs in this container.- Returns:
- a stream of
Tabinstances in the container
-
getTabAt
com.vaadin.flow.component.tabs.Tab getTabAt(int position) Returns the tab at the given position.- Parameters:
position- the position of the tab must be greater than or equals to 0 and less than the number of tabs- Returns:
- The tab at the given index
- Throws:
IllegalArgumentException- if the index is less than 0 or greater than or equals to the number of tabs
-
getIndexOf
int getIndexOf(com.vaadin.flow.component.tabs.Tab tab) Returns the index of the given tab.- Parameters:
tab- the tab to look up- Returns:
- the index of the tab or -1 if the tab is not added
-
getTab
default com.vaadin.flow.component.tabs.Tab getTab(com.vaadin.flow.component.Component content) Returns theTabassociated with the given component.- Parameters:
content- the component to look up- Returns:
- The tab instance associated with the given component
- Throws:
IllegalArgumentException- if tab not found
-
findTab
Returns theTabassociated with the given component.- Parameters:
content- the component to look up- Returns:
- The tab instance associated with the given component, or an
empty
Optionalif theTabSheetdoes not contain theTabassociated with the given component
-
getTab
Returns theTabassociated with the given ID.- Parameters:
id- the ID of the tab to retrieve- Returns:
- the
Tabassociated with the specified ID - Throws:
IllegalArgumentException- if no tab is found with the given ID
-
findTab
Returns theTabassociated with the given ID.- Parameters:
id- the ID of the tab to retrieve- Returns:
- the
Tabassociated with the specified ID, or an emptyOptionalif no tab is found with the given ID
-
getComponent
com.vaadin.flow.component.Component getComponent(com.vaadin.flow.component.tabs.Tab tab) Returns theComponentinstance associated with the given tab.- Parameters:
tab- the tab to get component- Returns:
- the component instance associated with the given tab
- Throws:
IllegalArgumentException- if component not found
-
findComponent
Returns theComponentinstance associated with the given tab.- Parameters:
tab- the tab to get component- Returns:
- the component instance associated with the given tab, or an empty optional if not found
-
getTabComponentsStream
Stream<com.vaadin.flow.component.Component> getTabComponentsStream()Returns a stream ofComponentinstances representing the tab content.- Returns:
- a stream of
Componentinstances representing the tab content
-
addSelectedChangeListener
com.vaadin.flow.shared.Registration addSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.SelectedChangeEvent<C>> listener) Adds a listener forTabbedViewsContainer.SelectedChangeEvent.- Parameters:
listener- the listener to add- Returns:
- a handle that can be used for removing the listener
-
addTabsCollectionChangeListener
com.vaadin.flow.shared.Registration addTabsCollectionChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.TabsCollectionChangeEvent<C>> listener) Adds a listener forTabbedViewsContainer.TabsCollectionChangeEvent.- Parameters:
listener- the listener to add- Returns:
- a handle that can be used for removing the listener
-