org.fife.ui.app
Class GUIApplicationPreferences

java.lang.Object
  extended by org.fife.ui.app.GUIApplicationPreferences
All Implemented Interfaces:
GUIApplicationConstants, DockableWindowConstants
Direct Known Subclasses:
RTextPreferences

public abstract class GUIApplicationPreferences
extends java.lang.Object
implements GUIApplicationConstants

Preferences for a GUIApplication. This class currently explicitly remembers the accelerators for all actions of the GUI application in a hash map. The keys in the map are the action keys in the application.

Version:
0.1
Author:
Robert Futrell
See Also:
GUIApplication, AbstractGUIApplication

Field Summary
 java.util.HashMap<java.lang.String,javax.swing.KeyStroke> accelerators
          Accelerators for all actions in the GUIApplication's action map.
 java.lang.String language
          The language for this application, in a Locale-friendly string.
 java.awt.Point location
          The location on-screen of this GUI application.
 java.lang.String lookAndFeel
          The user's preferred look and feel for the application.
 java.awt.Dimension size
          The size of this GUI application's main window.
 boolean statusBarVisible
          Whether this application's status bar is visible.
 boolean toolbarVisible
          Whether this application's toolbar is visible.
 
Fields inherited from interface org.fife.ui.app.GUIApplicationConstants
OS_LINUX, OS_MAC_OSX, OS_OTHER, OS_WINDOWS
 
Fields inherited from interface org.fife.ui.dockablewindows.DockableWindowConstants
BOTTOM, FLOATING, LEFT, RIGHT, TOP
 
Constructor Summary
GUIApplicationPreferences()
           
 
Method Summary
static GUIApplicationPreferences generatePreferences(java.lang.Object obj)
          Creates a properties object with all fields initialized to the values that the specified application instance is currently running with.
 javax.swing.KeyStroke getAccelerator(java.lang.String actionName)
          Returns the accelerator for the specified action name.
protected static void loadCommonPreferences(GUIApplicationPreferences prefs, java.util.prefs.Preferences p)
          Loads the preferences specified in this class into the specified GUIApplicationPreferences object.
static GUIApplicationPreferences loadPreferences()
          Initializes this preferences instance with data saved previously via the Java Preferences API.
protected  void saveCommonPreferences(java.util.prefs.Preferences prefs)
          Saves the common preferences specified in this class.
abstract  void savePreferences(java.lang.Object object)
          Saves this preferences instance via the Java Preferences API.
protected abstract  void setDefaults()
          Sets this preferences instance to contain all default values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

accelerators

public java.util.HashMap<java.lang.String,javax.swing.KeyStroke> accelerators
Accelerators for all actions in the GUIApplication's action map.

See Also:
getAccelerator(String)

location

public java.awt.Point location
The location on-screen of this GUI application.


size

public java.awt.Dimension size
The size of this GUI application's main window.


toolbarVisible

public boolean toolbarVisible
Whether this application's toolbar is visible.


statusBarVisible

public boolean statusBarVisible
Whether this application's status bar is visible.


lookAndFeel

public java.lang.String lookAndFeel
The user's preferred look and feel for the application.


language

public java.lang.String language
The language for this application, in a Locale-friendly string.

Constructor Detail

GUIApplicationPreferences

public GUIApplicationPreferences()
Method Detail

generatePreferences

public static GUIApplicationPreferences generatePreferences(java.lang.Object obj)
Creates a properties object with all fields initialized to the values that the specified application instance is currently running with.

The default implementation returns null. This method should be overridden to return properties for the specified object.

Parameters:
obj - The object for which to generate preferences.
Returns:
A GUIApplicaitonPrefences object initialized to contain the properties the specified object is running with.

getAccelerator

public javax.swing.KeyStroke getAccelerator(java.lang.String actionName)
Returns the accelerator for the specified action name. This is shorthand for (KeyStroke)accelerators.get(NAME);

Returns:
The accelerator.

loadCommonPreferences

protected static void loadCommonPreferences(GUIApplicationPreferences prefs,
                                            java.util.prefs.Preferences p)
Loads the preferences specified in this class into the specified GUIApplicationPreferences object. This method can be called by any subclass's loadPreferences so they don't have to worry about doing it all themselves.

Parameters:
prefs - The preferences into which to load. If any of the preferences aren't found in the backing store, the value of those preferences saved in this instance are not are not changed (i.e., the defaults are the current values).
p - The preferences backing store from which to retrieve preferences.

loadPreferences

public static GUIApplicationPreferences loadPreferences()
Initializes this preferences instance with data saved previously via the Java Preferences API. If the load fails, the result is implementation-specific; usually this preferences instance will be populated with default values.

The default implementation returns null. This method should be overridden to return properties for the specified object.

Returns:
If the load went okay, the preferences for the given application are returned. If something went wrong, or the user has never used this application before (and thus there are no saved preferences), default values are returned.

saveCommonPreferences

protected void saveCommonPreferences(java.util.prefs.Preferences prefs)
Saves the common preferences specified in this class. This method can be called by any subclass's savePreferences so they don't have to worry about doing it all themselves.

Parameters:
prefs - The preferences backing store into which to save preferences.

savePreferences

public abstract void savePreferences(java.lang.Object object)
Saves this preferences instance via the Java Preferences API.

Parameters:
object - Can be anything needed by an implementation of GUIApplicationPreferences. For example, it can be the application instance for which you are saving preferences. This parameter may not be needed by your implementation.

setDefaults

protected abstract void setDefaults()
Sets this preferences instance to contain all default values.