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

public class DefaultPreference<V>
extends AbstractPreference<V>

A generic Preference that can hold any value.

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 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 the choices for this preferences value.
 boolean isEnabled(PreferenceOperation operation)
          Tells whether operation is enabled and thus Preference.doOperation(PreferenceOperation) can be called.
 void setDefaultValue(V defaultValue)
          Sets the default value of this preference
 void setDescription(String description)
          Sets a description of this preference.
 void setLabel(String label)
          Sets a short human readable label for this preference.
 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
addPreferenceListener, fireChanged, listeners, read, removePreferenceListener, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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

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

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 the choices for this preferences value. 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

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

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