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 MainTabSheetActionsSupport
protected static final String
protected com.vaadin.flow.component.tabs.Tabs
protected Map<com.vaadin.flow.component.tabs.Tab,
com.vaadin.flow.component.Component> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
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.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.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.com.vaadin.flow.component.tabs.Tab
Adds a tab created from the given text and content.void
Add an action to the component.void
Add an action to the component at the specified index.com.vaadin.flow.shared.Registration
addSelectedChangeListener
(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.SelectedChangeEvent<MainTabSheet>> listener) Adds a listener forTabbedViewsContainer.SelectedChangeEvent
.com.vaadin.flow.shared.Registration
addTabsCollectionChangeListener
(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.TabsCollectionChangeEvent<MainTabSheet>> listener) Adds a listener forTabbedViewsContainer.TabsCollectionChangeEvent
.protected int
protected MainTabSheetActionsSupport
protected com.vaadin.flow.component.tabs.Tabs
Optional<com.vaadin.flow.component.Component>
findComponent
(com.vaadin.flow.component.tabs.Tab tab) Returns theComponent
instance associated with the given tab.Optional<com.vaadin.flow.component.Component>
Optional<com.vaadin.flow.component.tabs.Tab>
findTab
(com.vaadin.flow.component.Component content) Returns theTab
associated with the given component.Optional<com.vaadin.flow.component.tabs.Tab>
Returns theTab
associated with the given ID.protected String
Returns an action with passed id.protected MainTabSheetActionsSupport
Stream<com.vaadin.flow.component.Component>
Gets the child components of tab sheet inElement
tree.com.vaadin.flow.component.Component
getComponent
(com.vaadin.flow.component.tabs.Tab tab) Returns theComponent
instance associated with the given tab.protected Stream<? extends com.vaadin.flow.component.dnd.DragSource<?>>
int
getIndexOf
(com.vaadin.flow.component.tabs.Tab tab) Returns the index of the given tab.Collection<com.vaadin.flow.component.Component>
int
Gets the zero-based index of the currently selected tab.com.vaadin.flow.component.tabs.Tab
Gets the currently selected tab.getSubPart
(String name) Returns a sub part object by its name.com.vaadin.flow.component.tabs.Tab
getTabAt
(int position) Returns the tab at the given position.Stream<com.vaadin.flow.component.Component>
Returns a stream ofComponent
instances representing the tab content.int
Gets the number of tabs.Stream<com.vaadin.flow.component.tabs.Tab>
Returns a stream of all the tabs in this container.protected boolean
ignoreDrop
(MainTabSheetDropEvent event) protected void
protected void
boolean
Returns whether the tabs are draggable by the user.protected void
linkTabToContent
(com.vaadin.flow.component.tabs.Tab tab, com.vaadin.flow.component.Component content) protected void
onAttach
(com.vaadin.flow.component.AttachEvent attachEvent) protected void
onDrop
(MainTabSheetDropEvent event) void
remove
(int position) Removes the tab at the given position.void
remove
(com.vaadin.flow.component.Component content) Removes a tab based on the contentvoid
remove
(com.vaadin.flow.component.tabs.Tab tab) Removes a tab.void
removeAction
(Action action) Removes the action from the component.protected void
runBeforeClientResponse
(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command) void
setSelectedIndex
(int selectedIndex) Selects a tab based on its zero-based index.void
setSelectedTab
(com.vaadin.flow.component.tabs.Tab selectedTab) Selects the given tab.void
setTabsDraggable
(boolean tabsDraggable) Sets whether the tabs are draggable by the user.protected void
Marks the content related to the selected tab as enabled and adds it to the component if it is not already added.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 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, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface io.jmix.flowui.component.ComponentContainer
findComponent, getComponent, getComponents, getOwnComponent
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface io.jmix.flowui.kit.component.HasActions
removeAction, removeAllActions
Methods inherited from interface com.vaadin.flow.component.HasElement
getElement
Methods inherited from interface com.vaadin.flow.component.shared.HasPrefix
getPrefixComponent, setPrefixComponent
Methods 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, setWidthFull
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
Methods inherited from interface com.vaadin.flow.component.shared.HasSuffix
getSuffixComponent, setSuffixComponent
Methods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, removeThemeVariants
Methods 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:TabbedViewsContainer
Adds a tab created from the given text and content.- Specified by:
add
in 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:TabbedViewsContainer
Adds a tab created from the given tab content and content.- Specified by:
add
in 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:TabbedViewsContainer
Adds a tab with the given content.- Specified by:
add
in 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:TabbedViewsContainer
Adds a tab with the given content to the given position.- Specified by:
add
in 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:TabbedViewsContainer
Removes a tab.- Specified by:
remove
in 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:TabbedViewsContainer
Removes a tab based on the content- Specified by:
remove
in 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:TabbedViewsContainer
Removes the tab at the given position.- Specified by:
remove
in interfaceTabbedViewsContainer<MainTabSheet>
- Parameters:
position
- the position of the tab to be removed
-
getSelectedIndex
public int getSelectedIndex()Description copied from interface:TabbedViewsContainer
Gets the zero-based index of the currently selected tab.- Specified by:
getSelectedIndex
in 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:TabbedViewsContainer
Selects a tab based on its zero-based index.- Specified by:
setSelectedIndex
in 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:TabbedViewsContainer
Gets the currently selected tab.- Specified by:
getSelectedTab
in interfaceTabbedViewsContainer<MainTabSheet>
- Returns:
- the selected tab, or
null
if none is selected
-
setSelectedTab
public void setSelectedTab(@Nullable com.vaadin.flow.component.tabs.Tab selectedTab) Description copied from interface:TabbedViewsContainer
Selects the given tab.- Specified by:
setSelectedTab
in interfaceTabbedViewsContainer<MainTabSheet>
- Parameters:
selectedTab
- the tab to select,null
to unselect all
-
getTabCount
public int getTabCount()Description copied from interface:TabbedViewsContainer
Gets the number of tabs.- Specified by:
getTabCount
in interfaceTabbedViewsContainer<MainTabSheet>
- Returns:
- the number of tabs
-
getTabsStream
Description copied from interface:TabbedViewsContainer
Returns a stream of all the tabs in this container.- Specified by:
getTabsStream
in interfaceTabbedViewsContainer<MainTabSheet>
- Returns:
- a stream of
Tab
instances in the container
-
getTabAt
public com.vaadin.flow.component.tabs.Tab getTabAt(int position) Description copied from interface:TabbedViewsContainer
Returns the tab at the given position.- Specified by:
getTabAt
in 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:TabbedViewsContainer
Returns the index of the given tab.- Specified by:
getIndexOf
in 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:TabbedViewsContainer
Returns theTab
associated with the given component.- Specified by:
findTab
in interfaceTabbedViewsContainer<MainTabSheet>
- Parameters:
content
- the component to look up- Returns:
- The tab instance associated with the given component, or an
empty
Optional
if theTabSheet
does not contain theTab
associated with the given component
-
findTab
Description copied from interface:TabbedViewsContainer
Returns theTab
associated with the given ID.- Specified by:
findTab
in interfaceTabbedViewsContainer<MainTabSheet>
- Parameters:
id
- the ID of the tab to retrieve- Returns:
- the
Tab
associated with the specified ID, or an emptyOptional
if 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:TabbedViewsContainer
Returns theComponent
instance associated with the given tab.- Specified by:
getComponent
in 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:TabbedViewsContainer
Returns theComponent
instance associated with the given tab.- Specified by:
findComponent
in 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:TabbedViewsContainer
Returns a stream ofComponent
instances representing the tab content.- Specified by:
getTabComponentsStream
in interfaceTabbedViewsContainer<MainTabSheet>
- Returns:
- a stream of
Component
instances 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:TabbedViewsContainer
Adds a listener forTabbedViewsContainer.SelectedChangeEvent
.- Specified by:
addSelectedChangeListener
in 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:TabbedViewsContainer
Adds a listener forTabbedViewsContainer.TabsCollectionChangeEvent
.- Specified by:
addTabsCollectionChangeListener
in interfaceTabbedViewsContainer<MainTabSheet>
- Parameters:
listener
- the listener to add- Returns:
- a handle that can be used for removing the listener
-
findOwnComponent
- Specified by:
findOwnComponent
in interfaceComponentContainer
-
getOwnComponents
- Specified by:
getOwnComponents
in interfaceComponentContainer
-
getChildren
Gets the child components of tab sheet inElement
tree.- Overrides:
getChildren
in classcom.vaadin.flow.component.Component
- Returns:
- the stream of tab sheet tab
-
getSubPart
Description copied from interface:HasSubParts
Returns a sub part object by its name.- Specified by:
getSubPart
in interfaceHasSubParts
- Parameters:
name
- sub part name, e.g. component id- Returns:
- a sub part object by its name, or
null
if not found
-
addAction
Description copied from interface:HasActions
Add an action to the component.- Specified by:
addAction
in interfaceHasActions
- Parameters:
action
- action to add
-
addAction
Description copied from interface:HasActions
Add an action to the component at the specified index.- Specified by:
addAction
in interfaceHasActions
- Parameters:
action
- action to addindex
- index at which the specified action is to be added
-
removeAction
Description copied from interface:HasActions
Removes the action from the component.- Specified by:
removeAction
in interfaceHasActions
- Parameters:
action
- action to remove
-
getActions
- Specified by:
getActions
in interfaceHasActions
- Returns:
- unmodifiable collection of actions
-
getAction
Description copied from interface:HasActions
Returns an action with passed id.- Specified by:
getAction
in interfaceHasActions
- Parameters:
id
- id of the action to find- Returns:
- an action by its id, or
null
if not found
-
isTabsDraggable
public boolean isTabsDraggable()Returns whether the tabs are draggable by the user.- Returns:
true
if tabs are draggable,false
otherwise
-
setTabsDraggable
public void setTabsDraggable(boolean tabsDraggable) Sets whether the tabs are draggable by the user. Default value isfalse
.- Parameters:
tabsDraggable
-true
if tabs are draggable,false
otherwise
-
getDraggabdleTabsStream
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttach
in 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
-