psdi.workflow.util

Class Resources

  • java.lang.Object
    • psdi.workflow.util.Resources


  • public class Resources
    extends java.lang.Object
    This class is used to retrieve icon, strings etc based upon a String key.

    The format of the files are 'key=value'.

    Integers are one or more digits

    Booleans are one y,n,yes,no,t,f,true,false,on,off in any case.

    Colors are
    #RRGGBB or #AARRGGBB (Alpha pixels specification)
    A standard AWT name such as 'yellow'
    A Swing UI name such as "Label.foreground"

    Sizes are
    NNNxMMM

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected static java.util.Hashtable AWTColors
      AWT Color names
      protected static java.util.Hashtable booleans
      Boolean keywords
      static java.lang.String BUTTON_LABEL_CANCEL
      The Cancel button label
      static java.lang.String BUTTON_LABEL_OK
      The OK button label
      protected static java.lang.String DEFAULT_NAME 
      protected static java.util.Hashtable fontStyles 
      protected static IconHandler iconHandler
      The icon handler
      protected static boolean initialized
      The initialized flag
      protected static java.util.PropertyResourceBundle resources 
    • Constructor Summary

      Constructors 
      Constructor and Description
      Resources() 
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.lang.String formatSingleValue(java.lang.String key, java.lang.Object value)
      Format single value in a message of the form xxxx {0} yyyyy
      static boolean getBoolean(java.lang.String key)
      Returns the value of a boolean using false if one not found
      static boolean getBoolean(java.lang.String key, boolean def)
      Returns the value of a boolean using a default if no value found
      static java.awt.Color getColor(java.lang.String key)
      Gets a color from a key
      static java.awt.Color getColor(java.lang.String key, java.awt.Color def)
      Gets a color from a key
      static java.awt.Cursor getCursor(java.lang.String key)
      Gets a cursor from a key.
      static java.awt.Cursor getCursor(java.lang.String key, java.awt.Cursor def)
      Gets a cursor from a key
      static java.awt.Dimension getDimension(java.lang.String key)
      Returns the value of a dimension field
      static java.awt.Dimension getDimension(java.lang.String key, java.awt.Dimension def)
      Returns the value of a dimension field using a default if no value found
      static javax.swing.Icon getDisabledIcon(java.lang.String key)
      This method returns the disabled version of an icon using an identifier.
      static java.awt.Font getFont(java.lang.String key)
      Gets a font from a key
      static java.awt.Font getFont(java.lang.String key, int size)
      Gets a font from a key
      static java.awt.Font getFont(java.lang.String key, int size, java.awt.Font def)
      Gets a font from a key
      static javax.swing.Icon getIcon(java.lang.String key)
      This method returns an icon using an identifier.
      static java.io.InputStream getInputStream(java.lang.String key)
      Gets the input stream corresponding to a key.
      static int getInt(java.lang.String key)
      Returns the value of an int.
      static int getInt(java.lang.String key, int def)
      Returns the value of an int using a default if no value found
      static javax.swing.KeyStroke getKeyStroke(java.lang.String key)
      Gets a keystroke from a key
      static java.lang.String getLabelString(java.lang.String key)
      Returns the value of a string.
      static java.lang.String getString(java.lang.String key)
      Returns the value of a string.
      static java.lang.String getString(java.lang.String key, java.lang.String def)
      Returns the value of a string using a default if no value found
      static void initialize()
      Initialize with the standard properties file
      static void initialize(java.lang.String name)
      Initialize with a properties file
      static void setResources(java.util.PropertyResourceBundle resources)
      Sets the resource bundle
      • Methods inherited from class java.lang.Object

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

      • BUTTON_LABEL_OK

        public static final java.lang.String BUTTON_LABEL_OK
        The OK button label
        See Also:
        Constant Field Values
      • BUTTON_LABEL_CANCEL

        public static final java.lang.String BUTTON_LABEL_CANCEL
        The Cancel button label
        See Also:
        Constant Field Values
      • initialized

        protected static boolean initialized
        The initialized flag
      • iconHandler

        protected static IconHandler iconHandler
        The icon handler
      • booleans

        protected static java.util.Hashtable booleans
        Boolean keywords
      • fontStyles

        protected static java.util.Hashtable fontStyles
      • AWTColors

        protected static java.util.Hashtable AWTColors
        AWT Color names
      • resources

        protected static java.util.PropertyResourceBundle resources
    • Constructor Detail

      • Resources

        public Resources()
    • Method Detail

      • getLabelString

        public static java.lang.String getLabelString(java.lang.String key)
        Returns the value of a string. If the string is not found the key is returned. This useful for dialogs because it still allows a display but shows the key to define
        Parameters:
        key - The key to look up
        Returns:
        The String value corresponding to the key or the key itself if not found
      • getString

        public static java.lang.String getString(java.lang.String key)
        Returns the value of a string.
        Parameters:
        key - The key to look up
        Returns:
        The String value corresponding to the key or null if not found
      • getString

        public static java.lang.String getString(java.lang.String key,
                                                 java.lang.String def)
        Returns the value of a string using a default if no value found
        Parameters:
        key - The key to look up
        def - The default value
        Returns:
        The String value corresponding to the key
      • getInt

        public static int getInt(java.lang.String key)
        Returns the value of an int. Zero is returned if no value found
        Parameters:
        key - The key to look up
        Returns:
        The int value corresponding to the key
      • getInt

        public static int getInt(java.lang.String key,
                                 int def)
        Returns the value of an int using a default if no value found
        Parameters:
        key - The key to look up
        def - The default value
        Returns:
        The int value corresponding to the key
      • getBoolean

        public static boolean getBoolean(java.lang.String key)
        Returns the value of a boolean using false if one not found
        Parameters:
        key - The key to look up
        Returns:
        The boolean value corresponding to the key
      • getBoolean

        public static boolean getBoolean(java.lang.String key,
                                         boolean def)
        Returns the value of a boolean using a default if no value found
        Parameters:
        key - The key to look up
        def - The default value
        Returns:
        The boolean value corresponding to the key
      • getDimension

        public static java.awt.Dimension getDimension(java.lang.String key)
        Returns the value of a dimension field
        Parameters:
        key - The key to look up
        Returns:
        The dimension corresponding to the key or null if not found
      • getDimension

        public static java.awt.Dimension getDimension(java.lang.String key,
                                                      java.awt.Dimension def)
        Returns the value of a dimension field using a default if no value found
        Parameters:
        key - The key to look up
        def - The default value
        Returns:
        The dimension corresponding to the key
      • getColor

        public static java.awt.Color getColor(java.lang.String key)
        Gets a color from a key
        Parameters:
        key - The key to color
        Returns:
        the color or null if not found
      • getColor

        public static java.awt.Color getColor(java.lang.String key,
                                              java.awt.Color def)
        Gets a color from a key
        Parameters:
        key - The key to color
        def - The default value
        Returns:
        the color
      • getFont

        public static java.awt.Font getFont(java.lang.String key)
                                     throws java.lang.Exception
        Gets a font from a key
        Parameters:
        key - The key to the font
        Returns:
        the font
        Throws:
        java.lang.Exception
      • getFont

        public static java.awt.Font getFont(java.lang.String key,
                                            int size)
                                     throws java.lang.Exception
        Gets a font from a key
        Parameters:
        key - The key to the font
        size - The size (-1) means use the defined size
        Returns:
        the font
        Throws:
        java.lang.Exception
      • getFont

        public static java.awt.Font getFont(java.lang.String key,
                                            int size,
                                            java.awt.Font def)
                                     throws java.lang.Exception
        Gets a font from a key
        Parameters:
        key - The key to the font
        size - The size (-1) means use the defined size
        def - The default to use
        Returns:
        the font
        Throws:
        java.lang.Exception
      • getIcon

        public static javax.swing.Icon getIcon(java.lang.String key)
        This method returns an icon using an identifier.
        Parameters:
        id - The icon identifier
        Returns:
        The icon
      • getDisabledIcon

        public static javax.swing.Icon getDisabledIcon(java.lang.String key)
        This method returns the disabled version of an icon using an identifier.
        Parameters:
        id - The icon identifier
        Returns:
        The icon
      • getCursor

        public static java.awt.Cursor getCursor(java.lang.String key)
        Gets a cursor from a key. The hotspot is at (0,0)
        Parameters:
        key - The key to the gif image for the cursor
        Returns:
        the cursor
      • getCursor

        public static java.awt.Cursor getCursor(java.lang.String key,
                                                java.awt.Cursor def)
        Gets a cursor from a key
        Parameters:
        key - The key to the gif image for the cursor
        def - The default value
        Returns:
        the cursor
      • getKeyStroke

        public static javax.swing.KeyStroke getKeyStroke(java.lang.String key)
        Gets a keystroke from a key
        Parameters:
        key - The key to retrieve
        Returns:
        the keystroke or null if not found
      • getInputStream

        public static java.io.InputStream getInputStream(java.lang.String key)
        Gets the input stream corresponding to a key. The key identified a resource within the application
        Parameters:
        key - The key to the resources
        Returns:
        The input stream or null if not found
      • setResources

        public static void setResources(java.util.PropertyResourceBundle resources)
        Sets the resource bundle
        Parameters:
        resources - The resource bundle
      • formatSingleValue

        public static java.lang.String formatSingleValue(java.lang.String key,
                                                         java.lang.Object value)
        Format single value in a message of the form xxxx {0} yyyyy
        Parameters:
        key - Key to the format string
        value - The value format
        Returns:
        Theformatted string
      • initialize

        public static void initialize()
        Initialize with the standard properties file
        Parameters:
        name - The property file
      • initialize

        public static void initialize(java.lang.String name)
        Initialize with a properties file
        Parameters:
        name - The property file