Class JsonMenuItem

    • Constructor Summary

      Constructors 
      Constructor Description
      JsonMenuItem​(com.fasterxml.jackson.databind.JsonNode node)
      Create a menu item from a JSON object.
    • Method Summary

      All Methods Instance Methods Concrete 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.
      • Methods inherited from class java.lang.Object

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

      • JsonMenuItem

        public JsonMenuItem​(@Nonnull
                            com.fasterxml.jackson.databind.JsonNode node)
                     throws java.lang.IllegalArgumentException
        Create a menu item from a JSON object.
        Parameters:
        node - the JSON object containing the menu item
        Throws:
        java.lang.IllegalArgumentException - if node does not contain a path node
    • Method Detail

      • getPath

        public java.lang.String getPath()
        Description copied from interface: WebMenuItem
        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.

        Specified by:
        getPath in interface WebMenuItem
        Returns:
        the path to the menu item
      • getHref

        public java.lang.String getHref()
        Description copied from interface: WebMenuItem
        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.
        Specified by:
        getHref in interface WebMenuItem
        Returns:
        the hyper-reference or null if the item is not a link
      • getIconClass

        public java.lang.String getIconClass()
        Description copied from interface: WebMenuItem
        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.

        Specified by:
        getIconClass in interface WebMenuItem
        Returns:
        the class(es) for the icon or null if no icon is to be used
      • getTitle

        public java.lang.String getTitle​(java.util.Locale locale)
        Description copied from interface: WebMenuItem
        Get the title for the menu item. This is displayed in the menu.
        Specified by:
        getTitle in interface WebMenuItem
        Parameters:
        locale - the client locale
        Returns:
        the localized title
      • getPosition

        public int getPosition()
        Description copied from interface: WebMenuItem
        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.
        Specified by:
        getPosition in interface WebMenuItem
        Returns:
        the relative position
      • isSeparatedBefore

        public boolean isSeparatedBefore()
        Description copied from interface: WebMenuItem
        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.
        Specified by:
        isSeparatedBefore in interface WebMenuItem
        Returns:
        true if there should be a separator before the item; false otherwise
      • isSeparatedAfter

        public boolean isSeparatedAfter()
        Description copied from interface: WebMenuItem
        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.
        Specified by:
        isSeparatedAfter in interface WebMenuItem
        Returns:
        true if there should be a separator after the item; false otherwise
      • isDynamic

        public boolean isDynamic()
        Description copied from interface: WebMenuItem
        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.
        Specified by:
        isDynamic in interface WebMenuItem
        Returns:
        true if the menu item is an anchor for a dynamic menu; false otherwise