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

    Fields
    Modifier and Type
    Field
    Description
     
    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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected 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
    add(String tabText, com.vaadin.flow.component.Component content)
    Adds a tab created from the given text and content.
    void
    addAction(Action action)
    Add an action to the component.
    void
    addAction(Action action, int index)
    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)
    com.vaadin.flow.shared.Registration
    addTabsCollectionChangeListener(com.vaadin.flow.component.ComponentEventListener<TabbedViewsContainer.TabsCollectionChangeEvent<MainTabSheet>> listener)
    protected int
     
     
    protected com.vaadin.flow.component.tabs.Tabs
     
    Optional<com.vaadin.flow.component.Component>
    findComponent(com.vaadin.flow.component.tabs.Tab tab)
    Returns the Component 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 the Tab associated with the given component.
    Optional<com.vaadin.flow.component.tabs.Tab>
    Returns the Tab associated with the given ID.
    protected String
     
    Returns an action with passed id.
     
     
    Stream<com.vaadin.flow.component.Component>
    Gets the child components of tab sheet in Element tree.
    com.vaadin.flow.component.Component
    getComponent(com.vaadin.flow.component.tabs.Tab tab)
    Returns the Component 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.
    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 of Component 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
     
    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
     
    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 content
    void
    remove(com.vaadin.flow.component.tabs.Tab tab)
    Removes a tab.
    void
    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 one

    Methods 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

      protected static final String GENERATED_TAB_ID_PREFIX
      See Also:
    • actionsSupport

      protected MainTabSheetActionsSupport actionsSupport
    • tabs

      protected com.vaadin.flow.component.tabs.Tabs tabs
    • tabToContent

      protected Map<com.vaadin.flow.component.tabs.Tab,com.vaadin.flow.component.Component> 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 interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      tabText - the text of the tab
      content - 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 interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      tabContent - the content of the tab
      content - 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 interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      tab - the tab
      content - 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 interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      tab - the tab
      content - the content related to the tab
      position - 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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<MainTabSheet>
      Returns:
      the number of tabs
    • getTabsStream

      public Stream<com.vaadin.flow.component.tabs.Tab> getTabsStream()
      Description copied from interface: TabbedViewsContainer
      Returns a stream of all the tabs in this container.
      Specified by:
      getTabsStream in interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 interface TabbedViewsContainer<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 the Tab associated with the given component.
      Specified by:
      findTab in interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      content - the component to look up
      Returns:
      The tab instance associated with the given component, or an empty Optional if the TabSheet does not contain the Tab associated with the given component
    • findTab

      public Optional<com.vaadin.flow.component.tabs.Tab> findTab(String id)
      Description copied from interface: TabbedViewsContainer
      Returns the Tab associated with the given ID.
      Specified by:
      findTab in interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      id - the ID of the tab to retrieve
      Returns:
      the Tab associated with the specified ID, or an empty Optional 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 the Component instance associated with the given tab.
      Specified by:
      getComponent in interface TabbedViewsContainer<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 the Component instance associated with the given tab.
      Specified by:
      findComponent in interface TabbedViewsContainer<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

      public Stream<com.vaadin.flow.component.Component> getTabComponentsStream()
      Description copied from interface: TabbedViewsContainer
      Returns a stream of Component instances representing the tab content.
      Specified by:
      getTabComponentsStream in interface TabbedViewsContainer<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
      Specified by:
      addSelectedChangeListener in interface TabbedViewsContainer<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
      Specified by:
      addTabsCollectionChangeListener in interface TabbedViewsContainer<MainTabSheet>
      Parameters:
      listener - the listener to add
      Returns:
      a handle that can be used for removing the listener
    • findOwnComponent

      public Optional<com.vaadin.flow.component.Component> findOwnComponent(String id)
      Specified by:
      findOwnComponent in interface ComponentContainer
    • getOwnComponents

      public Collection<com.vaadin.flow.component.Component> getOwnComponents()
      Specified by:
      getOwnComponents in interface ComponentContainer
    • getChildren

      public Stream<com.vaadin.flow.component.Component> getChildren()
      Gets the child components of tab sheet in Element tree.
      Overrides:
      getChildren in class com.vaadin.flow.component.Component
      Returns:
      the stream of tab sheet tab
    • getSubPart

      @Nullable public Object getSubPart(String name)
      Description copied from interface: HasSubParts
      Returns a sub part object by its name.
      Specified by:
      getSubPart in interface HasSubParts
      Parameters:
      name - sub part name, e.g. component id
      Returns:
      a sub part object by its name, or null if not found
    • addAction

      public void addAction(Action action)
      Description copied from interface: HasActions
      Add an action to the component.
      Specified by:
      addAction in interface HasActions
      Parameters:
      action - action to add
    • addAction

      public void addAction(Action action, int index)
      Description copied from interface: HasActions
      Add an action to the component at the specified index.
      Specified by:
      addAction in interface HasActions
      Parameters:
      action - action to add
      index - index at which the specified action is to be added
    • removeAction

      public void removeAction(Action action)
      Description copied from interface: HasActions
      Removes the action from the component.
      Specified by:
      removeAction in interface HasActions
      Parameters:
      action - action to remove
    • getActions

      public Collection<Action> getActions()
      Specified by:
      getActions in interface HasActions
      Returns:
      unmodifiable collection of actions
    • getAction

      @Nullable public Action getAction(String id)
      Description copied from interface: HasActions
      Returns an action with passed id.
      Specified by:
      getAction in interface HasActions
      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 is false.
      Parameters:
      tabsDraggable - true if tabs are draggable, false otherwise
    • getDraggabdleTabsStream

      protected Stream<? extends com.vaadin.flow.component.dnd.DragSource<?>> getDraggabdleTabsStream()
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • activateSelectedTab

      protected void activateSelectedTab()
    • getActionsSupport

      protected MainTabSheetActionsSupport getActionsSupport()
    • createActionsSupport

      protected MainTabSheetActionsSupport 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 tab
      content - 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

      protected String generateTabId()
    • initConnector

      protected void initConnector()
    • onDrop

      protected void onDrop(MainTabSheetDropEvent event)
    • ignoreDrop

      protected boolean ignoreDrop(MainTabSheetDropEvent event)
    • calculateDropIndex

      protected int calculateDropIndex(MainTabSheetDropEvent event)