Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no "remo
Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no "remo [message #1770659] Tue, 15 August 2017 19:08 Go to next message
Denis Forveille is currently offline Denis ForveilleFriend
Messages: 10
Registered: July 2016
Junior Member
Q:
- Is there any reason why the "org.eclipse.jface.preference.PreferenceStore" class exposes no way to delete/remove a preference from the preference store?
- how to remove a preference from a "PreferenceStore" ?

Even if some want to extends this class, the "Properties" object that is used to store the preference is declared as private and there is no accessor, so it is not possible.

And the documentation states that "This class was not designed to be subclassed. "

I need to be able to remove some preference from the store, so it seems that my only option is to create my own implementation of the "IPersistentPreferenceStore" interface.
In fact I will "clone" the org.eclipse.jface.preference.PreferenceStore class and expose the remove() methods from the internal Properties object

Thanks



Re: Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no " [message #1770759 is a reply to message #1770659] Wed, 16 August 2017 20:22 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

All of the `setValue` methods note:
     * <p>
     * Note that the preferred way of re-initializing a preference to its
     * default value is to call <code>setToDefault</code>.
     * </p>


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no " [message #1770761 is a reply to message #1770759] Wed, 16 August 2017 20:30 Go to previous messageGo to next message
Denis Forveille is currently offline Denis ForveilleFriend
Messages: 10
Registered: July 2016
Junior Member
Brian de Alwis wrote on Wed, 16 August 2017 20:22
All of the `setValue` methods note:
     * <p>
     * Note that the preferred way of re-initializing a preference to its
     * default value is to call <code>setToDefault</code>.
     * </p>

Could you explain in what does this method solves my problem which is to remove a property from the PreferencesStore?
Re: Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no " [message #1770841 is a reply to message #1770761] Thu, 17 August 2017 14:10 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

The first paragraph of the IPreferenceStore javadoc says:
Quote:

The IPreferenceStore interface represents a table mapping named preferences to values. If there is no value for a given name, then that preferences's default value is returned; and if there is no default value for that preference, then a default-default value is returned. The default-default values for the primitive types are as follows:

Removing a value means reverting the value to the default value.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no " [message #1770847 is a reply to message #1770841] Thu, 17 August 2017 15:20 Go to previous messageGo to next message
Denis Forveille is currently offline Denis ForveilleFriend
Messages: 10
Registered: July 2016
Junior Member
Quote:
Removing a value means reverting the value to the default value.

Still not on the point.
The need is not to get the default value for a preference if it exists or not, the need is to remove the preference, ie remove the line corresponding to the preference in the file used by the PreferenceStore (Enter your own reason here: trimming. garbage collection, size reduction etc.).
It's about managing keys, not values


Re: Any reason why the "org.eclipse.jface.preference.PreferenceStore" class has no " [message #1770849 is a reply to message #1770847] Thu, 17 August 2017 20:38 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

The IPreferenceStore has two types of defaults: per-key defaults, and per-type defaults. So every key has a default value, regardless of whether you have set it or not.

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Enable disable custom import export wizards
Next Topic:ValueBinding not catching converter exception
Goto Forum:
  


Current Time: Sun Sep 23 22:14:01 GMT 2018

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

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

Back to the top