com.levigo.jadice.demo
Class JadiceDemoPreferences

java.lang.Object
  extended by com.levigo.jadice.demo.JadiceDemoPreferences

public class JadiceDemoPreferences
extends Object

This class provides some utility methods for the demo preferences. E.g. a method to load and store the list of recent files.

Weak listeners can be registered in cases where de-registration of listeners is not easily possible (see addWeakPreferenceChangeListener(PreferenceChangeListener)).

Auto-Flush mode: This class can automatically flush the preferences on a PreferenceChangeEvent ( see isAutoFlush() / setAutoFlush(boolean) ). By default, this feature is disabled.


Field Summary
static String PREF_KEY_RECENT_FILE
           
 
Method Summary
static void addWeakPreferenceChangeListener(PreferenceChangeListener listener)
          Adds a weak PreferenceChangeListener to get notified about preference changes.
static Preferences getPreferences()
          This is equivalent to
static List<String> getRecentlyUsedFiles()
          Returns a list containing the recently used files.
static boolean isAutoFlush()
          Check if auto-flush is enabled
static void setAutoFlush(boolean autoFlush)
          Sets the auto-flush to the desired value.
static void updateRecentFileList(String currentFile)
          Called when a new file has been opened.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_KEY_RECENT_FILE

public static final String PREF_KEY_RECENT_FILE
See Also:
Constant Field Values
Method Detail

addWeakPreferenceChangeListener

public static void addWeakPreferenceChangeListener(PreferenceChangeListener listener)
Adds a weak PreferenceChangeListener to get notified about preference changes.

Parameters:
listener - - the listener to weakly register

getPreferences

public static Preferences getPreferences()
This is equivalent to
 Preferences.userNodeForPackage(JadiceDemoProperties.class)
 

Returns:
- the Preferences object

isAutoFlush

public static boolean isAutoFlush()
Check if auto-flush is enabled

Returns:
true: auto-flush is enabled; false otherwise

setAutoFlush

public static void setAutoFlush(boolean autoFlush)
Sets the auto-flush to the desired value.

Parameters:
autoFlush -

updateRecentFileList

public static void updateRecentFileList(String currentFile)
Called when a new file has been opened. It will be saved in the list of recently used files.

This method encapsulates the logic to store the list in the preferences.

Parameters:
currentFile - - the file opened.

getRecentlyUsedFiles

public static List<String> getRecentlyUsedFiles()
Returns a list containing the recently used files. The list might contain up to elements.

Returns:
the list of recently used files (newest element at index 0)


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.