public interface PreferenceModel
read()
to fill the preference-buffers, and have to call write()
to write changes back.PreferenceStorage
to persistently store and load the artificial preferences.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.Modifier and Type | Method and Description |
---|---|
void |
addPreferenceModelListener(PreferenceModelListener listener)
Adds a listener to this model.
|
void |
doOperation(int index,
PreferenceOperation operation)
Executes the enabled operation
operation . |
DockController |
getController()
Gets the
DockController in whose realm this model is used. |
java.lang.String |
getDescription(int index)
Gets a description of the
index 'th object. |
java.lang.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. |
java.lang.Object |
getValue(int index)
Gets the
index 'th preference. |
java.lang.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,
java.lang.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.
|
DockController getController()
DockController
in whose realm this model is used. The controller
is mainly necessary to load icons and text.void read()
void write()
void addPreferenceModelListener(PreferenceModelListener listener)
listener
- the new listenervoid removePreferenceModelListener(PreferenceModelListener listener)
listener
- the listener to remove.int getSize()
java.lang.String getLabel(int index)
index
'th object.index
- the number the preferencejava.lang.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 preferencenull
, 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 preferencenull
void doOperation(int index, PreferenceOperation operation)
operation
.index
- the location of the affected preferenceoperation
- the operation to executejava.lang.Object 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 infonull
if no information is
availablejava.lang.Object 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 preferencenull
, has to be immutablevoid setValue(int index, java.lang.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 preferencetrue
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 valuePath getPath(int index)
index
'th preference of
this model.index
- the index of the preference