[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools] Re: Preferences not getting initialized to defaults

Here is what I did, and I never had the problem -- once I did all of the
following.  Maybe this helps you?

a) your plugin should have a class anyway that extends AbstractUIPlugin; in
that class override the method
    protected void initializeDefaultPreferences (final IPreferenceStore
store) ;
and for each page that you have added to the Preferenhces (details below) use
that IPreferenceStore to init the items on that page.

b) each page you add to the Preferences should extend PreferencePage and
implement IWorkbenchPreferencePage; in each such page, I recommend adding a
static method, that you call in step a, with the IPreferenceStore parameter;
this static method will then handle all data for its page.

c) you will have some way of defining a "preference item" (each check box or
string value or whatever: I invented my own interface); however you do it,
each such item should have a corresponding set of statics (method and tag and
value) that you use in step b to tell Eclipse what the default value of that
preference item is, using the same IPreferenceStore, like this:
    store.setDefault(TAG, DEFAULT_VALUE);
(IPreferenceStore's has many overloaded instance methods called setDefault())

HTH,
Paul K


Todd Chambery wrote:

> Hi all,
>
> My plugin uses preference pages that are not initialized to their default
> values until the actual pref page is viewed.  Consequently, I'm getting
> empty data for the preference lookup.
>
> Has anyone else noticed this behavior?
>
> Todd