Class IconManagerScriptService

  • All Implemented Interfaces:
    org.xwiki.script.service.ScriptService

    @Component
    @Named("icon")
    @Singleton
    public class IconManagerScriptService
    extends Object
    implements org.xwiki.script.service.ScriptService
    Script services to render an icon from the current icon set.
    Since:
    6.2M1
    Version:
    $Id: 42f770d5125cc901a27e07abc4da727dee8d7034 $
    • Constructor Detail

      • IconManagerScriptService

        public IconManagerScriptService()
    • Method Detail

      • render

        public String render​(String iconName)
        Display an icon with wiki code from the current IconSet.
        Parameters:
        iconName - name of the icon to display
        Returns:
        the wiki code that displays the icon
      • render

        public String render​(String iconName,
                             String iconSetName)
        Display an icon with wiki code from the specified IconSet.
        Parameters:
        iconName - name of the icon to display
        iconSetName - name of the icon set
        Returns:
        the wiki code that displays the icon
        Since:
        6.3RC1
      • render

        public String render​(String iconName,
                             String iconSetName,
                             boolean fallback)
        Display an icon with wiki code from the specified IconSet.
        Parameters:
        iconName - name of the icon to display
        iconSetName - name of the icon set
        fallback - enable the fallback to the default icon theme if the icon does not exist
        Returns:
        the wiki code that displays the icon
        Since:
        6.3RC1
      • renderHTML

        public String renderHTML​(String iconName)
        Display an icon with HTML code from the current IconSet.
        Parameters:
        iconName - name of the icon to display
        Returns:
        the HTML code that displays the icon
      • renderHTML

        public String renderHTML​(String iconName,
                                 String iconSetName)
        Display an icon with HTML code from the specified IconSet.
        Parameters:
        iconName - name of the icon to display
        iconSetName - name of the icon set
        Returns:
        the HTML code that displays the icon
        Since:
        6.3RC1
      • renderHTML

        public String renderHTML​(String iconName,
                                 String iconSetName,
                                 boolean fallback)
        Display an icon from the specified IconSet.
        Parameters:
        iconName - name of the icon to display
        iconSetName - name of the icon set
        fallback - enable the fallback to the default icon theme if the icon does not exist
        Returns:
        the HTML code that displays the icon
        Since:
        6.3RC1
      • use

        public void use()
        Pull the necessary resources to use the default icon set.
        Since:
        10.6RC1
      • use

        public void use​(String iconSetName)
        Pull the necessary resources to use the specified icon set.
        Parameters:
        iconSetName - name of the icon set
        Since:
        10.6RC1
      • getIconSetNames

        public List<String> getIconSetNames()
        Get the name of all the icon sets present in the current wiki.
        Returns:
        the list of the name of the icon sets present in the current wiki.
        Since:
        6.4M1
      • getIconNames

        public List<String> getIconNames()
        Get the list of the names of all available icons in the current icon set.
        Returns:
        the icon names
        Since:
        6.4M1
      • getIconNames

        public List<String> getIconNames​(String iconSetName)
        Get the list of the names of all available icons in the specified icon set.
        Parameters:
        iconSetName - name of the icon set
        Returns:
        the icon names
        Since:
        6.4M1
      • getCurrentIconSetName

        public String getCurrentIconSetName()
        Get the name of the current icon set.
        Returns:
        the name of the current icon set
        Since:
        6.4M2
      • getMetaData

        public Map<String,​Object> getMetaData​(String iconName)
                                             throws IconException
        Generate metadata of an icon.

        It can contain useful information such as:

        • The icon set name
        • The icon set type name
        • The icon url if defined
        • The icon css class if defined
        Parameters:
        iconName - name of the icon
        Returns:
        a metadata map
        Throws:
        IconException - if problems occur
        Since:
        10.6RC1
      • getMetaData

        public Map<String,​Object> getMetaData​(String iconName,
                                                    String iconSetName)
                                             throws IconException
        Generate metadata of an icon.

        It can contain useful information such as:

        • The icon set name
        • The icon set type name
        • The icon url if defined
        • The icon css class if defined
        Parameters:
        iconName - name of the icon
        iconSetName - name of the icon set to use
        Returns:
        a metadata map
        Throws:
        IconException - if problems occur
        Since:
        10.6RC1
      • getMetaData

        public Map<String,​Object> getMetaData​(String iconName,
                                                    String iconSetName,
                                                    boolean fallback)
                                             throws IconException
        Generate metadata of an icon.

        It can contain useful information such as:

        • The icon set name
        • The icon set type name
        • The icon url if defined
        • The icon css class if defined
        Parameters:
        iconName - name of the icon
        iconSetName - name of the icon set to use
        fallback - enable the fallback to the default icon set if the icon does not exist
        Returns:
        a metadata map
        Throws:
        IconException - if problems occur
        Since:
        10.6RC1
      • getLastError

        public IconException getLastError()
        Get the error generated while performing the previously called action.
        Returns:
        an eventual exception or null if no exception was thrown
        Since:
        6.3RC1