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

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

public abstract class DefaultPreference<V>
extends AbstractPreference<V>

A generic Preference that can hold any value. This preference does not implement the Preference.read() or Preference.write() method. If a default-value is set, then this preference activates the operation PreferenceOperation.DEFAULT, otherwise it shows no operations.
This preference is set to be an artificial preference, subclasses may call setNatural(boolean) to change the behavior.

Author:
Benjamin Sigg

Constructor Summary
DefaultPreference(Path type, Path path)
          Creates a new preference.
DefaultPreference(String label, Path type, Path path)
          Creates a new preference.
 
Method Summary
 void addPreferenceListener(PreferenceListener<V> listener)
          Adds a listener to this preference.
 void doOperation(PreferenceOperation operation)
          Executes the enabled operation operation.
 V getDefaultValue()
          Gets the default value of this preference
 String getDescription()
          Gets a long human readable description of this preference.
 String getLabel()
          Gets a short human readable string that is used as name for this preference.
 PreferenceOperation[] getOperations()
          Gets a list of operations which can be executed by this preference.
 Path getPath()
          Gets the unique path of this resource.
 Path getTypePath()
          Gets the type of the value that this preferences uses.
 V getValue()
          Gets the value of this preference.
 Object getValueInfo()
          Information about how the value of this preference can be modified.
 boolean isEnabled(PreferenceOperation operation)
          Tells whether operation is enabled and thus Preference.doOperation(PreferenceOperation) can be called.
 boolean isNatural()
          Tells whether this preference is natural or artificial.
 void removePreferenceListener(PreferenceListener<V> listener)
          Removes a listener from this preference.
 void setDefaultValue(V defaultValue)
          Sets the default value of this preference
 void setDescription(String description)
          Sets a description of this preference.
 void setDescriptionId(String descriptionId)
          Sets a unique identifier for the description text, the unique identifier will be used to read a text from the current TextManager.
 void setLabel(String label)
          Sets a short human readable label for this preference.
 void setLabelId(String labelId)
          Sets a unique identifier for the label text, the unique identifier will be used to read a text from the current TextManager.
 void setModel(PreferenceModel model)
          Sets the model which is using this preference.
 void setNatural(boolean natural)
          Sets whether this preference is natural or artificial.
 void setValue(V value)
          Sets the value of this preference.
 void setValueInfo(Object valueInfo)
          Sets information about this preferences value.
 
Methods inherited from class bibliothek.extension.gui.dock.preference.AbstractPreference
fireChanged, hasListeners, listeners
 
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
read, write
 

Constructor Detail

DefaultPreference

public DefaultPreference(Path type,
                         Path path)
Creates a new preference.

Parameters:
type - the type of value this preference uses
path - a unique path for this preference, all paths starting with "dock" are reserved for this framework

DefaultPreference

public DefaultPreference(String label,
                         Path type,
                         Path path)
Creates a new preference.

Parameters:
label - a short human readable label for this preference
type - the type of value this preference uses
path - a unique path for this preference, all paths starting with "dock" are reserved for this framework
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>
Overrides:
addPreferenceListener in class AbstractPreference<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>
Overrides:
removePreferenceListener in class AbstractPreference<V>
Parameters:
listener - the listener to remove

setModel

public void setModel(PreferenceModel model)
Description copied from interface: Preference
Sets the model which is using this preference.

Parameters:
model - the model, can be null

getLabel

public String getLabel()
Description copied from interface: Preference
Gets a short human readable string that is used as name for this preference.

Returns:
a short human readable string

setLabel

public void setLabel(String label)
Sets a short human readable label for this preference. Note that changes of the label are not propagated to any listener.

Parameters:
label - the new label

setLabelId

public void setLabelId(String labelId)
Sets a unique identifier for the label text, the unique identifier will be used to read a text from the current TextManager.

Parameters:
labelId - the unique identifier, can be null

getDescription

public String getDescription()
Description copied from interface: Preference
Gets a long human readable description of this preference.

Returns:
the description, may be null, may be formated in HTML

setDescription

public void setDescription(String description)
Sets a description of this preference.

Parameters:
description - a human readable string, can be null and can be formated in HTML

setDescriptionId

public void setDescriptionId(String descriptionId)
Sets a unique identifier for the description text, the unique identifier will be used to read a text from the current TextManager.

Parameters:
descriptionId - the unique identifier, can be null

getTypePath

public Path getTypePath()
Description copied from interface: Preference
Gets the type of the value that this preferences uses. The path normally is just the name of some class. There is a set of standard paths defined in Path

Returns:
the type of value

setValueInfo

public void setValueInfo(Object valueInfo)
Sets information about this preferences value. For example for an integer that could be the upper and the lower bounds. The exact meaning and type of this object depends on getTypePath().

Parameters:
valueInfo - the new information or null

getValueInfo

public Object getValueInfo()
Description copied from interface: Preference
Information about how the value of this preference can be modified. See PreferenceModel.getValueInfo(int).

Returns:
the information or null

getValue

public V getValue()
Description copied from interface: Preference
Gets the value of this preference.

Returns:
the value, might be null

setValue

public void setValue(V value)
Description copied from interface: Preference
Sets the value of this preference.

Parameters:
value - the value, might be null (depends on the editor used for this preference)

setDefaultValue

public void setDefaultValue(V defaultValue)
Sets the default value of this preference

Parameters:
defaultValue - the new default value

getDefaultValue

public V getDefaultValue()
Gets the default value of this preference

Returns:
the default value, might be null

getPath

public Path getPath()
Description copied from interface: Preference
Gets the unique path of this resource. The path has to be unique within the model which uses this preference. Paths whose first segment is "dock" are reserved for this framework. Clients may use any path not starting with "dock".

Returns:
the unique path

setNatural

public void setNatural(boolean natural)
Sets whether this preference is natural or artificial.

Parameters:
natural - true if natural, false if artificial
See Also:
isNatural(), PreferenceModel.isNatural(int)

isNatural

public boolean isNatural()
Description copied from interface: Preference
Tells whether this preference is natural or artificial.

Returns:
true if natural, false if artificial
See Also:
PreferenceModel.isNatural(int)

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>
Overrides:
getOperations in class AbstractPreference<V>
Returns:
the list of operations (enabled and disabled operations)

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>
Overrides:
isEnabled in class AbstractPreference<V>
Parameters:
operation - some operation of Preference.getOperations()
Returns:
true if the operation can be executed

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>
Overrides:
doOperation in class AbstractPreference<V>
Parameters:
operation - the key of the operation