Class PreferenceManager

java.lang.Object
org.graffiti.managers.PreferenceManager
All Implemented Interfaces:
PluginManagerListener

public class PreferenceManager
extends Object
implements PluginManagerListener
  • Method Details

    • getInstance

      public static PreferenceManager getInstance()
    • getPreferencingClasses

      public Set<Class<? extends PreferencesInterface>> getPreferencingClasses()
    • addPreferencingClass

      public void addPreferencingClass​(Class<? extends PreferencesInterface> preferencingClass)
      Another way of adding custom classes that implement the PreferencesInterface which will be added to the list of preferencing classes. Use this method if your class is not part of a plugin which provides new Views, Tabs, Algorithms, etc
      Parameters:
      preferencingClass -
    • pluginAdded

      public void pluginAdded​(GenericPlugin plugin, PluginDescription desc)
      called each time a plugin gets loaded Checks the Plugins entries (Views, Algorithms, Tabs, ViewComponents, Tools) if they implement the PreferenceInterface If so, the preferences of this class will be a) read (and stored), if this is a new class (first time) b) set, if there are present preferences stored Also this algorithm will synchronize the preferences, in case preferences have been created or deleted.
      Specified by:
      pluginAdded in interface PluginManagerListener
      Parameters:
      plugin -
      desc -
    • checkExistingPreferences

      public Preferences checkExistingPreferences​(Class<?> clazz, List<? extends Parameter> defaultPreferences)
      if no preferences found, create a new preferences object from default parameters. if parameters in already present preferences that are not anymore part of the given preferences, the parameters in the preferences gets deleted
    • checkAddAndSetClassesPreferences

      public void checkAddAndSetClassesPreferences​(PreferencesInterface prefInterface)
      This method will do several things, that are repeatedly done to get possibly existing Preferences and add the class to the list of Preferencing Classes and also call the implementing object for first-time setup during startup of the program
      Parameters:
      prefInterface -
    • getPreferenceForClass

      public static Preferences getPreferenceForClass​(Class<?> clazz)
      This method should be used when getting Preferences for a specific class/object. It'll supply a method that supports easy creation of Preference Objects regarding a Class. Normally Preferences can be created for Class objects but then the Preference relates to the package.
    • getPreferenceCategoryForClass

      public static Preferences getPreferenceCategoryForClass​(Class<?> clazz, String category)
      This method should be used when getting Preferences for a specific category (folder) for a class/object. This can be used to structure paramters in categories (folders)
    • updatePreferencesForClass

      public static void updatePreferencesForClass​(Class<? extends PreferencesInterface> clazz, Preferences preferences)
      This method will instantiate an Object from the given class and call the updatePreferences method, which must be implemented by any PreferencesInterface implementing class. The PreferencesInterface-object should then store the given preferences in static variables, since those parameters are with regard to the class The static variables will give fast access VS querying the Preferences each time.
      Parameters:
      clazz -
      preferences -
    • storePreferences

      public static void storePreferences()
      Stores the preferences in 'settings.xml' in the Vanted program directory.

      Improved to allow faster operations, also now closing the stream automatically, not waiting until GC.