any way to hook the EditorManager on app startup? [message #458807] |
Fri, 24 November 2006 16:03  |
Eclipse User |
|
|
|
R3.2.1, WinXP
My RCP app starts up, restores the workbench sites, thus calling the EditorManager.restoreState()
which calls my editor-part's init() method N times; then later on the WorkbenchAdvisor.startup()
method gets called.
Problem is, my editors require that a certain data-model (a kind of type-system) be initialized in
order for the editors to display correctly. (Init'g the type-system requires reading some files from
disk, but no UI work.)
So, in the init()-method, I lazily create that type-system; this works.
But it seems to me that there should be some way to ensure that it is initialized from "startup"
code, which in this case would be, I guess, the EditorManager (since it is run *before* my
WorkbenchAdvisor.startup() ...).
Is there any way to "hook" that EditorManager, so that I can do this init'n once? Or is it possible
to get the type-system inti'n to be done *before* the EditorManager runs, by specifying (something)?
(Prior attempts with "early startup" did not seem to work, since it was not "early enough", but I
may have done something wrongly.)
thanks,
Paul
|
|
|
|
|
Re: any way to hook the EditorManager on app startup? [message #459043 is a reply to message #459004] |
Mon, 27 November 2006 15:38   |
Eclipse User |
|
|
|
> But of course, some things are fundamental. If that's the case, what
> about initializing it in your Bundle#start(BundleContext)? The first
> call to a class contained within your plugin will cause the start(*)
> method to be called, and you can initialize your system there.
>
Hmm -- as mentioned, the TypeSystem is init'd by reading (a small number of) small XML files; but
the location of the root XML file of the files is stored as a preference, and when I call
<pseudocode> TypeSystem.init(); </pseudocode>, from within my activator's start() method (extended
solely for the purpose of making the init-call), I get the horrific call-stack below; nothing like
it ever seen in "normal" operation. (It is not impossible that I am doing something wrong with
prefs...) Other ideas?
thanks,
Paul
!SESSION 2006-11-27 15:31:51.058 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.5.0_04
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -product com.mun.ist.saw2.saw2
Command-line arguments: -product com.mun.ist.saw2.saw2 -data
C:\0-UIMA\eclipse\runtime-SAW-II.product -dev
file:C:/0-UIMA/eclipse/workspace/.metadata/.plugins/org.ecli pse.pde.core/SAW-II.product/dev.properties
-debug C:\0-UIMA\eclipse\workspace\.metadata\.plugins\org.eclipse.p de.core\SAW-II.product/.options
-os win32 -ws win32 -arch x86 -clean
!ENTRY org.eclipse.osgi 4 0 2006-11-27 15:31:53.297
!MESSAGE An error occurred while automatically activating bundle com.mun.ist.saw2 (10).
!STACK 0
org.osgi.framework.BundleException: Exception in com.mun.ist.saw2.SawPlugin.start() of bundle
com.mun.ist.saw2.
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:1010)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:966)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:256)
at
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .preFindLocalClass(EclipseLazyStarter.java:86)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:409)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:334)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:386)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:347)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:278)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1245)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:147)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
Caused by: java.lang.NullPointerException
at
org.eclipse.ui.internal.UIPreferenceInitializer.initializeDe faultPreferences(UIPreferenceInitializer.java:46)
at
org.eclipse.core.internal.preferences.PreferenceServiceRegis tryHelper.runInitializer(PreferenceServiceRegistryHelper.jav a:276)
at
org.eclipse.core.internal.preferences.PreferenceServiceRegis tryHelper.applyRuntimeDefaults(PreferenceServiceRegistryHelp er.java:130)
at
org.eclipse.core.internal.preferences.PreferencesService.app lyRuntimeDefaults(PreferencesService.java:337)
at
org.eclipse.core.internal.preferences.DefaultPreferences.app lyRuntimeDefaults(DefaultPreferences.java:162)
at org.eclipse.core.internal.preferences.DefaultPreferences.loa dDefaults(DefaultPreferences.java:231)
at org.eclipse.core.internal.preferences.DefaultPreferences.loa d(DefaultPreferences.java:227)
at org.eclipse.core.internal.preferences.EclipsePreferences.cre ate(EclipsePreferences.java:307)
at org.eclipse.core.internal.preferences.EclipsePreferences.int ernalNode(EclipsePreferences.java:543)
at org.eclipse.core.internal.preferences.EclipsePreferences.nod e(EclipsePreferences.java:662)
at org.eclipse.core.internal.preferences.AbstractScope.getNode( AbstractScope.java:38)
at org.eclipse.core.runtime.preferences.DefaultScope.getNode(De faultScope.java:67)
at
org.eclipse.ui.preferences.ScopedPreferenceStore.getDefaultP references(ScopedPreferenceStore.java:248)
at org.eclipse.ui.preferences.ScopedPreferenceStore.getPreferen ceNodes(ScopedPreferenceStore.java:282)
at org.eclipse.ui.preferences.ScopedPreferenceStore.internalGet (ScopedPreferenceStore.java:472)
at org.eclipse.ui.preferences.ScopedPreferenceStore.getString(S copedPreferenceStore.java:532)
at com.mun.ist.saw2core.CorpusModelManager.getStoredLocationPat h(CorpusModelManager.java:76)
at com.mun.ist.saw2model.corpus.AbstractCorpusModelManager.<init >(AbstractCorpusModelManager.java:50)
at com.mun.ist.saw2core.CorpusModelManager.<init>(CorpusModelManager.java:116)
at com.mun.ist.saw2core.CorpusModelManager.get(CorpusModelManag er.java:43)
at
com.mun.ist.saw2.views.typesystem.TypeSystemPreferences$Aspe nTypeSystemInit.getCorpus(TypeSystemPreferences.java:239)
at com.mun.ist.saw2model.types.TypeSystemInitializer.initSystem (TypeSystemInitializer.java:46)
at com.mun.ist.saw2.views.typesystem.TypeSystemPreferences.init System(TypeSystemPreferences.java:144)
at com.mun.ist.saw2.SawPlugin.start(SawPlugin.java:36)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:991)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:985)
... 31 more
Root exception:
java.lang.NullPointerException
at
org.eclipse.ui.internal.UIPreferenceInitializer.initializeDe faultPreferences(UIPreferenceInitializer.java:46)
at
org.eclipse.core.internal.preferences.PreferenceServiceRegis tryHelper.runInitializer(PreferenceServiceRegistryHelper.jav a:276)
at
org.eclipse.core.internal.preferences.PreferenceServiceRegis tryHelper.applyRuntimeDefaults(PreferenceServiceRegistryHelp er.java:130)
at
org.eclipse.core.internal.preferences.PreferencesService.app lyRuntimeDefaults(PreferencesService.java:337)
at
org.eclipse.core.internal.preferences.DefaultPreferences.app lyRuntimeDefaults(DefaultPreferences.java:162)
at org.eclipse.core.internal.preferences.DefaultPreferences.loa dDefaults(DefaultPreferences.java:231)
at org.eclipse.core.internal.preferences.DefaultPreferences.loa d(DefaultPreferences.java:227)
at org.eclipse.core.internal.preferences.EclipsePreferences.cre ate(EclipsePreferences.java:307)
at org.eclipse.core.internal.preferences.EclipsePreferences.int ernalNode(EclipsePreferences.java:543)
at org.eclipse.core.internal.preferences.EclipsePreferences.nod e(EclipsePreferences.java:662)
at org.eclipse.core.internal.preferences.AbstractScope.getNode( AbstractScope.java:38)
at org.eclipse.core.runtime.preferences.DefaultScope.getNode(De faultScope.java:67)
at
org.eclipse.ui.preferences.ScopedPreferenceStore.getDefaultP references(ScopedPreferenceStore.java:248)
at org.eclipse.ui.preferences.ScopedPreferenceStore.getPreferen ceNodes(ScopedPreferenceStore.java:282)
at org.eclipse.ui.preferences.ScopedPreferenceStore.internalGet (ScopedPreferenceStore.java:472)
at org.eclipse.ui.preferences.ScopedPreferenceStore.getString(S copedPreferenceStore.java:532)
at com.mun.ist.saw2core.CorpusModelManager.getStoredLocationPat h(CorpusModelManager.java:76)
at com.mun.ist.saw2model.corpus.AbstractCorpusModelManager.<init >(AbstractCorpusModelManager.java:50)
at com.mun.ist.saw2core.CorpusModelManager.<init>(CorpusModelManager.java:116)
at com.mun.ist.saw2core.CorpusModelManager.get(CorpusModelManag er.java:43)
at
com.mun.ist.saw2.views.typesystem.TypeSystemPreferences$Aspe nTypeSystemInit.getCorpus(TypeSystemPreferences.java:239)
at com.mun.ist.saw2model.types.TypeSystemInitializer.initSystem (TypeSystemInitializer.java:46)
at com.mun.ist.saw2.views.typesystem.TypeSystemPreferences.init System(TypeSystemPreferences.java:144)
at com.mun.ist.saw2.SawPlugin.start(SawPlugin.java:36)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2 .run(BundleContextImpl.java:991)
at java.security.AccessController.doPrivileged(Native Method)
at
org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tartActivator(BundleContextImpl.java:985)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.s tart(BundleContextImpl.java:966)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWor ker(BundleHost.java:317)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.star t(AbstractBundle.java:256)
at
org.eclipse.core.runtime.internal.adaptor.EclipseLazyStarter .preFindLocalClass(EclipseLazyStarter.java:86)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLoc alClass(ClasspathManager.java:409)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.fin dLocalClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findLo calClass(BundleLoader.java:334)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:386)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:347)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:278)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1245)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:147)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
!ENTRY org.eclipse.osgi 4 0 2006-11-27 15:31:53.317
!MESSAGE Application error
!STACK 1
org.eclipse.core.runtime.CoreException: Plug-in com.mun.ist.saw2 was unable to load class
com.mun.ist.saw2.Application.
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .throwException(RegistryStrategyOSGI.java:165)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:149)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
org.eclipse.core.runtime.CoreException[1]: java.lang.ClassNotFoundException:
com.mun.ist.saw2.Application
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:402)
at org.eclipse.osgi.framework.internal.core.BundleLoader.findCl ass(BundleLoader.java:347)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loa dClass(DefaultClassLoader.java:83)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.osgi.framework.internal.core.BundleLoader.loadCl ass(BundleLoader.java:278)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClas s(BundleHost.java:227)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.load Class(AbstractBundle.java:1245)
at
org.eclipse.core.internal.registry.osgi.RegistryStrategyOSGI .createExecutableExtension(RegistryStrategyOSGI.java:147)
at
org.eclipse.core.internal.registry.ExtensionRegistry.createE xecutableExtension(ExtensionRegistry.java:759)
at
org.eclipse.core.internal.registry.ConfigurationElement.crea teExecutableExtension(ConfigurationElement.java:243)
at
org.eclipse.core.internal.registry.ConfigurationElementHandl e.createExecutableExtension(ConfigurationElementHandle.java: 51)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(Pl atformActivator.java:74)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:177)
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.core.launcher.Main.invokeFramework(Main.java:336 )
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
|
|
|
Re: any way to hook the EditorManager on app startup? [message #459045 is a reply to message #458832] |
Mon, 27 November 2006 15:48   |
Eclipse User |
|
|
|
Remy Suen wrote:
> Paul Keyser wrote:
>
>> Is there any way to "hook" that EditorManager, so that I can do this
>> init'n once? Or is it possible to get the type-system inti'n to be
>> done *before* the EditorManager runs, by specifying (something)?
>> (Prior attempts with "early startup" did not seem to work, since it
>> was not "early enough", but I may have done something wrongly.)
>
>
> Does the org.eclipse.ui.startup extension point work or was that what
> you were trying to do with regards to your "early startup" attempt?
>
That's what I was trying; fails completely. Well, the "earlyStartup()" method of my IStartup class
gets called, ok, but long after the EditorManager has run. Before I tried making my activator class
be the IStartup, which I now see is deprecated, so just now I tried simply making the
TypeSystem-initializer class be the IStartup, with the same result.
Paul
|
|
|
|
|
|
Re: any way to hook the EditorManager on app startup? [message #459997 is a reply to message #459980] |
Sun, 10 December 2006 22:55  |
Eclipse User |
|
|
|
Interesting idea, thanks. But what do you mean, exactly -- what code would go into that non-UI
(lower-level) plug-in that is to be loaded at startup? (I see what would go into the UI plug-in --
the prefs-page, along with all the other UI stuff; in fact, that's more or less what I have now.)
But raising that issue, makes me wonder if I may be doing something wrong with prefs, or failing to
do something needed. Reminder: I need to access the stored prefs-values at startup, before the user
ever opens a prefs-page; I'm using the PreferenceStore provided by AbstractUIPlugin.
I've looked at the (old) article on prefs, but it is pre-RCP and does not seem to contain anything
relevant: http://www.eclipse.org/articles/Article-Preferences/preferen ces.htm
I've looked at the bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=86750, which could be relevant,
but I am using Eclipse 3.2.1, and it is said to be fixed as of 3.1 -- do I still need to call
getStateLocation() or getInstanceLocation()?
There is also the possibility of an AbstractPreferenceInitializer (and the tag "initializer" of the
preferences ext.-pt.) -- would that be correct here?
I'll be trying these ideas, but it feels somewhat random-walky -- is there any description of how
one is supposed to handle this case -- which does not really seem all that remote?
thanks,
Paul
|
|
|
Powered by
FUDForum. Page generated in 0.02387 seconds