Interface WebMenuItem

  • All Known Implementing Classes:
    JsonMenuItem

    public interface WebMenuItem
    Provide a menu item used in the navigation bar on the JMRI web server.

    Note: the results of two or more WebMenuItems having the same path is undefined.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getHref()
      Get the URL for the menu item.
      java.lang.String getIconClass()
      Get the icon for the menu item.
      java.lang.String getPath()
      Get the path to the menu item.
      int getPosition()
      The relative position of the menu item.
      java.lang.String getTitle​(java.util.Locale locale)
      Get the title for the menu item.
      boolean isDynamic()
      Indicate if the menu item is the anchor for a dynamic menu.
      boolean isSeparatedAfter()
      Indicate if the menu item should have a separator after it.
      boolean isSeparatedBefore()
      Indicate if the menu item should have a separator before it.
    • Method Detail

      • getPath

        @Nonnull
        java.lang.String getPath()
        Get the path to the menu item. This should be the same regardless of locale. Use forward slashes (/ ) to separate menu items to create sub menus. Menu items will have the id navbar-<path>

        Primary menu items will not have a separator.

        Returns:
        the path to the menu item
      • getHref

        @CheckForNull
        java.lang.String getHref()
        Get the URL for the menu item. This may be an absolute URL path in the JMRI web service, a URL that resolves to some other location, or a JavaScript trigger. If null, the menu item will not have a link. If the HREF starts with ng-click:, it will be treated as a JavaScript trigger instead of a URL.
        Returns:
        the hyper-reference or null if the item is not a link
      • getIconClass

        @CheckForNull
        java.lang.String getIconClass()
        Get the icon for the menu item. This icon needs to be the class attributes for the HTML span element that contains the icon. It is recommended that this icon be one of the Font Awesome or Patternfly icons as these icon sets will be available.

        Icons will only be displayed for items in the primary menu.

        Returns:
        the class(es) for the icon or null if no icon is to be used
      • getTitle

        @Nonnull
        java.lang.String getTitle​(@Nonnull
                                  java.util.Locale locale)
        Get the title for the menu item. This is displayed in the menu.
        Parameters:
        locale - the client locale
        Returns:
        the localized title
      • getPosition

        int getPosition()
        The relative position of the menu item. If two menu items have the same relative position, they will be sorted in order by the path. For items within a sub menu, this position only applies to the sub menu.
        Returns:
        the relative position
      • isSeparatedBefore

        boolean isSeparatedBefore()
        Indicate if the menu item should have a separator before it. Note that if there are multiple items with the same position, they will be grouped on the same side of the separator if any of the items requires a separator.
        Returns:
        true if there should be a separator before the item; false otherwise
      • isSeparatedAfter

        boolean isSeparatedAfter()
        Indicate if the menu item should have a separator after it. Note that if there are multiple items with the same position, they will be grouped on the same side of the separator if any of the items requires a separator.
        Returns:
        true if there should be a separator after the item; false otherwise
      • isDynamic

        boolean isDynamic()
        Indicate if the menu item is the anchor for a dynamic menu. A dynamic menu is one that is built on as needed, often by JavaScript executed on the client.
        Returns:
        true if the menu item is an anchor for a dynamic menu; false otherwise