public class DefaultPreferenceModel extends AbstractPreferenceModel
PreferenceModel
using Preference
s to
describe its entries.Constructor and Description |
---|
DefaultPreferenceModel(DockController controller) |
Modifier and Type | Method and Description |
---|---|
void |
add(Preference<?> preference)
Adds
preference at the end of this model. |
void |
addPreferenceModelListener(PreferenceModelListener listener)
Adds a listener to this model.
|
void |
doOperation(int index,
PreferenceOperation operation)
Executes the enabled operation
operation . |
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. |
Preference<?> |
getPreference(int index)
Gets the preference of location
index . |
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. |
int |
indexOf(Preference<?> preference)
Gets the location of
preference . |
void |
insert(int index,
Preference<?> preference)
Adds a new preference to this model.
|
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 |
remove(int index)
Removes the
index 'th preference of this model. |
void |
remove(Preference<?> preference)
Removes
preference from this model. |
void |
removeAll()
Removes all preferences of this model.
|
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
PreferenceModel.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.
|
firePreferenceAdded, firePreferenceChanged, firePreferenceRemoved, getController, hasListeners, listeners
public DefaultPreferenceModel(DockController controller)
public int getSize()
PreferenceModel
public java.lang.String getLabel(int index)
PreferenceModel
index
'th object.index
- the number the preferencepublic java.lang.String getDescription(int index)
PreferenceModel
index
'th object. The description
is a longer text that will be presented to the user.getDescription
in interface PreferenceModel
getDescription
in class AbstractPreferenceModel
index
- the number of the preferencenull
, might be formated
in HTMLpublic java.lang.Object getValueInfo(int index)
PreferenceModel
index
'th value can
be modified. For an integer that might be its upper and lower boundaries.
The type of this objects depends on PreferenceModel.getTypePath(int)
.index
- the index of the infonull
if no information is
availablepublic java.lang.Object getValue(int index)
PreferenceModel
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 immutablepublic void setValue(int index, java.lang.Object value)
PreferenceModel
index
'th preference.index
- the number of the preferencevalue
- the new value, may be null
public Path getTypePath(int index)
PreferenceModel
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 valuepublic Path getPath(int index)
PreferenceModel
index
'th preference of
this model.index
- the index of the preferencepublic boolean isNatural(int index)
PreferenceModel
index
'th preference is natural or
artificial.
isNatural
in interface PreferenceModel
isNatural
in class AbstractPreferenceModel
index
- the index of the preferencetrue
if the preference is natural, false
if it is artificialpublic void setValueNatural(int index)
PreferenceModel
PreferenceModel.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.setValueNatural
in interface PreferenceModel
setValueNatural
in class AbstractPreferenceModel
index
- the index of the preference to updatepublic void addPreferenceModelListener(PreferenceModelListener listener)
PreferenceModel
addPreferenceModelListener
in interface PreferenceModel
addPreferenceModelListener
in class AbstractPreferenceModel
listener
- the new listenerpublic void removePreferenceModelListener(PreferenceModelListener listener)
PreferenceModel
removePreferenceModelListener
in interface PreferenceModel
removePreferenceModelListener
in class AbstractPreferenceModel
listener
- the listener to remove.public Preference<?> getPreference(int index)
index
.index
- the location of the preferencepublic void add(Preference<?> preference)
preference
at the end of this model.preference
- the preference to addpublic void insert(int index, Preference<?> preference)
index
- the location of the new preferencepreference
- the new preferencepublic void remove(int index)
index
'th preference of this model.index
- the preference to removepublic void remove(Preference<?> preference)
preference
from this model.preference
- the preference to removepublic void removeAll()
public int indexOf(Preference<?> preference)
preference
.preference
- the preference to accesspreference
or -1public void read()
PreferenceModel
read
in interface PreferenceModel
read
in class AbstractPreferenceModel
public void write()
PreferenceModel
write
in interface PreferenceModel
write
in class AbstractPreferenceModel
public PreferenceOperation[] getOperations(int index)
PreferenceModel
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.getOperations
in interface PreferenceModel
getOperations
in class AbstractPreferenceModel
index
- the location of a preferencenull
public boolean isEnabled(int index, PreferenceOperation operation)
PreferenceModel
operation
is enabled for
the preference at location index
.isEnabled
in interface PreferenceModel
isEnabled
in class AbstractPreferenceModel
index
- some locationoperation
- an operation from PreferenceModel.getOperations(int)
true
if the operation is enabled, false
if notpublic void doOperation(int index, PreferenceOperation operation)
PreferenceModel
operation
.doOperation
in interface PreferenceModel
doOperation
in class AbstractPreferenceModel
index
- the location of the affected preferenceoperation
- the operation to execute