[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools] Re: What's the best way to notify an editor of preference changes?
|
You could add your editor as a IPropertyChangeListener to the
com.ibm.jface.preferences.IPreferenceStore. There are lifecycle methods on
editors, etc. where you can remove the listeners again.
Thomas
jamsden@xxxxxxxxxx wrote:
> There may be two classes of preferences, those that are just data that the
> editor, view, or builder goes and gets when it needs it, and those that
> effect an editor or view that is already running. In the first case, it
> seems like the best approach is to use a FieldEditorPreferencePage to
> display, input, validate, and store preferences. To get the values,
> subclasses can provide convenience methods that get the preferences store
> and query and return the value given its id.
>
> For the second case, the opened editors and/or views need to be notified
> of changes that happen so they can update their views accordingly. This
> could be done by iterating over the effected editors and views in the
> FieldEditorPreferencPage.performOk() method, but this seems like it would
> create undesirable coupling. The preference page would have to know how to
> update the corresponding viewers. Another possibility is to use the fact
> that a FieldEditorPreferencePage is an IPropertyChangeListener so editors
> could register interest in property changes that effect their views. The
> disadvantage of this approach is that the interest has to be removed when
> the editor or view is removed or exceptions will be raised if the
> preference page is changed after the viewer is closed.
>
> What is the preferred approach for handling preferences that effect open
> viewers?