Class AdaptiveMenu

All Implemented Interfaces:
HasAttachHandlers, HasHandlers, EventListener, HasVisibility, IsWidget, LogicalStructure, HasClearHandlers, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasRuleContextChangedHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers, HasMembersChangedHandlers

public class AdaptiveMenu extends Layout
A menu that can either show its menu options inline, or show them via a drop-down, depending on available space in the surrounding Layout or ToolStrip.

See canAdaptWidth for background on adaptive layout.

  • Constructor Details

    • AdaptiveMenu

      public AdaptiveMenu()
    • AdaptiveMenu

      public AdaptiveMenu(JavaScriptObject jsObj)
    • AdaptiveMenu

      public AdaptiveMenu(MenuItem[] items)
    • AdaptiveMenu

      public AdaptiveMenu(Menu menu)
  • Method Details

    • getOrCreateRef

      public static AdaptiveMenu getOrCreateRef(JavaScriptObject jsObj)
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, Canvas defaults)
      Changes the defaults for Canvas AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - Canvas defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • changeAutoChildDefaults

      public static void changeAutoChildDefaults(String autoChildName, FormItem defaults)
      Changes the defaults for FormItem AutoChildren named autoChildName.
      Parameters:
      autoChildName - name of an AutoChild to customize the defaults for.
      defaults - FormItem defaults to apply. These defaults override any existing properties without destroying or wiping out non-overridden properties. For usage tips on this param, see SGWTProperties.
      See Also:
    • create

      protected JavaScriptObject create()
      Overrides:
      create in class Layout
    • getInlineImgButton

      public ImgButton getInlineImgButton()
      Note : This API is non-functional (always returns null) and exists only to make you aware that this MultiAutoChild exists. See Using AutoChildren for details.

      ToolStripButton to display when showIconOnlyInline is set for one MenuItem

      Returns:
      null
    • getInlineMenuItem

      public ToolStripButton getInlineMenuItem()
      Note : This API is non-functional (always returns null) and exists only to make you aware that this MultiAutoChild exists. See Using AutoChildren for details.

      MultiAutoChild used to create inline menu items.

      The MenuItem.icon and MenuItem.title will be rendered via Button.icon and Button.title respectively; other MenuItem appearance-related properties do not apply.

      Returns:
      null
    • setInlinePlacement

      public AdaptiveMenu setInlinePlacement(Alignment inlinePlacement) throws IllegalStateException
      Placement of inlined items relative to the main MenuButton. Default is to place items above the menu if the parent is a Layout with vertical orientation, otherwise to the left of the menuButton (or right if the page is\n RTL (right-to-left).

      A setting of "center" is invalid and will cause a warning and be ignored

      Parameters:
      inlinePlacement - New inlinePlacement value. Default value is null
      Returns:
      AdaptiveMenu instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getInlinePlacement

      public Alignment getInlinePlacement()
      Placement of inlined items relative to the main MenuButton. Default is to place items above the menu if the parent is a Layout with vertical orientation, otherwise to the left of the menuButton (or right if the page is\n RTL (right-to-left).

      A setting of "center" is invalid and will cause a warning and be ignored

      Returns:
      Current inlinePlacement value. Default value is null
    • setInlinePlacement

      public AdaptiveMenu setInlinePlacement(VerticalAlignment inlinePlacement) throws IllegalStateException
      Placement of inlined items relative to the main MenuButton. Default is to place items above the menu if the parent is a Layout with vertical orientation, otherwise to the left of the menuButton (or right if the page is\n RTL (right-to-left).

      A setting of "center" is invalid and will cause a warning and be ignored

      Parameters:
      inlinePlacement - New inlinePlacement value. Default value is null
      Returns:
      AdaptiveMenu instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getInlinePlacementAsVerticalAlignment

      public VerticalAlignment getInlinePlacementAsVerticalAlignment()
      Placement of inlined items relative to the main MenuButton. Default is to place items above the menu if the parent is a Layout with vertical orientation, otherwise to the left of the menuButton (or right if the page is\n RTL (right-to-left).

      A setting of "center" is invalid and will cause a warning and be ignored

      Returns:
      Current inlinePlacement value. Default value is null
    • getInlineSubmenuItem

      public IconMenuButton getInlineSubmenuItem()
      Note : This API is non-functional (always returns null) and exists only to make you aware that this MultiAutoChild exists. See Using AutoChildren for details.

      MultiAutoChild used to create inline menu items for menu items that have a submenu.

      The MenuItem.icon and MenuItem.title will be rendered via IconButton.icon and Button.title respectively; other MenuItem appearance-related properties do not apply.

      Returns:
      null
    • setItems

      public AdaptiveMenu setItems(MenuItem... items)
      MenuItems to be show either inline or as a drop-down Menu.

      When shown inline, items are rendered as different com.smartgwt.client.types.AutoChild according to the settings on the MenuItem:

      Parameters:
      items - New items value. Default value is null
      Returns:
      AdaptiveMenu instance, for chaining setter calls
    • getItems

      public MenuItem[] getItems()
      MenuItems to be show either inline or as a drop-down Menu.

      When shown inline, items are rendered as different com.smartgwt.client.types.AutoChild according to the settings on the MenuItem:

      Returns:
      Current items value. Default value is null
    • getMenu

      public Menu getMenu() throws IllegalStateException
      Instance of the normal (non-Adaptive) Menu class used to show items that do not fit inline.

      This component is an AutoChild named "menu". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current menu value. Default value is null
      Throws:
      IllegalStateException - if this widget has not yet been rendered.
    • getMenuButton

      public MenuButton getMenuButton() throws IllegalStateException
      MenuButton used as a drop-down control for showing any items of the menu that are not displayed inline.

      This component is an AutoChild named "menuButton". For an overview of how to use and configure AutoChildren, see Using AutoChildren.

      Returns:
      Current menuButton value. Default value is null
      Throws:
      IllegalStateException - if this widget has not yet been rendered.
    • setMenuButtonIcon

      public AdaptiveMenu setMenuButtonIcon(String menuButtonIcon) throws IllegalStateException
      Icon used for the MenuButton. Default of null means to use the default for the MenuButton class.
      Parameters:
      menuButtonIcon - New menuButtonIcon value. Default value is null
      Returns:
      AdaptiveMenu instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getMenuButtonIcon

      public String getMenuButtonIcon()
      Icon used for the MenuButton. Default of null means to use the default for the MenuButton class.
      Returns:
      Current menuButtonIcon value. Default value is null
      See Also:
    • setMenuButtonTitle

      public AdaptiveMenu setMenuButtonTitle(String menuButtonTitle) throws IllegalStateException
      Title used for the MenuButton.
      Parameters:
      menuButtonTitle - New menuButtonTitle value. Default value is null
      Returns:
      AdaptiveMenu instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
      See Also:
    • getMenuButtonTitle

      public String getMenuButtonTitle()
      Title used for the MenuButton.
      Returns:
      Current menuButtonTitle value. Default value is null
      See Also:
    • setPartialInlining

      public AdaptiveMenu setPartialInlining(boolean partialInlining)
      If there is not enough space to show the full set of items as buttons inline, how should the Adaptive menu behave?
      If showPartialInlining is true, the menu will render as many items as inline buttons as can be shown in the available space, plus the menu button to access the remaining items.
      If false, it will show just the menu button.

      If there is enough space to show the full set of items inline they will be shown inline regardless of this property.

      Parameters:
      partialInlining - New partialInlining value. Default value is true
      Returns:
      AdaptiveMenu instance, for chaining setter calls
    • getPartialInlining

      public boolean getPartialInlining()
      If there is not enough space to show the full set of items as buttons inline, how should the Adaptive menu behave?
      If showPartialInlining is true, the menu will render as many items as inline buttons as can be shown in the available space, plus the menu button to access the remaining items.
      If false, it will show just the menu button.

      If there is enough space to show the full set of items inline they will be shown inline regardless of this property.

      Returns:
      Current partialInlining value. Default value is true
    • setShowIconOnlyInline

      public AdaptiveMenu setShowIconOnlyInline(boolean showIconOnlyInline) throws IllegalStateException
      Default setting for MenuItem.showIconOnlyInline. Individual items can set showIconOnlyInline to override this setting.
      Parameters:
      showIconOnlyInline - New showIconOnlyInline value. Default value is false
      Returns:
      AdaptiveMenu instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowIconOnlyInline

      public boolean getShowIconOnlyInline()
      Default setting for MenuItem.showIconOnlyInline. Individual items can set showIconOnlyInline to override this setting.
      Returns:
      Current showIconOnlyInline value. Default value is false
    • setShowInlineSeparators

      public AdaptiveMenu setShowInlineSeparators(Boolean showInlineSeparators) throws IllegalStateException
      Whether separators should be shown for inline menu items. True by default for horizontal orientation, false for vertical.
      Parameters:
      showInlineSeparators - New showInlineSeparators value. Default value is null
      Returns:
      AdaptiveMenu instance, for chaining setter calls
      Throws:
      IllegalStateException - this property cannot be changed after the component has been created
    • getShowInlineSeparators

      public Boolean getShowInlineSeparators()
      Whether separators should be shown for inline menu items. True by default for horizontal orientation, false for vertical.
      Returns:
      Current showInlineSeparators value. Default value is null
    • setDefaultProperties

      public static void setDefaultProperties(AdaptiveMenu adaptiveMenuProperties)
      Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

      Note: This method is intended for setting default attributes only and will affect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.

      Parameters:
      adaptiveMenuProperties - properties that should be used as new defaults when instances of this class are created
      See Also:
    • setLogicalStructure

      public LogicalStructureObject setLogicalStructure(AdaptiveMenuLogicalStructure s)
      Setter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
    • getLogicalStructure

      public LogicalStructureObject getLogicalStructure()
      Getter implementing the LogicalStructure interface, which supports Eclipse's logical structure debugging facility.
      Specified by:
      getLogicalStructure in interface LogicalStructure
      Overrides:
      getLogicalStructure in class Layout