bibliothek.extension.gui.dock.preference
Interface PreferenceEditor<V>

Type Parameters:
V - the kind of value this editor edits
All Known Implementing Classes:
BooleanEditor, ChoiceEditor, KeyStrokeEditor, LabelEditor, ModifierMaskEditor, StringEditor

public interface PreferenceEditor<V>

An editor configures a Component which is used to edit some value. How exactly this component is configured depends on the meta-information extracted from the preference which is edited.
An editor communicates with its surroundings through a callback. The editor can ask its parent to show some buttons which represent operations this editor can execute. For example an editor could ask its parent to show a "reset value to default"-button. The editor manages these buttons by calling PreferenceEditorCallback.setOperation(PreferenceOperation, boolean) and by implementing doOperation(PreferenceOperation).

Author:
Benjamin Sigg

Method Summary
 void doOperation(PreferenceOperation operation)
          Executes the operation that matches operation or does nothing if operation is unknown.
 Component getComponent()
          Gets a component which displays the contents of this editor.
 V getValue()
          Gets the value of this editor.
 void setCallback(PreferenceEditorCallback<V> callback)
          Sets a callback, a callback can be used to read the value that has to be edited or to store the edited value.
 void setValue(V value)
          Sets the current value of this editor.
 void setValueInfo(Object information)
          Sets information about the value that is shown.
 

Method Detail

getComponent

Component getComponent()
Gets a component which displays the contents of this editor.

Returns:
the component, not null

setCallback

void setCallback(PreferenceEditorCallback<V> callback)
Sets a callback, a callback can be used to read the value that has to be edited or to store the edited value.
Note: this editor should call PreferenceEditorCallback.set(Object) whenever this editor shows a new valid value.

Parameters:
callback - the callback, might be null

setValueInfo

void setValueInfo(Object information)
Sets information about the value that is shown. This method is called before setValue(Object). This method might be called with a null argument when the editor is no longer needed.

Parameters:
information - the information, may be null

setValue

void setValue(V value)
Sets the current value of this editor.

Parameters:
value - the value, might be null

getValue

V getValue()
Gets the value of this editor.
Note: editors should call PreferenceEditorCallback.set(Object) when their value got edited by the user. An editor should not expect a call to this method.

Returns:
the value, might be null

doOperation

void doOperation(PreferenceOperation operation)
Executes the operation that matches operation or does nothing if operation is unknown.

Parameters:
operation - the operation that was triggered