Class Tab

All Implemented Interfaces:
HasHandlers, HasTabDeselectedHandlers, HasTabSelectedHandlers

public class Tab extends RefDataClass implements HasTabDeselectedHandlers, HasTabSelectedHandlers
Tab instances for use with TabSet. Tab instances specify the appearance (setTitle, setIcon) of the tab, and provide the tab's pane. See setTabs for further details.
  • Constructor Details

  • Method Details

    • getOrCreateRef

      public static Tab getOrCreateRef(JavaScriptObject jsObj)
    • setCanAdaptWidth

      public Tab setCanAdaptWidth(Boolean canAdaptWidth)
      If enabled, the tab will collapse to show just its icon when showing the title would cause overflow of a containing TabBar. While collapsed, the tab will show its title on hover, unless an explicit hover has been specified such as by prompt.
      Parameters:
      canAdaptWidth - New canAdaptWidth value. Default value is false
      Returns:
      Tab instance, for chaining setter calls
      See Also:
    • getCanAdaptWidth

      public Boolean getCanAdaptWidth()
      If enabled, the tab will collapse to show just its icon when showing the title would cause overflow of a containing TabBar. While collapsed, the tab will show its title on hover, unless an explicit hover has been specified such as by prompt.
      Returns:
      Current canAdaptWidth value. Default value is false
      See Also:
    • getCanClose

      public Boolean getCanClose()
      Determines whether this tab should show a close icon allowing the user to dismiss the tab by clicking on the close icon directly. The URL for the close icon's image will be derived from TabSet.closeTabIcon by default, but may be overridden by explicitly specifying closeIcon.

      If unset or null, this property is derived from TabSet.canCloseTabs.

      Note that setting canClose means that icon cannot be used, because it's used for the closeIcon - see TabSet.canCloseTabs for a workaround.

      Returns:
      Current canClose value. Default value is null
      See Also:
    • getCanEditTitle

      public Boolean getCanEditTitle()
      If specified, overrides the TabSet.canEditTabTitles setting, for this one tab only.

      Note that the TabSet's titleEditEvent must be set to a supported TabTitleEditEvent in order for users to be able to edit this tab's title.

      Returns:
      Current canEditTitle value. Default value is null
      See Also:
    • setCanReorder

      public Tab setCanReorder(Boolean canReorder)
      If TabSet.canReorderTabs is set to true, setting canReorder explicitly to false for some tab will disallow drag-reordering of this tab. Has no effect if canReorderTabs is not true at the tabSet level.

      Note that this setting also disallows a reorder of another tab into the slot before or following this tab. This means for tabs located at the beginning or end of the tab-bar, users cannot changing the index of the tab by dropping another before or after it. However if you have a canReorder:false tab which is not at the beginning or end of the tab bar, users can drag reorder other tabs around it which may ultimately change its position.

      Parameters:
      canReorder - New canReorder value. Default value is null
      Returns:
      Tab instance, for chaining setter calls
      See Also:
    • getCanReorder

      public Boolean getCanReorder()
      If TabSet.canReorderTabs is set to true, setting canReorder explicitly to false for some tab will disallow drag-reordering of this tab. Has no effect if canReorderTabs is not true at the tabSet level.

      Note that this setting also disallows a reorder of another tab into the slot before or following this tab. This means for tabs located at the beginning or end of the tab-bar, users cannot changing the index of the tab by dropping another before or after it. However if you have a canReorder:false tab which is not at the beginning or end of the tab bar, users can drag reorder other tabs around it which may ultimately change its position.

      Returns:
      Current canReorder value. Default value is null
      See Also:
    • getCloseIcon

      public String getCloseIcon()
      Custom src for the close icon for this tab to display if it is closeable. See canClose and TabSet.canCloseTabs.
      Returns:
      Current closeIcon value. Default value is null
      See Also:
    • getCloseIconSize

      public Integer getCloseIconSize()
      Size of the closeIcon for this tab. If unspecified the icon will be sized according to TabSet.closeTabIconSize
      Returns:
      Current closeIconSize value. Default value is null
    • getDisabled

      public Boolean getDisabled()
      If specified, this tab will initially be rendered in a disabled state. methods.
      Returns:
      Current disabled value. Default value is null
    • setEnableWhen

      public Tab setEnableWhen(Criteria enableWhen)
      Criteria to be evaluated to determine whether this Tab should be enabled.

      A basic criteria uses textMatchStyle:"exact". When specified in Component XML this property allows shorthand formats for defining criteria.

      Parameters:
      enableWhen - New enableWhen value. Default value is null
      Returns:
      Tab instance, for chaining setter calls
      See Also:
    • getEnableWhen

      public Criteria getEnableWhen()
      Criteria to be evaluated to determine whether this Tab should be enabled.

      A basic criteria uses textMatchStyle:"exact". When specified in Component XML this property allows shorthand formats for defining criteria.

      Returns:
      Current enableWhen value. Default value is null
      See Also:
    • setHidden

      public Tab setHidden(Boolean hidden)
      If specified this tab will be hidden by default. To show and hide tabs at runtime use TabSet.showTab() and TabSet.hideTab()
      Parameters:
      hidden - New hidden value. Default value is null
      Returns:
      Tab instance, for chaining setter calls
    • getHidden

      public Boolean getHidden()
      If specified this tab will be hidden by default. To show and hide tabs at runtime use TabSet.showTab() and TabSet.hideTab()
      Returns:
      Current hidden value. Default value is null
    • getIcon

      public String getIcon()
      If specified, this tab will show an icon next to the tab title.

      NOTE: if you enable closeable tabs, tab.icon is used for the close icon. TabSet.canCloseTabs describes a workaround to enable both a closeIcon and a second icon to be shown.

      Use TabSet.tabIconClick() to add an event handler specifically for clicks on the icon.

      If a tab becomes disabled, a different icon will be loaded by adding a suffix to the image name (see Button.icon).

      You should specify a size for the icon via iconSize or iconWidth and iconHeight. Without an explicitly specified size, tabs may be drawn overlapping or with gaps the first time a page is loaded, because the icon is not cached and therefore its size isn't known.

      Returns:
      Current icon value. Default value is null
      See Also:
    • getIconHeight

      public Integer getIconHeight()
      If icon is specified, this property may be used to specify a height for the icon.
      Returns:
      Current iconHeight value. Default value is null
    • getIconSize

      public Integer getIconSize()
      If icon is specified, this property may be used to specify a size for the icon. Per side sizing may be specified instead via iconWidth and iconHeight.
      Returns:
      Current iconSize value. Default value is 16
    • getIconWidth

      public Integer getIconWidth()
      If icon is specified, this property may be used to specify a width for the icon.
      Returns:
      Current iconWidth value. Default value is null
    • setName

      public Tab setName(String name)
      Optional name for the tab, which can later be used to reference the tab. APIs requiring a reference to a tab will accept the tab's name [including TabSet.selectTab(), TabSet.updateTab(), TabSet.removeTab()].
      This name will also be passed to the TabSet.tabSelected() and TabSet.tabDeselected() handler functions, if specified.

      This identifier is requred to be locally unique to the TabSet and cannot be used to get a global reference to the Tab. If you want a global reference, set ID instead.

      Parameters:
      name - New name value. Default value is null
      Returns:
      Tab instance, for chaining setter calls
      See Also:
    • getName

      public String getName()
      Optional name for the tab, which can later be used to reference the tab. APIs requiring a reference to a tab will accept the tab's name [including TabSet.selectTab(), TabSet.updateTab(), TabSet.removeTab()].
      This name will also be passed to the TabSet.tabSelected() and TabSet.tabDeselected() handler functions, if specified.

      This identifier is requred to be locally unique to the TabSet and cannot be used to get a global reference to the Tab. If you want a global reference, set ID instead.

      Returns:
      Current name value. Default value is null
      See Also:
    • getPane

      public Canvas getPane()
      Specifies the pane associated with this tab. You have three options for the value of the pane attribute:
      • ID - The global ID of an already created Canvas (or subclass).
      • Canvas - A live instance of a Canvas (or subclass).
      • AutoChildShortcut - String with format "autoChild:autoChildName"
      Returns:
      Current pane value. Default value is null
      See Also:
    • setPaneMargin

      public Tab setPaneMargin(Integer paneMargin)
      Space to leave around the pane within this Tab. If specified, this property takes precedence over TabSet.paneMargin
      Parameters:
      paneMargin - New paneMargin value. Default value is null
      Returns:
      Tab instance, for chaining setter calls
    • getPaneMargin

      public Integer getPaneMargin()
      Space to leave around the pane within this Tab. If specified, this property takes precedence over TabSet.paneMargin
      Returns:
      Current paneMargin value. Default value is null
    • getPickerTitle

      public String getPickerTitle()
      If TabSet.showTabPicker is true for this TabSet, if set this property will determine the title of the picker menu item for this tab. If unset, title will be used instead.
      Returns:
      Current pickerTitle value. Default value is null
      See Also:
    • getPrompt

      public String getPrompt()
      Specifies the prompt to be displayed when the mouse hovers over the tab.
      Returns:
      Current prompt value. Default value is null
      See Also:
    • getTitle

      public String getTitle()
      Specifies the title of the this tab.
      Returns:
      Current title value. Default value is null
      See Also:
    • setVisibleWhen

      public Tab setVisibleWhen(Criteria visibleWhen)
      Criteria to be evaluated to determine whether this Tab should be visible.

      A basic criteria uses textMatchStyle:"exact". When specified in Component XML this property allows shorthand formats for defining criteria.

      Parameters:
      visibleWhen - New visibleWhen value. Default value is null
      Returns:
      Tab instance, for chaining setter calls
      See Also:
    • getVisibleWhen

      public Criteria getVisibleWhen()
      Criteria to be evaluated to determine whether this Tab should be visible.

      A basic criteria uses textMatchStyle:"exact". When specified in Component XML this property allows shorthand formats for defining criteria.

      Returns:
      Current visibleWhen value. Default value is null
      See Also:
    • getWidth

      public int getWidth()
      You can specify an explicit width for the tab using this property. Note that tabs automatically size to make room for the full title, but if you want to e.g. specify a uniform width for all tabs in a TabSet, this property enables you to do so.

      Returns:
      Current width value. Default value is 100
    • addTabDeselectedHandler

      public HandlerRegistration addTabDeselectedHandler(TabDeselectedHandler handler)
      Add a tabDeselected handler.

      Optional handler to fire when a tab is deselected. Calling TabDeselectedEvent.cancel will cancel the new selection, leaving this tab selected. As with TabSet.tabSelected() this method only fires when the tabset is drawn.

      Specified by:
      addTabDeselectedHandler in interface HasTabDeselectedHandlers
      Parameters:
      handler - the tabDeselected handler
      Returns:
      HandlerRegistration used to remove this handler
    • addTabSelectedHandler

      public HandlerRegistration addTabSelectedHandler(TabSelectedHandler handler)
      Add a tabSelected handler.

      Optional handler to fire when a tab is selected. As with TabSet.tabSelected() this method only fires when the tabset is drawn.

      Specified by:
      addTabSelectedHandler in interface HasTabSelectedHandlers
      Parameters:
      handler - the tabSelected handler
      Returns:
      HandlerRegistration used to remove this handler
    • setID

      public void setID(String ID)
      Optional ID for the tab, which can later be used to reference the tab. APIs requiring a reference to a tab will accept the tabs ID [including TabSet.selectTab, TabSet.updateTab, TabSet.removeTab].
      The ID will also be passed to the TabSet.tabSelected and TabSet.tabDeselected handler functions, if specified.

      Note that if you provide an ID, it must be globally unique.

      Parameters:
      ID - ID Default value is null
    • getID

      public String getID()
      Optional ID for the tab, which can later be used to reference the tab. APIs requiring a reference to a tab will accept the tabs ID [including TabSet.selectTab, TabSet.updateTab, TabSet.removeTab].
      The ID will also be passed to the TabSet.tabSelected and TabSet.tabDeselected handler functions, if specified.

      Note that if you provide an ID, it must be globally unique.

      Returns:
      String
    • setTitle

      public void setTitle(String title)
      Specifies the title of the this tab. To change the title after the TabSet has been created, call TabSet.setTabTitle.
      Parameters:
      title - title Default value is null
    • setDisabled

      public void setDisabled(boolean disabled)
      If specified, this tab will initially be rendered in a disabled state.
      Parameters:
      disabled - disabled Default value is null
    • setIcon

      public void setIcon(String icon)
      If specified, this tab will show an icon next to the tab title. Note that as with icon, the URL of a tabs icon will be updated to reflect disabled state.
      If desired a click handler may be assigned to the icon, which will be fired when the user clicks the tab. This method takes a single parameter tab, a pointer to the tab object.
      Parameters:
      icon - icon Default value is null
      See Also:
    • setIcon

      public void setIcon(String icon, int iconWidth, int iconHeight)
      If specified, this tab will show an icon next to the tab title. Note that as with icon, the URL of a tabs icon will be updated to reflect disabled state.
      If desired a click handler may be assigned to the icon, which will be fired when the user clicks the tab. This method takes a single parameter tab, a pointer to the tab object.
      Parameters:
      icon - icon Default value is null
      iconWidth - the icon width
      iconHeight - the icon height
      See Also:
    • setIcon

      public void setIcon(String icon, int iconSize)
      If specified, this tab will show an icon next to the tab title. Note that as with icon, the URL of a tabs icon will be updated to reflect disabled state.
      If desired a click handler may be assigned to the icon, which will be fired when the user clicks the tab. This method takes a single parameter tab, a pointer to the tab object.
      Parameters:
      icon - icon Default value is null
      iconSize - the icon size
      See Also:
    • setIconSize

      public void setIconSize(Integer iconSize)
      If icon is specified, this property may be used to specify a size for the icon. Per side sizing may be specified instead via iconWidth and iconHeight.
      Parameters:
      iconSize - New iconSize value. Default value is 16
    • setIconWidth

      public void setIconWidth(Integer iconWidth)
      If icon is specified, this property may be used to specify a width for the icon.
      Parameters:
      iconWidth - New iconWidth value. Default value is null
    • setIconHeight

      public void setIconHeight(Integer iconHeight)
      If icon is specified, this property may be used to specify a height for the icon.
      Parameters:
      iconHeight - New iconHeight value. Default value is null
    • setPickerTitle

      public void setPickerTitle(String pickerTitle)
      If TabSet.showTabPicker is true for this TabSet, if set this property will determine the title of the picker menu item for this tab. If unset, title will be used instead
      Parameters:
      pickerTitle - New pickerTitle value. Default value is null
      See Also:
    • setWidth

      public void setWidth(int width)
      You can specify an explicit width for the tab using this property. Note that tabs automatically size to make room for the full title, but if you want to e.g. specify a uniform width for all tabs in a TabSet, this property enables you to do so.
      Parameters:
      width - New width value. Default value is 100
    • setPrompt

      public void setPrompt(String prompt)
      Specifies the prompt to be displayed when the mouse hovers over the tab.
      Parameters:
      prompt - New prompt value. Default value is null
      See Also:
    • setCanEditTitle

      public void setCanEditTitle(Boolean canEditTitle)
      If specified, overrides the TabSet.canEditTabTitles setting, for this one tab only.

      Note that the TabSet's titleEditEvent must be set to a supported TabTitleEditEvent in order for users to be able to edit this tab's title.

      Parameters:
      canEditTitle - New canEditTitle value. Default value is null
      See Also:
    • setCanClose

      public void setCanClose(Boolean canClose)
      Determines whether this tab should show a close icon allowing the user to dismiss the tab by clicking on the close icon directly. The URL for the close icon's image will be{M{ derived from TabSet.closeTabIcon by default, but may be overridden by explicitly specifying closeIcon.

      If unset or null, this property is derived from TabSet.canCloseTabs.

      Note that setting canClose means that icon cannot be used, because it's used for the closeIcon - see TabSet.canCloseTabs for a workaround.

      Parameters:
      canClose - New canClose value. Default value is null
      See Also:
    • setCanClose

      public void setCanClose(boolean canClose)
      Parameters:
      canClose - New canClose value.
    • setCloseIcon

      public void setCloseIcon(String closeIcon)
      Custom src for the close icon for this tab to display if it is closeable. See canClose and TabSet.canCloseTabs.
      Parameters:
      closeIcon - New closeIcon value. Default value is null
      See Also:
    • setCloseIconSize

      public void setCloseIconSize(Integer closeIconSize)
      Size of the closeIcon for this tab. If unspecified the icon will be sized according to TabSet.closeTabIconSize
      Parameters:
      closeIconSize - New closeIconSize value. Default value is null
    • setPaneID

      public void setPaneID(String paneID)
    • setTitleStyle

      public void setTitleStyle(String titleStyle)
      Provide a separate style for the title text. If set and the ImgTab is vertical, a "v" will be automatically prepended to the style name (hence "tabTitle" -> "vtabTitle").
      Parameters:
      titleStyle - the title style
    • getTitleStyle

      public String getTitleStyle()
      A separate style for the title text. If set and the ImgTab is vertical, a "v" will be automatically prepended to the style name (hence "tabTitle" -> "vtabTitle").
      Returns:
      the title style
    • setPane

      public void setPane(Canvas pane)
      Specifies the pane associated with this tab. You can change the pane associated with a given tab after the TabSet has been created by calling TabSet.updateTab(int, com.smartgwt.client.widgets.Canvas)
      Parameters:
      pane - the tab pane
    • setContextMenu

      public void setContextMenu(Menu contextMenu)
      Context menu to show for this tab.
      Parameters:
      contextMenu - contextMenu Default value is null
    • getContextMenu

      public Menu getContextMenu()
      Context menu to show for this object, an instance of the Menu widget.
      Returns:
      Menu
    • getTabSet

      public TabSet getTabSet()
    • setTabSet

      public void setTabSet(TabSet tabSet)
    • getTabCanvas

      public StatefulCanvas getTabCanvas()
      Returns the live Canvas used to represent this tab in a tabSet. Will return null if this Tab has not been added to a TabSet or if the tabset is not yet drawn.

      The underlying SmartClient class of the returned canvas depends on #getUseSimpleTabs. If this property is false, the returned canvas will be a ImgTab instance. If true the canvas will be a com.smartgwt.client.widgets.tab.Button instance. Note that you can make use of ImgTab APIs by using the getJsObj() and create() APIs to "cast" to the appropriate type - for example:
      ImgTab liveTab = ImgTab.create(myTabSet.getTabCanvas(2).getJsObj());

      Returns:
      live Canvas for this tab in a tabSet.