de.sciss.gui
Class PrefMenuAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by de.sciss.gui.MenuAction
          extended by de.sciss.gui.PrefMenuAction
All Implemented Interfaces:
LaterInvocationManager.Listener, PreferenceEntrySync, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, java.util.prefs.PreferenceChangeListener, javax.swing.Action
Direct Known Subclasses:
BooleanPrefsMenuAction, IntPrefsMenuAction

public abstract class PrefMenuAction
extends MenuAction
implements PreferenceEntrySync, java.util.prefs.PreferenceChangeListener, LaterInvocationManager.Listener

Adds PreferenceEntrySync functionality to the superclass. note that unlike PrefCheckBox and the like, it's only valid to listen to the prefs changes, not the action events.

Version:
0.70, 17-Apr-07
Author:
Hanns Holger Rutz
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
PrefMenuAction(java.lang.String text, javax.swing.KeyStroke shortcut)
           
PrefMenuAction(java.lang.String text, javax.swing.KeyStroke shortcut, boolean readPrefs, boolean writePrefs)
           
 
Method Summary
protected  boolean canWritePrefs()
           
 java.lang.String getPreferenceKey()
          Gets the recently set preference key
 java.util.prefs.Preferences getPreferenceNode()
          Gets the recently set preference node
 boolean getReadPrefs()
           
 boolean getWritePrefs()
           
 void laterInvocation(java.lang.Object o)
          Called later in the event thread, this passes the object given to the queue method
 void preferenceChange(java.util.prefs.PreferenceChangeEvent e)
           
 void readPrefs()
           
protected abstract  void readPrefsFromString(java.lang.String prefsValue)
           
 void setPreferenceKey(java.lang.String key)
           
 void setPreferenceNode(java.util.prefs.Preferences prefs)
           
 void setPreferences(java.util.prefs.Preferences prefs, java.lang.String key)
          Enables Preferences synchronization.
 void setReadPrefs(boolean b)
           
 void setWritePrefs(boolean b)
           
protected  boolean shouldWritePrefs()
           
 
Methods inherited from class de.sciss.gui.MenuAction
actionPerformed, deinstallFrom, installOn, mimic
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.sciss.app.PreferenceEntrySync
writePrefs
 

Constructor Detail

PrefMenuAction

public PrefMenuAction(java.lang.String text,
                      javax.swing.KeyStroke shortcut)

PrefMenuAction

public PrefMenuAction(java.lang.String text,
                      javax.swing.KeyStroke shortcut,
                      boolean readPrefs,
                      boolean writePrefs)
Method Detail

setReadPrefs

public void setReadPrefs(boolean b)
Specified by:
setReadPrefs in interface PreferenceEntrySync

getReadPrefs

public boolean getReadPrefs()
Specified by:
getReadPrefs in interface PreferenceEntrySync

setWritePrefs

public void setWritePrefs(boolean b)
Specified by:
setWritePrefs in interface PreferenceEntrySync

getWritePrefs

public boolean getWritePrefs()
Specified by:
getWritePrefs in interface PreferenceEntrySync

canWritePrefs

protected boolean canWritePrefs()

shouldWritePrefs

protected boolean shouldWritePrefs()

setPreferenceKey

public void setPreferenceKey(java.lang.String key)
Specified by:
setPreferenceKey in interface PreferenceEntrySync

setPreferenceNode

public void setPreferenceNode(java.util.prefs.Preferences prefs)
Specified by:
setPreferenceNode in interface PreferenceEntrySync

setPreferences

public void setPreferences(java.util.prefs.Preferences prefs,
                           java.lang.String key)
Description copied from interface: PreferenceEntrySync
Enables Preferences synchronization. This method is not thread safe and must be called from the event thread. When a preference change is received, the GUI is updated and dispatches an event to registered listeners. Likewise, if the user adjusts the GUI value, the preference will be updated. The same is true, if you call one of the value changing methods.

Specified by:
setPreferences in interface PreferenceEntrySync
Parameters:
prefs - the preferences node in which the value is stored, or null to disable prefs sync.
key - the key used to store and recall prefs. the value is converted into a string.

getPreferenceNode

public java.util.prefs.Preferences getPreferenceNode()
Description copied from interface: PreferenceEntrySync
Gets the recently set preference node

Specified by:
getPreferenceNode in interface PreferenceEntrySync
Returns:
the node set with setPreferences or null if no prefs were set

getPreferenceKey

public java.lang.String getPreferenceKey()
Description copied from interface: PreferenceEntrySync
Gets the recently set preference key

Specified by:
getPreferenceKey in interface PreferenceEntrySync
Returns:
the key set with setPreferences or null if no prefs were set

preferenceChange

public void preferenceChange(java.util.prefs.PreferenceChangeEvent e)
Specified by:
preferenceChange in interface java.util.prefs.PreferenceChangeListener

readPrefs

public void readPrefs()
Specified by:
readPrefs in interface PreferenceEntrySync

laterInvocation

public final void laterInvocation(java.lang.Object o)
Description copied from interface: LaterInvocationManager.Listener
Called later in the event thread, this passes the object given to the queue method

Specified by:
laterInvocation in interface LaterInvocationManager.Listener
Parameters:
o - object as passed to queue

readPrefsFromString

protected abstract void readPrefsFromString(java.lang.String prefsValue)