Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Issues with PreferenceStore
Issues with PreferenceStore [message #285551] Wed, 18 May 2005 18:37 Go to next message
Eclipse UserFriend
Originally posted by: martin.hejl.de

Hi,

I'm trying to working on a PreferenceStore implementation that saves the
data to a database instead of a file. In that process, I've come across
two issues that I don't quite get - maybe somebody here could help me out.

1. maybe it's just a misunderstanding on my side, but why doesn't
IPersistentPreferenceStore also include a declaration for a "load()"
method? My idea is that it would be nice if PreferenceStore and my new
DatabasePreferenceStore could be used interchangeably, but with
IPersistentPreferenceStore missing a means to load the data, I don't
quite see how that could work (without subclassing PreferenceStore,
which, according to the API docs, it was not designed for).

2. (and more importantly)
The API documentation of "public String[] preferenceNames()" of
PreferenceStore states:
"Returns an enumeration of all preferences known to this store which
have current values other than their default value"

Now, this would be exactly what I'd need (since I wouldn't want to save
the values that are at their default anyway), but it doesn't seem to
work that way (again, maybe I just don't understand what the docs are
actually saying).
When running the following code snippet

PreferenceStore store = new PreferenceStore();
store.setDefault("test1", true);
store.setDefault("test2", 10);
store.setDefault("test3", "something");
store.putValue("test3", "something else");

String[] names = store.preferenceNames();
for (int i = 0; i < names.length; i++) {
System.out.println(
names[i] +
": " +
store.getString(names[i]) +
" (" +
store.getDefaultString(names[i]) +
")"
);
}


I'd expect the output to be
test3: something else (something)

but instead I get
test3: something else (something)
test2: 10 (10)
test1: true (true)

Obviously, working around that issue is not a big deal, but I'd like to
understand why things aren't working they way I'd expect them to work
from reading the docs.

Can somebody enlighten me what I'm misunderstanding here?

Thanks

Martin
Re: Issues with PreferenceStore [message #686069 is a reply to message #285551] Tue, 21 June 2011 15:10 Go to previous message
atx Missing name is currently offline atx Missing nameFriend
Messages: 2
Registered: June 2011
Junior Member
I've the same problem, did you find a solution that works for you?
Previous Topic:Using Team API
Next Topic:Interested in Eclipse's update mechanism
Goto Forum:
  


Current Time: Thu Mar 28 17:17:58 GMT 2024

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

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

Back to the top