|
|
|
|
Re: Preference Values [message #500470 is a reply to message #500117] |
Thu, 26 November 2009 09:53 |
|
Ok, lets see troubles check list
1. Check prefs initialization extension point exists in plugin.xml
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="xxx. ProfilesPreferenceInitializer">
</initializer>
</extension>
2. Check class xxx. ProfilesPreferenceInitializer
public class ProfilesPreferenceInitializer extends AbstractPreferenceInitializer {
public ProfilesPreferenceInitializer() {
super();
}
@Override
public void initializeDefaultPreferences() {
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
store.setDefault(<pref mnemonic name>, <default pref value>);
}
}
3. Check bundle Activator in bundle MANIFEST.MF present and "Activate this plugin when one of its classes loaded" is checked.
4. Check Activator class declaration
public class Activator extends AbstractUIPlugin
5. Check read default pref value code
Activator activator = Activator.getDefault();
String value = activator.getPreferenceStore().getString(<pref mnemonic name>);
If this does not help can you send me your code?
|
|
|
Re: Preference Values [message #661566 is a reply to message #500117] |
Fri, 25 March 2011 11:45 |
Martin F. Messages: 12 Registered: January 2011 |
Junior Member |
|
|
It seems like I have the exact same problem. I made my way through the checklist above and everything seems to be fine according to it.
But initializeDefaultPreferences() is only called when the PreferencePage is being opened. (checked by setting a breakpoint)
Is initializeDefaultPreferences() being called at this moment only and not while the plugin loads, by design? (it's not the constructor, so that would make sense for my limited knowledge) If so, how can I evaluate a value stored in the preferences store during loading of the plugin? (and execute some code accordingly)
[Updated on: Fri, 25 March 2011 11:46] Report message to a moderator
|
|
|
|
|
|
Re: Preference Values [message #662020 is a reply to message #661883] |
Mon, 28 March 2011 22:24 |
Martin F. Messages: 12 Registered: January 2011 |
Junior Member |
|
|
Dani Megert wrote on Mon, 28 March 2011 14:04 |
I don't see how getPreferenceStore() would cause an NPE.
|
Well yes, it's quite confusing because it checks for being null and creates a new store in that case (which it shouldn't btw. I'm not wanting to create a new store, I want to use my existing data. Or would that be the case if it creates a new one at this point?)
Anyway here's a debug-session which shows the NPE: http://vimeo.com/21603141 (HD in fullscreeen-mode makes the fonts readable)
I'm pressing F5-F6-F6 when "miracle" steps appear in the video, sry, should have used the mouse maybe to make it more clear.
I'm completely lost on what goes wrong there. ;-(
regards
Martin
> Is it inappropriate to do this in the Activator (if so, where should
> it be done to perform something on loading of the plugin which uses
> the PreferenceStore?) or does the PreferenceStore need to be accessed
> in another way than mentioned above when doing it in the Activator?
> kind regards
>
> Martin
[Updated on: Mon, 28 March 2011 22:25] Report message to a moderator
|
|
|
|
Re: Preference Values [message #665660 is a reply to message #662075] |
Fri, 15 April 2011 12:19 |
Martin F. Messages: 12 Registered: January 2011 |
Junior Member |
|
|
Dani Megert wrote on Tue, 29 March 2011 09:34
> Sorry, that was my bad - I didn't notice that you do it in the
> constructor. You can basically do it anywhere in the activator but not
> in the constructor because there 'start' wasn't called yet and hence the
> bundle (i.e. getBundle()) is still 'null'.
Okay thanks, taking it out of the constructor fixes this NP-issue but leaves the problem that nothing is being performed during/after load of Eclipse and my plugin. I have to open the preference page to make it perform the wanted steps (reading the pref and performing calling a function according to it) but I'm searching for a way so it does that without opening the preferences page. (as mentioned below)
>> Is it inappropriate to do this in the Activator (if so, where should
>> it be done to perform something on loading of the plugin which uses
>> the PreferenceStore?) or does the PreferenceStore need to be accessed
>> in another way than mentioned above when doing it in the Activator?
>> kind regards
>>
>> Martin
[Updated on: Thu, 16 June 2011 15:03] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.10964 seconds