Package de.sciss.gui
Class PrefMenuAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- de.sciss.gui.MenuAction
-
- 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.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description PrefMenuAction(java.lang.String text, javax.swing.KeyStroke shortcut)PrefMenuAction(java.lang.String text, javax.swing.KeyStroke shortcut, boolean readPrefs, boolean writePrefs)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleancanWritePrefs()java.lang.StringgetPreferenceKey()Gets the recently set preference keyjava.util.prefs.PreferencesgetPreferenceNode()Gets the recently set preference nodebooleangetReadPrefs()booleangetWritePrefs()voidlaterInvocation(java.lang.Object o)Called later in the event thread, this passes the object given to the queue methodvoidpreferenceChange(java.util.prefs.PreferenceChangeEvent e)voidreadPrefs()protected abstract voidreadPrefsFromString(java.lang.String prefsValue)voidsetPreferenceKey(java.lang.String key)voidsetPreferenceNode(java.util.prefs.Preferences prefs)voidsetPreferences(java.util.prefs.Preferences prefs, java.lang.String key)Enables Preferences synchronization.voidsetReadPrefs(boolean b)voidsetWritePrefs(boolean b)protected booleanshouldWritePrefs()-
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
-
-
-
-
Method Detail
-
setReadPrefs
public void setReadPrefs(boolean b)
- Specified by:
setReadPrefsin interfacePreferenceEntrySync
-
getReadPrefs
public boolean getReadPrefs()
- Specified by:
getReadPrefsin interfacePreferenceEntrySync
-
setWritePrefs
public void setWritePrefs(boolean b)
- Specified by:
setWritePrefsin interfacePreferenceEntrySync
-
getWritePrefs
public boolean getWritePrefs()
- Specified by:
getWritePrefsin interfacePreferenceEntrySync
-
canWritePrefs
protected boolean canWritePrefs()
-
shouldWritePrefs
protected boolean shouldWritePrefs()
-
setPreferenceKey
public void setPreferenceKey(java.lang.String key)
- Specified by:
setPreferenceKeyin interfacePreferenceEntrySync
-
setPreferenceNode
public void setPreferenceNode(java.util.prefs.Preferences prefs)
- Specified by:
setPreferenceNodein interfacePreferenceEntrySync
-
setPreferences
public void setPreferences(java.util.prefs.Preferences prefs, java.lang.String key)Description copied from interface:PreferenceEntrySyncEnables 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:
setPreferencesin interfacePreferenceEntrySync- 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:PreferenceEntrySyncGets the recently set preference node- Specified by:
getPreferenceNodein interfacePreferenceEntrySync- Returns:
- the node set with setPreferences or null if no prefs were set
-
getPreferenceKey
public java.lang.String getPreferenceKey()
Description copied from interface:PreferenceEntrySyncGets the recently set preference key- Specified by:
getPreferenceKeyin interfacePreferenceEntrySync- Returns:
- the key set with setPreferences or null if no prefs were set
-
preferenceChange
public void preferenceChange(java.util.prefs.PreferenceChangeEvent e)
- Specified by:
preferenceChangein interfacejava.util.prefs.PreferenceChangeListener
-
readPrefs
public void readPrefs()
- Specified by:
readPrefsin interfacePreferenceEntrySync
-
laterInvocation
public final void laterInvocation(java.lang.Object o)
Description copied from interface:LaterInvocationManager.ListenerCalled later in the event thread, this passes the object given to the queue method- Specified by:
laterInvocationin interfaceLaterInvocationManager.Listener- Parameters:
o- object as passed toqueue
-
readPrefsFromString
protected abstract void readPrefsFromString(java.lang.String prefsValue)
-
-