Class MainTabSheet
java.lang.Object
com.vaadin.flow.component.Component
io.jmix.tabbedmode.component.tabsheet.MainTabSheet
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasTheme,com.vaadin.flow.component.shared.HasPrefix,com.vaadin.flow.component.shared.HasSuffix,com.vaadin.flow.component.shared.HasThemeVariant<MainTabSheetVariant>,ComponentContainer,HasActions,HasSubParts,TabbedViewsContainer<MainTabSheet>,Serializable
@Tag("jmix-main-tabsheet")
@JsModule("./src/tabsheet/jmix-main-tabsheet.js") @JsModule("./src/tabsheet/mainTabSheetConnector.ts")
public class MainTabSheet
extends com.vaadin.flow.component.Component
implements TabbedViewsContainer<MainTabSheet>, HasActions, ComponentContainer, HasSubParts, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.shared.HasThemeVariant<MainTabSheetVariant>, com.vaadin.flow.component.shared.HasPrefix, com.vaadin.flow.component.shared.HasSuffix
Component that consists of a set of tabs and the content area. The content area
displays a component associated with the selected tab.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.jmix.tabbedmode.component.workarea.TabbedViewsContainer
TabbedViewsContainer.SelectedChangeEvent<C extends com.vaadin.flow.component.Component & TabbedViewsContainer<C>>, TabbedViewsContainer.TabsCollectionChangeEvent<C extends com.vaadin.flow.component.Component & TabbedViewsContainer<C>>, TabbedViewsContainer.TabsCollectionChangeType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MainTabSheetActionsSupportprotected static final Stringprotected com.vaadin.flow.component.tabs.Tabsprotected Map<com.vaadin.flow.component.tabs.Tab,com.vaadin.flow.component.Component> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcom.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.voidAdd an action to the component.voidAdd an action to the component at the specified index.com.vaadin.flow.shared.RegistrationaddSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.SelectedChangeEvent<MainTabSheet>> listener) Adds a listener forTabbedViewsContainer.SelectedChangeEvent.com.vaadin.flow.shared.RegistrationaddTabsCollectionChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.TabsCollectionChangeEvent<MainTabSheet>> listener) Adds a listener forTabbedViewsContainer.TabsCollectionChangeEvent.protected intprotected MainTabSheetActionsSupportprotected com.vaadin.flow.component.tabs.TabsOptional<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.Component>Finds a component within immediate children of the container by its unique identifier.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.protected StringReturns an action with passed id.protected MainTabSheetActionsSupportStream<com.vaadin.flow.component.Component>Gets the child components of tab sheet inElementtree.com.vaadin.flow.component.ComponentgetComponent(com.vaadin.flow.component.tabs.Tab tab) Returns theComponentinstance associated with the given tab.protected Stream<? extends com.vaadin.flow.component.dnd.DragSource<?>>intgetIndexOf(com.vaadin.flow.component.tabs.Tab tab) Returns the index of the given tab.Collection<com.vaadin.flow.component.Component>Returns a collection of components that are direct children (immediate descendants) of the container.intGets the zero-based index of the currently selected tab.com.vaadin.flow.component.tabs.TabGets the currently selected tab.getSubPart(String name) Returns a sub part object by its name.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.protected booleanignoreDrop(MainTabSheetDropEvent event) protected voidprotected voidbooleanReturns whether the tabs are draggable by the user.protected voidlinkTabToContent(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) protected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidonDrop(MainTabSheetDropEvent event) 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.voidremoveAction(Action action) Removes the action from the component.protected voidrunBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command) voidsetSelectedIndex(int selectedIndex) Selects a tab based on its zero-based index.voidsetSelectedTab(com.vaadin.flow.component.tabs.Tab selectedTab) Selects the given tab.voidsetTabsDraggable(boolean tabsDraggable) Sets whether the tabs are draggable by the user.protected voidMarks the content related to the selected tab as enabled and adds it to the component if it is not already added.protected voidupdateTabContent(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) Remove old tab content if exists and set new oneMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface io.jmix.flowui.component.ComponentContainer
findComponent, getComponent, getComponents, getOwnComponentMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface io.jmix.flowui.kit.component.HasActions
removeAction, removeAllActionsMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponentMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponentMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariantsMethods inherited from interface io.jmix.tabbedmode.component.workarea.TabbedViewsContainer
getTab, getTab
-
Field Details
-
GENERATED_TAB_ID_PREFIX
- See Also:
-
actionsSupport
-
tabs
protected com.vaadin.flow.component.tabs.Tabs tabs -
tabToContent
-
-
Constructor Details
-
MainTabSheet
public MainTabSheet()
-
-
Method Details
-
initComponent
protected void initComponent() -
createTabsComponent
protected com.vaadin.flow.component.tabs.Tabs createTabsComponent() -
add
public com.vaadin.flow.component.tabs.Tab add(String tabText, com.vaadin.flow.component.Component content) Description copied from interface:TabbedViewsContainerAdds a tab created from the given text and content.- Specified by:
addin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tabText- the text of the tabcontent- the content related to the tab- Returns:
- the created tab
-
add
public com.vaadin.flow.component.tabs.Tab add(com.vaadin.flow.component.Component tabContent, com.vaadin.flow.component.Component content) Description copied from interface:TabbedViewsContainerAdds a tab created from the given tab content and content.- Specified by:
addin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tabContent- the content of the tabcontent- the content related to the tab- Returns:
- the created tab
-
add
public com.vaadin.flow.component.tabs.Tab add(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) Description copied from interface:TabbedViewsContainerAdds a tab with the given content.- Specified by:
addin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tab- the tabcontent- the content related to the tab- Returns:
- the added tab
-
add
public com.vaadin.flow.component.tabs.Tab add(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content, int position) Description copied from interface:TabbedViewsContainerAdds a tab with the given content to the given position.- Specified by:
addin interfaceTabbedViewsContainer<MainTabSheet>- 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
public void remove(com.vaadin.flow.component.tabs.Tab tab) Description copied from interface:TabbedViewsContainerRemoves a tab.- Specified by:
removein interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tab- the non-null tab to be removed
-
remove
public void remove(com.vaadin.flow.component.Component content) Description copied from interface:TabbedViewsContainerRemoves a tab based on the content- Specified by:
removein interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
content- the non-null content related to the tab to be removed
-
remove
public void remove(int position) Description copied from interface:TabbedViewsContainerRemoves the tab at the given position.- Specified by:
removein interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
position- the position of the tab to be removed
-
getSelectedIndex
public int getSelectedIndex()Description copied from interface:TabbedViewsContainerGets the zero-based index of the currently selected tab.- Specified by:
getSelectedIndexin interfaceTabbedViewsContainer<MainTabSheet>- Returns:
- the zero-based index of the selected tab, or -1 if none of the tabs is selected
-
setSelectedIndex
public void setSelectedIndex(int selectedIndex) Description copied from interface:TabbedViewsContainerSelects a tab based on its zero-based index.- Specified by:
setSelectedIndexin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
selectedIndex- the zero-based index of the selected tab, -1 to unselect all
-
getSelectedTab
@Nullable public com.vaadin.flow.component.tabs.Tab getSelectedTab()Description copied from interface:TabbedViewsContainerGets the currently selected tab.- Specified by:
getSelectedTabin interfaceTabbedViewsContainer<MainTabSheet>- Returns:
- the selected tab, or
nullif none is selected
-
setSelectedTab
public void setSelectedTab(@Nullable com.vaadin.flow.component.tabs.Tab selectedTab) Description copied from interface:TabbedViewsContainerSelects the given tab.- Specified by:
setSelectedTabin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
selectedTab- the tab to select,nullto unselect all
-
getTabCount
public int getTabCount()Description copied from interface:TabbedViewsContainerGets the number of tabs.- Specified by:
getTabCountin interfaceTabbedViewsContainer<MainTabSheet>- Returns:
- the number of tabs
-
getTabsStream
Description copied from interface:TabbedViewsContainerReturns a stream of all the tabs in this container.- Specified by:
getTabsStreamin interfaceTabbedViewsContainer<MainTabSheet>- Returns:
- a stream of
Tabinstances in the container
-
getTabAt
public com.vaadin.flow.component.tabs.Tab getTabAt(int position) Description copied from interface:TabbedViewsContainerReturns the tab at the given position.- Specified by:
getTabAtin interfaceTabbedViewsContainer<MainTabSheet>- 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
-
getIndexOf
public int getIndexOf(com.vaadin.flow.component.tabs.Tab tab) Description copied from interface:TabbedViewsContainerReturns the index of the given tab.- Specified by:
getIndexOfin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tab- the tab to look up- Returns:
- the index of the tab or -1 if the tab is not added
-
findTab
public Optional<com.vaadin.flow.component.tabs.Tab> findTab(com.vaadin.flow.component.Component content) Description copied from interface:TabbedViewsContainerReturns theTabassociated with the given component.- Specified by:
findTabin interfaceTabbedViewsContainer<MainTabSheet>- 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
-
findTab
Description copied from interface:TabbedViewsContainerReturns theTabassociated with the given ID.- Specified by:
findTabin interfaceTabbedViewsContainer<MainTabSheet>- 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
public com.vaadin.flow.component.Component getComponent(com.vaadin.flow.component.tabs.Tab tab) Description copied from interface:TabbedViewsContainerReturns theComponentinstance associated with the given tab.- Specified by:
getComponentin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tab- the tab to get component- Returns:
- the component instance associated with the given tab
-
findComponent
public Optional<com.vaadin.flow.component.Component> findComponent(com.vaadin.flow.component.tabs.Tab tab) Description copied from interface:TabbedViewsContainerReturns theComponentinstance associated with the given tab.- Specified by:
findComponentin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
tab- the tab to get component- Returns:
- the component instance associated with the given tab, or an empty optional if not found
-
getTabComponentsStream
Description copied from interface:TabbedViewsContainerReturns a stream ofComponentinstances representing the tab content.- Specified by:
getTabComponentsStreamin interfaceTabbedViewsContainer<MainTabSheet>- Returns:
- a stream of
Componentinstances representing the tab content
-
addSelectedChangeListener
public com.vaadin.flow.shared.Registration addSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.SelectedChangeEvent<MainTabSheet>> listener) Description copied from interface:TabbedViewsContainerAdds a listener forTabbedViewsContainer.SelectedChangeEvent.- Specified by:
addSelectedChangeListenerin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
listener- the listener to add- Returns:
- a handle that can be used for removing the listener
-
addTabsCollectionChangeListener
public com.vaadin.flow.shared.Registration addTabsCollectionChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.TabsCollectionChangeEvent<MainTabSheet>> listener) Description copied from interface:TabbedViewsContainerAdds a listener forTabbedViewsContainer.TabsCollectionChangeEvent.- Specified by:
addTabsCollectionChangeListenerin interfaceTabbedViewsContainer<MainTabSheet>- Parameters:
listener- the listener to add- Returns:
- a handle that can be used for removing the listener
-
findOwnComponent
Description copied from interface:ComponentContainerFinds a component within immediate children of the container by its unique identifier.- Specified by:
findOwnComponentin interfaceComponentContainer- Parameters:
id- the unique identifier of the component to find- Returns:
- an
Optionalcontaining the found component if it exists within the immediate children of the container, or an emptyOptionalif no component with the given identifier is found
-
getOwnComponents
Description copied from interface:ComponentContainerReturns a collection of components that are direct children (immediate descendants) of the container.- Specified by:
getOwnComponentsin interfaceComponentContainer- Returns:
- a collection of
Componentinstances representing the immediate children of the container, or an empty collection if no such components exist
-
getChildren
Gets the child components of tab sheet inElementtree.- Overrides:
getChildrenin classcom.vaadin.flow.component.Component- Returns:
- the stream of tab sheet tab
-
getSubPart
Description copied from interface:HasSubPartsReturns a sub part object by its name.- Specified by:
getSubPartin interfaceHasSubParts- Parameters:
name- sub part name, e.g. component id- Returns:
- a sub part object by its name, or
nullif not found
-
addAction
Description copied from interface:HasActionsAdd an action to the component.- Specified by:
addActionin interfaceHasActions- Parameters:
action- action to add
-
addAction
Description copied from interface:HasActionsAdd an action to the component at the specified index.- Specified by:
addActionin interfaceHasActions- Parameters:
action- action to addindex- index at which the specified action is to be added
-
removeAction
Description copied from interface:HasActionsRemoves the action from the component.- Specified by:
removeActionin interfaceHasActions- Parameters:
action- action to remove
-
getActions
- Specified by:
getActionsin interfaceHasActions- Returns:
- unmodifiable collection of actions
-
getAction
Description copied from interface:HasActionsReturns an action with passed id.- Specified by:
getActionin interfaceHasActions- Parameters:
id- id of the action to find- Returns:
- an action by its id, or
nullif not found
-
isTabsDraggable
public boolean isTabsDraggable()Returns whether the tabs are draggable by the user.- Returns:
trueif tabs are draggable,falseotherwise
-
setTabsDraggable
public void setTabsDraggable(boolean tabsDraggable) Sets whether the tabs are draggable by the user. Default value isfalse.- Parameters:
tabsDraggable-trueif tabs are draggable,falseotherwise
-
getDraggabdleTabsStream
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
activateSelectedTab
protected void activateSelectedTab() -
getActionsSupport
-
createActionsSupport
-
updateContent
protected void updateContent()Marks the content related to the selected tab as enabled and adds it to the component if it is not already added. All the other content panels are disabled, so they can't be interacted with. -
updateTabContent
protected void updateTabContent(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) Remove old tab content if exists and set new one- Parameters:
tab- updated tabcontent- new content
-
linkTabToContent
protected void linkTabToContent(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) -
runBeforeClientResponse
protected void runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command) -
generateTabId
-
initConnector
protected void initConnector() -
onDrop
-
ignoreDrop
-
calculateDropIndex
-