All Implemented Interfaces:
Animatable<Tab>, CanDrop<Tab>, Draggable<Tab>

public class Tab extends Component<Tab> implements Animatable<Tab>, CanDrop<Tab>, Draggable<Tab>

This component collects the tab components. This means that the component has no visual display on the interface, it is only used to group tab page components. Please note that the tab page components cannot be placed on the interface directly, they must be placed through the tab component. Otherwise, neither the tab, or tab page component will not function properly.

Through the component, tab page components can be displayed. Only one tab page component can be displayed from a group. However, every tab will be visible on the top. By default, when displaying the first tab page component will be active, and have its contents displayed. If the user clicks on another tab, the currently active tab page will disappear, only it's clickable tab will remain, while the new tab page will be displayed.

With the help of this component, we can set the state of the assigned tab pages. By default, these tab pages appear on the upper side of the tab, but it can be modified to the left or right side. It is also possible to switch between the tab pages through code, either by using their index, or going forward or backward by one tab. Click handlers can also be placed on the individual tab pages, or the same handler can be set to all tab pages, so the event of the user changing pages can be handled.

Supported events:

AnimationStart AnimationEnd, Drop, DragStart, DragEnd

Since:
4.0
Author:
JBStrap
See Also:
  • Field Details

  • Constructor Details

    • Tab

      public Tab()
      Creates an empty, default tab component.
    • Tab

      public Tab(String id)
      Creates an empty, default tab component with the specified ID.
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
    • Tab

      public Tab(TabType type)
      Creates an empty tab component, with the specified tab type
      Parameters:
      type - The tab position. For applicable values, see the TabType enum. If null, the tab will use the default type.
    • Tab

      public Tab(String id, TabType type)
      Creates an empty tab component, with the specified tab type
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      type - The tab position. For applicable values, see the TabType enum. If null, the tab will use the default type.
    • Tab

      public Tab(TabPage... tabPages)
      Creates a tab component, in the default state, with the specified tab pages
      Parameters:
      tabPages - The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
    • Tab

      public Tab(String id, TabPage... tabPages)
      Creates a tab component, in the default state, with the specified tab pages
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      tabPages - The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
    • Tab

      public Tab(TabType tabType, TabPage... tabPages)
      Creates a tab component, with the specified tab type and tab pages.
      Parameters:
      tabType - The tab position. For applicable values, see the TabType enum. If null, the tab will use the default type.
      tabPages - The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
    • Tab

      public Tab(String id, TabType tabType, TabPage... tabPages)
      Creates a tab component, with the specified tab type and tab pages.
      Parameters:
      id - The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)
      tabType - The tab position. For applicable values, see the TabType enum. If null, the tab will use the default type.
      tabPages - The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
  • Method Details

    • addTabPage

      public Tab addTabPage(TabPage tabPage)
      Adds the specified tab page to the tab component
      Parameters:
      tabPage - The tab page component instance that will be added to the tab
      Returns:
      The tab component
    • addTabPages

      public Tab addTabPages(TabPage... tabPages)
      Adds multiple tab pages to the tab component
      Parameters:
      tabPages - The tab page component instances, that will be added to the tab. The pages will be added in the order they are specified.
      Returns:
      The tab component
    • addComponent

      public Tab addComponent(Component<?> component)
      Adds a component to the tab component. The tab component can only have tab page component added to it.
      Overrides:
      addComponent in class Component<Tab>
      Parameters:
      component - The tab page component, that is to be added.
      Returns:
      The tab component
      Throws:
      IllegalArgumentException - If the specified component is not a TabPage, or extends from it.
    • onShow

      public void onShow()
      Description copied from class: Component
      The operations to be executed after the component is displayed on the client

      By default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is displayed. This method is nearly identical to the afterDraw() method, they differ in when they are executed. This method runs after the component is displayed on the client. Meaning that it is executed even if the component isn't redrawn, but only set to be visible after being hidden.

      Overrides:
      onShow in class Component<Tab>
    • onHide

      public void onHide()
      Description copied from class: Component
      The operations to be executed after the component is hidden on the client

      By default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is hidden.

      Overrides:
      onHide in class Component<Tab>
    • removeTabPage

      public Tab removeTabPage(TabPage tabPage)
      Removes a tab page from the tab component
      Parameters:
      tabPage - The tab page component instance that will be added to the tab
      Returns:
      The tab component
    • removeTabPage

      public Tab removeTabPage(int index)
      Removes the specified tab page from the component. The page can be specified by using its index. If the tab page is in an active state, then after it is removed, the first tab page will be active.
      Parameters:
      index - The index of the tab page to be removed.
      Returns:
      The tab component
    • selectTab

      public final Tab selectTab(int index)
      Selects a tab page (makes it active). The tab page can be specified by its index. An active tab page's contents are displayed on the interface.
      Parameters:
      index - The index of the tab page to be selected (to be made active)
      Returns:
      The tab component
    • selectTab

      public final Tab selectTab(TabPage page)
      Selects the specified tab page. When a tab page is selected, it is active, and its contents will be displayed on the interface.
      Parameters:
      page - The instance of the tab page to be selected.
      Returns:
      The tab component
    • next

      public Tab next()
      Selects the tab page, that is to the right of the currently selected (active) tab page. If the currently selected tab page is the last one, the method won't do anything.
      Returns:
      The tab component
    • previous

      public Tab previous()
      Selects the tab page, that is to the left of the currently selected (active) tab page. If the currently selected tab page is the first one, the method won't do anything.
      Returns:
      The tab component
    • getTabPage

      public TabPage getTabPage(int index)
      Gets the specified (by using its index) tab page
      Parameters:
      index - The index of the tab page
      Returns:
      The tab page corresponding ot the specified index, or null, if the index doesn't correspond to a tab page.
    • setTabType

      public final Tab setTabType(TabType tabType)
      Sets the type of the tab pages.
      Parameters:
      tabType - The tab position. For applicable values, see the TabType enum. If null, the tab will use the default type.
      Returns:
      The tab component
    • getTabType

      public final TabType getTabType()
      Gets the tab type (position)
      Returns:
      The tab type (position)
    • writeHTML

      public boolean writeHTML(StringWriter writer)
      Description copied from class: Component
      Creates the component's HTML equivalent

      This method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (StringWriter class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return with false. Otherwise, it must return with true.

      Specified by:
      writeHTML in class Component<Tab>
      Returns:
      If the componentwas drawn, true, otherwise false
    • getCurrentTabPageIndex

      public Integer getCurrentTabPageIndex()
      Gets the index of the currently selected (active) tab page.
      Returns:
      The index of the tab page, or null, if there isn't an active tab page.
    • getTabPages

      public List<TabPage> getTabPages()
      Gets every tab page that is assigned to the tab component.
      Returns:
      A list of the tab pages. If the tab component has nothing assigned to it, the list will be empty.
    • addTabClickHandler

      public Tab addTabClickHandler(ClickEventHandler handler)
      Adds a tab page click handler (tab page change event). The specified event will be added to every tab page, so the event will be executed, regardless of which tab page the user clicks on.
      Parameters:
      handler - The ClickEventHandler implementation
      See Also:
    • addTabClickHandler

      public Tab addTabClickHandler(int tabIndex, ClickEventHandler handler)
      Adds a tab page click handler (tab page change event) to the specified tab page. The specified handler will only run, if the user chooses the specified tab page.
      Parameters:
      tabIndex - The index of the tab page, that will have the handler added to it.
      handler - The ClickEventHandler implementation
      See Also:
    • getTabPagesCount

      public int getTabPagesCount()
      Counts the tab pages that are added to the tab component.
      Returns:
      The amount of the tab pages. If the tab component has none assigned to it, it will return with 0.
    • getCurrentTabPage

      public TabPage getCurrentTabPage()
      Gets the currently active tab page component.
      Returns:
      The tab page component, that is currently active, or null, if there is no active tab page at the time of the query.