bibliothek.extension.gui.dock.preference
Class AbstractPreference<V>

java.lang.Object
  extended by bibliothek.extension.gui.dock.preference.AbstractPreference<V>
Type Parameters:
V - the kind of value this preference uses
All Implemented Interfaces:
Preference<V>
Direct Known Subclasses:
DefaultPreference

public abstract class AbstractPreference<V>
extends Object
implements Preference<V>

An abstract implementation of Preference that offers support for PreferenceListeners.

Author:
Benjamin Sigg

Constructor Summary
AbstractPreference()
           
 
Method Summary
 void addPreferenceListener(PreferenceListener<V> listener)
          Adds a listener to this preference.
 void doOperation(PreferenceOperation operation)
          Executes the enabled operation operation.
protected  void fireChanged()
          Informs all listeners that the value of this preference has changed.
 PreferenceOperation[] getOperations()
          Gets a list of operations which can be executed by this preference.
 boolean isEnabled(PreferenceOperation operation)
          Tells whether operation is enabled and thus Preference.doOperation(PreferenceOperation) can be called.
protected  PreferenceListener<V>[] listeners()
          Gets all the listeners of this preference.
 void removePreferenceListener(PreferenceListener<V> listener)
          Removes a listener from this preference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.extension.gui.dock.preference.Preference
getDescription, getLabel, getPath, getTypePath, getValue, getValueInfo, isNatural, read, setValue, write
 

Constructor Detail

AbstractPreference

public AbstractPreference()
Method Detail

addPreferenceListener

public void addPreferenceListener(PreferenceListener<V> listener)
Description copied from interface: Preference
Adds a listener to this preference.

Specified by:
addPreferenceListener in interface Preference<V>
Parameters:
listener - the new listener

removePreferenceListener

public void removePreferenceListener(PreferenceListener<V> listener)
Description copied from interface: Preference
Removes a listener from this preference.

Specified by:
removePreferenceListener in interface Preference<V>
Parameters:
listener - the listener to remove

listeners

protected PreferenceListener<V>[] listeners()
Gets all the listeners of this preference.

Returns:
the list of listeners

fireChanged

protected void fireChanged()
Informs all listeners that the value of this preference has changed.


isEnabled

public boolean isEnabled(PreferenceOperation operation)
Description copied from interface: Preference
Tells whether operation is enabled and thus Preference.doOperation(PreferenceOperation) can be called.

Specified by:
isEnabled in interface Preference<V>
Parameters:
operation - some operation of Preference.getOperations()
Returns:
true if the operation can be executed

getOperations

public PreferenceOperation[] getOperations()
Description copied from interface: Preference
Gets a list of operations which can be executed by this preference.

Specified by:
getOperations in interface Preference<V>
Returns:
the list of operations (enabled and disabled operations)

doOperation

public void doOperation(PreferenceOperation operation)
Description copied from interface: Preference
Executes the enabled operation operation. This method should not be called if operation is disabled.

Specified by:
doOperation in interface Preference<V>
Parameters:
operation - the key of the operation