Class UISettings


  • public class UISettings
    extends Object
    Class for keeping track of parameters for panels, like divider locations. Uses the class (or class of the object) and the property to generate a key.
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • SECONDS_WAIT

        public static final int SECONDS_WAIT
        the seconds to wait before saving the settings.
        See Also:
        Constant Field Values
      • m_Properties

        protected static Properties m_Properties
        the properties.
      • m_SaveThread

        protected static Thread m_SaveThread
        the threading for saving.
      • m_Modified

        protected static boolean m_Modified
        whether settings are not yet saved.
    • Constructor Detail

      • UISettings

        public UISettings()
    • Method Detail

      • initializeProperties

        protected static void initializeProperties()
        Initializes the properties if necessary.
      • getProperties

        protected static Properties getProperties()
        Returns the properties in use.
        Returns:
        the properties
      • createKey

        protected static String createKey​(Class cls,
                                          String property)
        Assembles the key.
        Parameters:
        cls - the class
        property - the property
        Returns:
        the key
      • set

        public static void set​(Object obj,
                               String property,
                               Integer value)
        Sets the Integer value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Integer value)
        Sets the Integer value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Long value)
        Sets the Long value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Long value)
        Sets the Long value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Double value)
        Sets the Double value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Double value)
        Sets the Double value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Boolean value)
        Sets the Boolean value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Boolean value)
        Sets the Boolean value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Time value)
        Sets the Time value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Time value)
        Sets the Time value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               DateTime value)
        Sets the DateTime value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               DateTime value)
        Sets the DateTime value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Date value)
        Sets the Date value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Date value)
        Sets the Date value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Color value)
        Sets the Color value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Color value)
        Sets the Color value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               BasePassword value)
        Sets the BasePassword value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               BasePassword value)
        Sets the BasePassword value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Object obj,
                               String property,
                               Dimension value)
        Sets the Dimension value for the object.
        Parameters:
        obj - the object to set the value for
        property - the property to set
        value - the value to set
      • set

        public static void set​(Class cls,
                               String property,
                               Dimension value)
        Sets the Dimension value for the class.
        Parameters:
        cls - the class to set the value for
        property - the property to set
        value - the value to set
      • flagModified

        protected static void flagModified()
        Flags as modified and queues saving.
      • get

        public static boolean get​(Object obj,
                                  String property,
                                  boolean defValue)
        Returns the Boolean value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static boolean get​(Class cls,
                                  String property,
                                  boolean defValue)
        Returns the Boolean value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static int get​(Object obj,
                              String property,
                              int defValue)
        Returns the Integer value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static int get​(Class cls,
                              String property,
                              int defValue)
        Returns the Integer value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static long get​(Object obj,
                               String property,
                               long defValue)
        Returns the Long value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static long get​(Class cls,
                               String property,
                               long defValue)
        Returns the Long value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static double get​(Object obj,
                                 String property,
                                 double defValue)
        Returns the Double value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static double get​(Class cls,
                                 String property,
                                 double defValue)
        Returns the Double value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Time get​(Object obj,
                               String property,
                               Time defValue)
        Returns the Time value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Time get​(Class cls,
                               String property,
                               Time defValue)
        Returns the Time value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Date get​(Object obj,
                               String property,
                               Date defValue)
        Returns the Date value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Date get​(Class cls,
                               String property,
                               Date defValue)
        Returns the Date value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static DateTime get​(Object obj,
                                   String property,
                                   DateTime defValue)
        Returns the DateTime value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static DateTime get​(Class cls,
                                   String property,
                                   DateTime defValue)
        Returns the DateTime value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Color get​(Object obj,
                                String property,
                                Color defValue)
        Returns the Color value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Color get​(Class cls,
                                String property,
                                Color defValue)
        Returns the Color value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static BasePassword get​(Object obj,
                                       String property,
                                       BasePassword defValue)
        Returns the Password value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static BasePassword get​(Class cls,
                                       String property,
                                       BasePassword defValue)
        Returns the Password value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static String get​(Object obj,
                                 String property,
                                 String defValue)
        Returns the String value.
        Parameters:
        obj - the object
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static String get​(Class cls,
                                 String property,
                                 String defValue)
        Returns the String value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • get

        public static Dimension get​(Class cls,
                                    String property,
                                    Dimension defValue)
        Returns the Dimension value.
        Parameters:
        cls - the class
        property - the property
        defValue - the default value
        Returns:
        the stored value or the default value
      • has

        public static boolean has​(Object obj,
                                  String property)
        Returns the whether the value is present.
        Parameters:
        obj - the object
        property - the property
        Returns:
        true if available
      • has

        public static boolean has​(Class cls,
                                  String property)
        Returns the whether the value is present.
        Parameters:
        cls - the class
        property - the property
        Returns:
        true if available
      • isModified

        public static boolean isModified()
        Returns whether the settings are currently unsaved.
        Returns:
        true if not yet saved
      • queueSave

        public static void queueSave()
        Queues saving the settings after SECONDS_WAIT seconds.
      • save

        public static String save()
        Stores the settings.
        Returns:
        null if successful, otherwise error message