bibliothek.extension.gui.dock.preference
Interface PreferenceModel

All Known Implementing Classes:
AbstractPreferenceModel, BubbleThemePreferenceModel, DefaultPreferenceModel, DockingFramesPreference, EclipseThemePreferenceModel, KeyStrokePreferenceModel, LayoutPreferenceModel, MergedPreferenceModel, PreferenceTreeModel

public interface PreferenceModel

A preference model is a list of objects which represent some preferences of another resource. A preference model has enough information to be displayed in a graphical user interface and be modified by a user.

Author:
Benjamin Sigg

Method Summary
 void addPreferenceModelListener(PreferenceModelListener listener)
          Adds a listener to this model.
 void doOperation(int index, PreferenceOperation operation)
          Executes the enabled operation operation.
 String getDescription(int index)
          Gets a description of the index'th object.
 String getLabel(int index)
          Gets a short label that can be presented to the user for the index'th object.
 PreferenceOperation[] getOperations(int index)
          Gets all operations for which this model has a definition for the preference at location index.
 Path getPath(int index)
          Gets the unique location of the index'th preference of this model.
 int getSize()
          Gets the number of preferences stored in this model.
 Path getTypePath(int index)
          Tells what kind of type the index'th value is.
 Object getValue(int index)
          Gets the index'th preference.
 Object getValueInfo(int index)
          Gets information about how the index'th value can be modified.
 boolean isEnabled(int index, PreferenceOperation operation)
          Tells whether the operation operation is enabled for the preference at location index.
 boolean isNatural(int index)
          Tells whether the index'th preference is natural or artificial.
 void read()
          Uses an unknown source to update this model and load all the preferences that are currently available.
 void removePreferenceModelListener(PreferenceModelListener listener)
          Removes a listener from this model.
 void setValue(int index, Object value)
          Sets the value of the index'th preference.
 void setValueNatural(int index)
          Asks this model to set the index'th preference on its natural way.
 void write()
          Writes the current preferences to the location where they are used.
 

Method Detail

read

void read()
Uses an unknown source to update this model and load all the preferences that are currently available. If the underlying resource cannot be read, or returns invalid data, then this model should not change its content.


write

void write()
Writes the current preferences to the location where they are used.


addPreferenceModelListener

void addPreferenceModelListener(PreferenceModelListener listener)
Adds a listener to this model.

Parameters:
listener - the new listener

removePreferenceModelListener

void removePreferenceModelListener(PreferenceModelListener listener)
Removes a listener from this model.

Parameters:
listener - the listener to remove.

getSize

int getSize()
Gets the number of preferences stored in this model.

Returns:
the number of preferences

getLabel

String getLabel(int index)
Gets a short label that can be presented to the user for the index'th object.

Parameters:
index - the number the preference
Returns:
a short human readable description

getDescription

String getDescription(int index)
Gets a description of the index'th object. The description is a longer text that will be presented to the user.

Parameters:
index - the number of the preference
Returns:
the description, might be null, might be formated in HTML

isEnabled

boolean isEnabled(int index,
                  PreferenceOperation operation)
Tells whether the operation operation is enabled for the preference at location index.

Parameters:
index - some location
operation - an operation from getOperations(int)
Returns:
true if the operation is enabled, false if not

getOperations

PreferenceOperation[] getOperations(int index)
Gets all operations for which this model has a definition for the preference at location index. Note: a PreferenceEditor has operations as well, if the editor and the model share an operation, then the operation is considered to belong to the editor.

Parameters:
index - the location of a preference
Returns:
the list of available operations (enabled and disabled operations), can be null

doOperation

void doOperation(int index,
                 PreferenceOperation operation)
Executes the enabled operation operation.

Parameters:
index - the location of the affected preference
operation - the operation to execute

getValueInfo

Object getValueInfo(int index)
Gets information about how the index'th value can be modified. For an integer that might be its upper and lower boundaries. The type of this objects depends on getTypePath(int).

Parameters:
index - the index of the info
Returns:
the information or null if no information is available

getValue

Object getValue(int index)
Gets the index'th preference. The type path determines how the value is to be presented on the screen.

Parameters:
index - the number of the preference
Returns:
the value or maybe null, has to be immutable

setValue

void setValue(int index,
              Object value)
Sets the value of the index'th preference.

Parameters:
index - the number of the preference
value - the new value, may be null

isNatural

boolean isNatural(int index)
Tells whether the index'th preference is natural or artificial.

Parameters:
index - the index of the preference
Returns:
true if the preference is natural, false if it is artificial

setValueNatural

void setValueNatural(int index)
Asks this model to set the index'th preference on its natural way.

Parameters:
index - the index of the preference to set

getTypePath

Path getTypePath(int index)
Tells what kind of type the index'th value is. The type is represented as a path. Most times the path would equal the name of some class. Note: there is a set of standard paths defined in Path.

Parameters:
index - the number of the value
Returns:
a unique path for the type of this value

getPath

Path getPath(int index)
Gets the unique location of the index'th preference of this model.

Parameters:
index - the index of the preference
Returns:
the unique path, compared to the other paths of this model, to the preference