Reading and acting on preferences on startup / plugin load [message #685160] |
Thu, 16 June 2011 19:54  |
Eclipse User |
|
|
|
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 19:56] by Moderator
|
|
|
|
|
|
Re: Reading and acting on resukt of preferences [message #708736 is a reply to message #685553] |
Wed, 03 August 2011 02:09  |
Eclipse User |
|
|
|
Hi,
I am facing a similar kind of problem. I want to close all editors at the time of launch. Since mine is a plugin project but is not an RCP application, i am not sure how and where do i override org.eclipse.ui.application.WorkbenchAdvisor.postStartup() method. I added following piece of code in start method of activator.
PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow iWorkbenchWindow : windows) {
if (iWorkbenchWindow.getActivePage() != null) {
break;
}
iWorkbenchWindow.close();
}
but this is of no use. I added above code to one of the methods of class implementing AbstractUIPlugin. It is closing all the editors at the time of eclipse luanch but throwd a NullPoiner Exception as well. Please fond the stack trace below:
java.lang.NullPointerException
at org.eclipse.ui.internal.menus.WorkbenchMenuService.releaseContributions(WorkbenchMenuService.java:854)
at org.eclipse.ui.internal.WorkbenchWindow.hardClose(WorkbenchWindow.java:1682)
at org.eclipse.ui.internal.WorkbenchWindow.busyClose(WorkbenchWindow.java:723)
at org.eclipse.ui.internal.WorkbenchWindow.access$0(WorkbenchWindow.java:699)
at org.eclipse.ui.internal.WorkbenchWindow$5.run(WorkbenchWindow.java:815)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchWindow.close(WorkbenchWindow.java:813)
at org.eclipse.ui.internal.Workbench$61.runWithException(Workbench.java:3402)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1384)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
Please help.
thanks
|
|
|
Powered by
FUDForum. Page generated in 0.03889 seconds