Reading and acting on preferences on startup / plugin load [message #685160] |
Thu, 16 June 2011 23:54 |
Martin F. Messages: 12 Registered: January 2011 |
Junior Member |
|
|
Hi,
I have created a plugin which contributes a wizard and some preference pages to the Eclipse UI.
Now after the user has selected the option(s) on the preference page as he/she wished for example, they are being saved successfully.
My question is: Is there any way to execute certain code upon startup of Eclipse (at/after loading of the plugin) which makes use of the preference store without requiring the user to visit preference page? (because that it what already works, my code is executed when the pref-page is loaded)
The init methods are only being called after the user visits the preference page and therefore the plug-in preference store is accessed. How can i tell Eclipse/my plugin to access that store on load and perform an action based on a preference right away?
I already found out that an activator is executed when a plugin starts, but I can't load the preferenceStore at that early point, so activator does not seem to be an option. But where do I need to put my code to get it executed on startup then?
Thank you.
[Updated on: Thu, 16 June 2011 23:56] Report message to a moderator
|
|
|
|
|
Re: Reading and acting on resukt of preferences [message #685553 is a reply to message #685366] |
Fri, 17 June 2011 18:22 |
|
Mtchr.schmusemail.de wrote on Fri, 17 June 2011 07:15
My fault was trying to do that the constructor of the Activator. So using a method public void start(BundleContext context) in the Activator allows to access the Preference store. Now I have two methods in my Activator: public void start(BundleContext context) and public void stop(BundleContext context)
But unfortunately that start()-Method is also only executed when I open my preference page and not on startup. (tried to perform a simple Logging-Output in there, to verify this) How can I achieve the desired execution onload?
Thanks.
In general in eclipse a plugin is only started the first time a class is accessed. ex: the user shows one of your views. That's the behaviour you are seeing.
In an RCP app, you can use your org.eclipse.ui.application.WorkbenchAdvisor.postStartup() method to check your preference and then start up the server.
PW
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
|
Powered by
FUDForum. Page generated in 0.03558 seconds