Class MenuItemNavigation

  • All Implemented Interfaces:

    
    public final class MenuItemNavigation
    
                        

    Menu item lookup shared by the menu testers.

    A path addresses an item the way the browser shows it: by the text of each item in the hierarchy, or by the zero-based position of each item among the visible ones. The item at the end of the path must be enabled and visible, since a user cannot click anything else.

    For internal use only.

    Since:

    25.3

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static <C extends ContextMenuBase<C, I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> I findByPath(List<I> rootItems, String topLevelText, Array<String> nestedItemsText) Finds the menu item addressed by the given text path.
      static <C extends ContextMenuBase<C, I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> I findByPath(List<I> rootItems, int topLevelPosition, Array<int> nestedItemsPositions) Finds the menu item addressed by the given position path.
      static List<String> visibleTexts(List<out MenuItemBase<out Object, out Object, out Object>> items) Gets the texts of the given menu items as the browser shows them, i.e.
      static <C extends ContextMenuBase<C, I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> List<String> visibleSubMenuTexts(List<I> rootItems, String topLevelText, Array<String> nestedItemsText) Gets the texts of the visible items of the sub menu of the item addressed by the given text path.
      static void requireCheckable(MenuItemBase<out Object, out Object, out Object> menuItem, String path) Ensures that the given menu item is checkable, as only a checkable item has a checked state to read.
      static String pathToString(String topLevelText, Array<String> nestedItemsText) Renders a text path the way it is reported in error messages.
      static String pathToString(int topLevelPosition, Array<int> nestedItemsPositions) Renders a position path the way it is reported in error messages.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • findByPath

         static <C extends ContextMenuBase<C, I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> I findByPath(List<I> rootItems, String topLevelText, Array<String> nestedItemsText)

        Finds the menu item addressed by the given text path.

        Parameters:
        rootItems - the items of the top level menu
        topLevelText - the text content of the top level menu item, not null
        nestedItemsText - text content of the nested menu items
        Returns:

        the menu item at the given path

      • findByPath

         static <C extends ContextMenuBase<C, I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> I findByPath(List<I> rootItems, int topLevelPosition, Array<int> nestedItemsPositions)

        Finds the menu item addressed by the given position path.

        Parameters:
        rootItems - the items of the top level menu
        topLevelPosition - the zero-based position of the item in the menu, as it will be seen in the browser
        nestedItemsPositions - the zero-based position of the nested items, relative to the parent menu
        Returns:

        the menu item at the given path

      • visibleTexts

         static List<String> visibleTexts(List<out MenuItemBase<out Object, out Object, out Object>> items)

        Gets the texts of the given menu items as the browser shows them, i.e. only the visible ones, in their order.

        An item created from a component has no text of its own, so it is reported as an empty string.

        Parameters:
        items - the items of a menu level
        Returns:

        the texts of the visible items

      • visibleSubMenuTexts

         static <C extends ContextMenuBase<C, I, S>, I extends MenuItemBase<C, I, S>, S extends SubMenuBase<C, I, S>> List<String> visibleSubMenuTexts(List<I> rootItems, String topLevelText, Array<String> nestedItemsText)

        Gets the texts of the visible items of the sub menu of the item addressed by the given text path.

        Parameters:
        rootItems - the items of the top level menu
        topLevelText - the text content of the top level menu item, not null
        nestedItemsText - text content of the nested menu items
        Returns:

        the texts of the visible items of the sub menu

      • requireCheckable

         static void requireCheckable(MenuItemBase<out Object, out Object, out Object> menuItem, String path)

        Ensures that the given menu item is checkable, as only a checkable item has a checked state to read.

        Parameters:
        menuItem - the menu item to check
        path - the path the item was addressed by, for the error message
      • pathToString

         static String pathToString(String topLevelText, Array<String> nestedItemsText)

        Renders a text path the way it is reported in error messages.

        Parameters:
        topLevelText - the text content of the top level menu item
        nestedItemsText - text content of the nested menu items
        Returns:

        the path as a string

      • pathToString

         static String pathToString(int topLevelPosition, Array<int> nestedItemsPositions)

        Renders a position path the way it is reported in error messages.

        Parameters:
        topLevelPosition - the position of the top level menu item
        nestedItemsPositions - positions of the nested menu items
        Returns:

        the path as a string