Class FileIconService


  • public class FileIconService
    extends java.lang.Object
    Provides Icons that represent the type and status of a file, based on a filename mapping and caller specified status overlays.

    The mappings between a file's extension and its icon are stored in a resource file called "file_extension_icons.xml", which is read and parsed the first time this service is referenced.

    Status overlays are also specified in the file_extension_icons.xml file, and are resized to be 1/2 the width and height of the icon they are being overlayed on.

    Threadsafe

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javax.swing.Icon getImage​(java.lang.String fileName, java.lang.String... overlays)
      Returns an Icon that represents a file's content based on its name.
      static FileIconService getInstance()  
      protected void loadIfNeeded()
      Check to see if XML file has changed.
      • Methods inherited from class java.lang.Object

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

      • OVERLAY_IMPORTED

        public static final java.lang.String OVERLAY_IMPORTED
        See Also:
        Constant Field Values
      • OVERLAY_FILESYSTEM

        public static final java.lang.String OVERLAY_FILESYSTEM
        See Also:
        Constant Field Values
    • Method Detail

      • getImage

        public javax.swing.Icon getImage​(java.lang.String fileName,
                                         java.lang.String... overlays)
        Returns an Icon that represents a file's content based on its name.
        Parameters:
        fileName - name of file that an icon is being requested for.
        overlays - optional list of overlay names, names of icons that should be overlaid on top of the base icon, that represent a status or feature independent of the file's base icon.
        Returns:
        Icon instance that best represents the named file, never null.
      • loadIfNeeded

        protected void loadIfNeeded()
        Check to see if XML file has changed. If so, then reload the file. This action will dynamically update the icons without having to restart.