Class ResourceManager


  • public class ResourceManager
    extends SWTResourceManager
    Utility class for managing OS resources associated with SWT/JFace controls such as colors, fonts, images, etc. !!! IMPORTANT !!! Application code must explicitly invoke the dispose() method to release the operating system resources managed by cached objects when those objects and OS resources are no longer needed (e.g. on application shutdown) This class may be freely distributed as part of any application or plugin.

    • Constructor Detail

      • ResourceManager

        public ResourceManager()
    • Method Detail

      • getImageDescriptor

        public static ImageDescriptor getImageDescriptor​(Class<?> clazz,
                                                         String path)
        Returns an ImageDescriptor stored in the file at the specified path relative to the specified class.
        Parameters:
        clazz - the Class relative to which to find the image descriptor.
        path - the path to the image file.
        Returns:
        the ImageDescriptor stored in the file at the specified path.
      • getImageDescriptor

        public static ImageDescriptor getImageDescriptor​(String path)
        Returns an ImageDescriptor stored in the file at the specified path.
        Parameters:
        path - the path to the image file.
        Returns:
        the ImageDescriptor stored in the file at the specified path.
      • decorateImage

        public static Image decorateImage​(Image baseImage,
                                          Image decorator)
        Returns an Image composed of a base image decorated by another image.
        Parameters:
        baseImage - the base Image that should be decorated.
        decorator - the Image to decorate the base image.
        Returns:
        Image The resulting decorated image.
      • decorateImage

        public static Image decorateImage​(Image baseImage,
                                          Image decorator,
                                          int corner)
        Returns an Image composed of a base image decorated by another image.
        Parameters:
        baseImage - the base Image that should be decorated.
        decorator - the Image to decorate the base image.
        corner - the corner to place decorator image.
        Returns:
        the resulting decorated Image.
      • disposeImages

        public static void disposeImages()
        Dispose all of the cached images.
      • getPluginImage

        @Deprecated
        public static Image getPluginImage​(Object plugin,
                                           String name)
        Deprecated.
        Returns an Image based on a plugin and file path.
        Parameters:
        plugin - the plugin Object containing the image
        name - the path to the image within the plugin
        Returns:
        the Image stored in the file at the specified path
      • getPluginImage

        public static Image getPluginImage​(String symbolicName,
                                           String path)
        Returns an Image based on a Bundle and resource entry path.
        Parameters:
        symbolicName - the symbolic name of the Bundle.
        path - the path of the resource entry.
        Returns:
        the Image stored in the file at the specified path.
      • getPluginImageDescriptor

        public static ImageDescriptor getPluginImageDescriptor​(String symbolicName,
                                                               String path)
        Returns an ImageDescriptor based on a Bundle and resource entry path.
        Parameters:
        symbolicName - the symbolic name of the Bundle.
        path - the path of the resource entry.
        Returns:
        the ImageDescriptor based on a Bundle and resource entry path.
      • dispose

        public static void dispose()
        Dispose of cached objects and their underlying OS resources. This should only be called when the cached objects are no longer needed (e.g. on application shutdown).