com.alee.managers.settings
Class SettingsProcessor<C extends java.awt.Component,V extends java.io.Serializable>

java.lang.Object
  extended by com.alee.managers.settings.SettingsProcessor<C,V>
Direct Known Subclasses:
AbstractButtonSettingsProcessor, JComboBoxSettingsProcessor, JPasswordFieldSettingsProcessor, JScrollBarSettingsProcessor, JSliderSettingsProcessor, JTabbedPaneSettingsProcessor, JTextComponentSettingsProcessor, WebAccordionSettingsProcessor, WebCollapsiblePaneSettingsProcessor, WebDateFieldSettingsProcessor, WebGradientColorChooserSettingsProcessor, WindowSettingsProcessor

public abstract class SettingsProcessor<C extends java.awt.Component,V extends java.io.Serializable>
extends java.lang.Object

This abstract class represents core component settings tracking functionality. Extend and register it in SettingsManager or ComponentSettingsManager to provide additional components support.

SettingsProcessor is also defended from recursive settings load/save which might occur if component sends additional data change events when new data is loaded into it (doesn't matter from SettingsProcessor or some other source).

To register new SettingsProcessor use registerSettingsProcessor(Class, Class) method from SettingsManager or ComponentSettingsManager class (they both do the same).

Author:
Mikle Garin
See Also:
How to use SettingsManager, SettingsManager, SettingsManager.registerSettingsProcessor(Class, Class), ComponentSettingsManager, ComponentSettingsManager.registerSettingsProcessor(Class, Class)

Field Summary
protected  SettingsProcessorData data
          Settings processor data.
protected  boolean loading
          Whether this settings processor is currently loading settings or not.
protected  boolean saving
          Whether this settings processor is currently saving settings or not.
 
Constructor Summary
SettingsProcessor(java.awt.Component component, java.lang.String group, java.lang.String key, java.lang.Object defaultValue, boolean loadInitialSettings, boolean applySettingsChanges)
          Constructs SettingsProcessor using the specified data.
SettingsProcessor(SettingsProcessorData data)
          Constructs SettingsProcessor using the specified SettingsProcessorData.
 
Method Summary
 void destroy()
          Destroys this SettingsProcessor.
protected abstract  void doDestroy(C component)
          Called when component is unregistered from ComponentSettingsManager.
protected abstract  void doInit(C component)
          Called when a new component is registered in ComponentSettingsManager.
protected abstract  void doLoad(C component)
          Called on component settings load.
protected abstract  void doSave(C component)
          Called on component settings save.
 C getComponent()
          Returns managed component.
 SettingsProcessorData getData()
          Returns SettingsProcessorData.
 V getDefaultValue()
          Returns component default value.
 java.lang.String getGroup()
          Returns component settings group.
 java.lang.String getKey()
          Returns component settings key.
 void load()
          Loads saved settings into the component.
protected  V loadValue()
          Loads and returns saved component settings.
 void save()
          Saves settings taken from the component.
 void save(boolean onChange)
          Saves settings taken from the component.
protected  void saveValue(V value)
          Saves component settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loading

protected boolean loading
Whether this settings processor is currently loading settings or not.


saving

protected boolean saving
Whether this settings processor is currently saving settings or not.


data

protected SettingsProcessorData data
Settings processor data.

Constructor Detail

SettingsProcessor

public SettingsProcessor(java.awt.Component component,
                         java.lang.String group,
                         java.lang.String key,
                         java.lang.Object defaultValue,
                         boolean loadInitialSettings,
                         boolean applySettingsChanges)
Constructs SettingsProcessor using the specified data.

Parameters:
component - component which settings are being managed
group - component settings group
key - component settings key
defaultValue - component default value
loadInitialSettings - whether to load initial available settings into the component or not
applySettingsChanges - whether to apply settings changes to the component or not

SettingsProcessor

public SettingsProcessor(SettingsProcessorData data)
Constructs SettingsProcessor using the specified SettingsProcessorData.

Parameters:
data - SettingsProcessorData
Method Detail

getData

public SettingsProcessorData getData()
Returns SettingsProcessorData.

Returns:
SettingsProcessorData

getComponent

public C getComponent()
Returns managed component.

Returns:
managed component

getGroup

public java.lang.String getGroup()
Returns component settings group.

Returns:
component settings group

getKey

public java.lang.String getKey()
Returns component settings key.

Returns:
component settings key

getDefaultValue

public V getDefaultValue()
Returns component default value.

Returns:
component default value

load

public final void load()
Loads saved settings into the component.


save

public final void save()
Saves settings taken from the component. This method might be called from the component listeners to provide auto-save functionality.


save

public final void save(boolean onChange)
Saves settings taken from the component. This method might be called from the component listeners to provide auto-save functionality.

Parameters:
onChange - whether this save is called from component change listeners

destroy

public final void destroy()
Destroys this SettingsProcessor.


loadValue

protected V loadValue()
Loads and returns saved component settings.

Returns:
loaded settings

saveValue

protected void saveValue(V value)
Saves component settings.

Parameters:
value - new component settings

doInit

protected abstract void doInit(C component)
Called when a new component is registered in ComponentSettingsManager.

Parameters:
component - registered component

doDestroy

protected abstract void doDestroy(C component)
Called when component is unregistered from ComponentSettingsManager.

Parameters:
component - unregistered component

doLoad

protected abstract void doLoad(C component)
Called on component settings load. It doesn't matter if it is invoked by SettingsProcessor or some other source.

Parameters:
component - component to load settings into

doSave

protected abstract void doSave(C component)
Called on component settings save. It doesn't matter if it is invoked by SettingsProcessor or some other source.

Parameters:
component - component to save settings from