Class ContextMenuIconUtils

java.lang.Object
com.cloudbees.plugins.credentials.ContextMenuIconUtils

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class ContextMenuIconUtils extends Object
Some utility methods to help working with Icon, IconSet and ModelObjectWithContextMenu.ContextMenu.
Since:
2.0
  • Method Details

    • buildUrl

      @NonNull public static String buildUrl(String... segments)
      Combine segments of an URL in the style expected by ModelObjectWithContextMenu.MenuItem.
      Parameters:
      segments - the segments.
      Returns:
      the combined URL.
    • addMenuItem

      public static void addMenuItem(@NonNull ModelObjectWithContextMenu.ContextMenu menu, @CheckForNull String prefix, @NonNull Action action, @CheckForNull ModelObjectWithContextMenu.ContextMenu subMenu)
      Adds a menu item for the specified action with the supplied prefix offset and optional sub menu.
      Parameters:
      menu - the menu to add to.
      prefix - the prefix offset of the action urls.
      action - the action.
      subMenu - the sub menu.
    • addMenuItem

      public static void addMenuItem(@NonNull ModelObjectWithContextMenu.ContextMenu menu, @CheckForNull String prefix, @NonNull Action action)
      Adds a menu item for the specified action with the supplied prefix offset.
      Parameters:
      menu - the menu to add to.
      prefix - the prefix offset of the action urls.
      action - the action.
    • addMenuItem

      public static void addMenuItem(@NonNull ModelObjectWithContextMenu.ContextMenu menu, @NonNull Action action)
      Adds a menu item for the specified action.
      Parameters:
      menu - the menu to add to.
      action - the action.
    • getMenuItemIconUrlByClassSpec

      @CheckForNull public static String getMenuItemIconUrlByClassSpec(@CheckForNull String spec)
      Gets the qualified URL for an icon spec.
      Parameters:
      spec - the icon spec.
      Returns:
      the qualified URL for a menu item
    • getMenuItemIconUrl

      public static String getMenuItemIconUrl(String url)
      Converts a regular icon url into a menu item icon url
      Parameters:
      url - the "regular" icon url.
      Returns:
      the url for a menu item.
    • getIconByClassSpec

      @CheckForNull public static Icon getIconByClassSpec(String spec)
      Navigate the signature changes in different versions of IconSet.
      Parameters:
      spec - the spec to look up.
      Returns:
      the Icon or null
    • getIcon

      @CheckForNull public static Icon getIcon(@NonNull Action action)
      IconSet support has not been implemented for ModelObjectWithContextMenu.ContextMenu as of Jenkins 2.5. Hacks to work around some of the fun method signature migrations in IconSet.
      Parameters:
      action - the action.
      Returns:
      the Icon or null
    • getQualifiedUrl

      @CheckForNull public static String getQualifiedUrl(@CheckForNull Icon icon)
      Gets the qualified URL of the specified icon.
      Parameters:
      icon - the icon.
      Returns:
      the qualified URL of the icon.