Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Preferences IPropertyChangeListener
Preferences IPropertyChangeListener [message #1770435] Fri, 11 August 2017 11:01 Go to next message
sirair sirair is currently offline sirair sirairFriend
Messages: 6
Registered: November 2015
Junior Member
Hello,

im my RCP application I use custom Preferences.
To listen for changes I use the code below.
IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore();
preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {
			@Override
			public void propertyChange(PropertyChangeEvent event) {
				}
		});


The problem is that I have more than two preferences, but only a special preference is relevant for a plugin. But in the above code I get notified for each change.
Is it possible to get notified for a special preference, even better when I get notified for a special BooleanFieldEditor used in the preference for example.
Re: Preferences IPropertyChangeListener [message #1770578 is a reply to message #1770435] Mon, 14 August 2017 15:48 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 652
Registered: January 2012
Senior Member

You have to filter the change events.

Quote:
Is it possible [...] even better when I get notified for a special BooleanFieldEditor used in the preference for example.


Why do you want to do this? I'll posit that you don't want to know about what changed the preference (i.e., the BooleanFieldEditor). In doing so, you risk operating against stale data (i.e., a legitimate change came from elsewhere). If you're seeking to perform validation, check it in the editor or the pref page before writing the preference change out; by the time the event comes, it's too late: the value has been written out.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:RunAndTrack update accessed variables
Next Topic:Rendering a label or text field in a toolbar is incorrect in defining over fragment.e4xmi
Goto Forum:
  


Current Time: Fri Sep 22 13:45:54 GMT 2017

Powered by FUDForum. Page generated in 0.04309 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software