|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PreferenceModel
A preference model is a layer between the framework and its properties, and the
dialog, table or tree with which the user can modify these properties. A model
consists of "preferences", each preference is a wrapper around a single property. A preference
also serves as buffer: modifying a preference does not immediately change the property.
Clients have to call read()
to fill the preference-buffers, and have to call write()
to write changes back.
The framework stores and loads some properties automatically, the preferences for these
properties are called "natural". If on the other hand the framework assumes that a
property is managed by the client, its preference is called "artificial". Clients have
to use a PreferenceStorage
to persistently store and load the artificial preferences.
A preference model also offers information of how to present its preferences to the
user.
The typical lifecycle of a PreferenceModel
looks as follows:
PreferenceStorage
is created and its content loaded using one of its read
-methods.PreferenceStorage.load(PreferenceModel, boolean)
the artificial and natural preferences are loaded.write()
all preferences are made available to the entire framework.read()
will update the contents of the model.write()
will make modified preferences available to the entire framework.PreferenceStorage.store(PreferenceModel)
the preferences are stored.write
-methods of the PreferenceStorage
the client can store the preferences persistentlyPreferenceModel
s can share the same PreferenceStorage
. In such a case its best to re-create and refill the
models before using them.
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 identifier 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)
Like setValue(int, Object) this method changes the value of the index 'th
preference. |
void |
write()
Writes the current preferences to the location where they are used. |
Method Detail |
---|
void read()
void write()
void addPreferenceModelListener(PreferenceModelListener listener)
listener
- the new listenervoid removePreferenceModelListener(PreferenceModelListener listener)
listener
- the listener to remove.int getSize()
String getLabel(int index)
index
'th object.
index
- the number the preference
String getDescription(int index)
index
'th object. The description
is a longer text that will be presented to the user.
index
- the number of the preference
null
, might be formated
in HTMLboolean isEnabled(int index, PreferenceOperation operation)
operation
is enabled for
the preference at location index
.
index
- some locationoperation
- an operation from getOperations(int)
true
if the operation is enabled, false
if notPreferenceOperation[] getOperations(int index)
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.
index
- the location of a preference
null
void doOperation(int index, PreferenceOperation operation)
operation
.
index
- the location of the affected preferenceoperation
- the operation to executeObject getValueInfo(int index)
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)
.
index
- the index of the info
null
if no information is
availableObject getValue(int index)
index
'th preference. The type path
determines how the value is to be presented on the screen.
index
- the number of the preference
null
, has to be immutablevoid setValue(int index, Object value)
index
'th preference.
index
- the number of the preferencevalue
- the new value, may be null
boolean isNatural(int index)
index
'th preference is natural or
artificial.
index
- the index of the preference
true
if the preference is natural, false
if it is artificialvoid setValueNatural(int index)
setValue(int, Object)
this method changes the value of the index
'th
preference. But this time the natural preference has to extract the value from
its underlying property.
index
- the index of the preference to updatePath getTypePath(int index)
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
.
index
- the number of the value
Path getPath(int index)
index
'th preference of
this model.
index
- the index of the preference
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |