Package org.eclipse.jface.preference
Class PreferenceMemento
java.lang.Object
org.eclipse.jface.preference.PreferenceMemento
A utility to change and remember preference values and later restore there
original value. The first time a preference value is changed its current
value is stored. Later you can reset all preference values (which are changed
through this class) to the state they had when creating the memento.
This class is most useful for testing to prevent leakage of preference changes between individual tests.
- Since:
- 3.18
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Reset every preference changed by this utility to its state before the first change.<T> void
setValue
(IPreferenceStore store, String name, T value) Set the value for the given preference on the given store.
-
Constructor Details
-
PreferenceMemento
public PreferenceMemento()
-
-
Method Details
-
setValue
Set the value for the given preference on the given store.The first time this preference is changed its value before change is remembered and can later be restored using
resetPreferences()
.- Type Parameters:
T
- the preference value type. The type must have a correspondingIPreferenceStore
setter.- Parameters:
store
- the preference store to manipulate (notnull
)name
- the name of the preference (notnull
)value
- the new current value of the preference.- Throws:
IllegalArgumentException
- when setting a type which is not supported byIPreferenceStore
- See Also:
-
resetPreferences
public void resetPreferences()Reset every preference changed by this utility to its state before the first change. After this the instance can still be used as if it was just created.
-