ToolWindowManagerImpl.registerToolWindow throwing NPEs

Hello,

I'm trying to port modifications I made to the MKS plugin to the new Selena VCS OpenAPI.

I added a toolwindow to the plugin allowing a quick view of all modified files, and used to register this window during the plugin initComponent method.
This now throws a NPE when trying to register the toolwindow.
Is there an other way I should do it ?

The code I use is the following


java.lang.NullPointerException
at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.a(ToolWindowManagerImpl.java:373)
at com.intellij.openapi.wm.impl.ToolWindowManagerImpl.registerToolWindow(ToolWindowManagerImpl.java:417)
at org.intellij.vcs.mks.MksVcs.initToolWindow(MksVcs.java:148)
at org.intellij.vcs.mks.MksVcs.initComponent(MksVcs.java:77)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:150)
at com.intellij.openapi.components.impl.ComponentManagerImpl.access$1100(ComponentManagerImpl.java:73)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:6)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:25)
at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:193)
at com.intellij.util.pico.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:180)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:162)
at org.picocontainer.defaults.CollectionComponentParameter.getArrayInstance(CollectionComponentParameter.java:268)
at org.picocontainer.defaults.CollectionComponentParameter.resolveInstance(CollectionComponentParameter.java:127)
at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:116)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:257)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:217)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at org.picocontainer.defaults.DecoratingComponentAdapter.getComponentInstance(DecoratingComponentAdapter.java:60)
at org.picocontainer.defaults.CachingComponentAdapter.getComponentInstance(CachingComponentAdapter.java:58)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:2)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:25)
at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:193)
at com.intellij.util.pico.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:180)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:162)
at org.picocontainer.defaults.BasicComponentParameter.resolveInstance(BasicComponentParameter.java:77)
at org.picocontainer.defaults.ComponentParameter.resolveInstance(ComponentParameter.java:114)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getConstructorArguments(ConstructorInjectionComponentAdapter.java:257)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter$1.run(ConstructorInjectionComponentAdapter.java:217)
at org.picocontainer.defaults.ThreadLocalCyclicDependencyGuard.observe(ThreadLocalCyclicDependencyGuard.java:53)
at org.picocontainer.defaults.ConstructorInjectionComponentAdapter.getComponentInstance(ConstructorInjectionComponentAdapter.java:248)
at org.picocontainer.defaults.DecoratingComponentAdapter.getComponentInstance(DecoratingComponentAdapter.java:60)
at org.picocontainer.defaults.CachingComponentAdapter.getComponentInstance(CachingComponentAdapter.java:58)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter$1.getComponentInstance(ComponentManagerImpl.java:2)
at com.intellij.openapi.components.impl.ComponentManagerImpl$ComponentConfigComponentAdapter.getComponentInstance(ComponentManagerImpl.java:25)
at com.intellij.util.pico.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:193)
at com.intellij.util.pico.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:180)
at com.intellij.util.pico.DefaultPicoContainer.getComponentInstance(DefaultPicoContainer.java:162)
at org.picocontainer.alternatives.AbstractDelegatingMutablePicoContainer.getComponentInstance(AbstractDelegatingMutablePicoContainer.java:75)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:86)
at com.intellij.openapi.components.impl.ComponentManagerImpl.a(ComponentManagerImpl.java:51)
at com.intellij.openapi.components.impl.ComponentManagerImpl.initComponents(ComponentManagerImpl.java:64)
at com.intellij.openapi.components.impl.ComponentManagerImpl.init(ComponentManagerImpl.java:98)
at com.intellij.openapi.project.impl.ProjectImpl.init(ProjectImpl.java:4)
at com.intellij.openapi.components.impl.stores.ProjectStoreImpl.loadProject(ProjectStoreImpl.java:33)
at com.intellij.openapi.project.impl.ProjectManagerImpl.loadProject(ProjectManagerImpl.java:57)
at com.intellij.openapi.project.impl.ProjectManagerImpl.loadAndOpenProject(ProjectManagerImpl.java:55)
at com.intellij.ide.impl.ProjectUtil.openProject(ProjectUtil.java:23)
at com.intellij.idea.IdeaApplication.c(IdeaApplication.java:39)
at com.intellij.idea.IdeaApplication.access$400(IdeaApplication.java:41)
at com.intellij.idea.IdeaApplication$IdeStarter$2.run(IdeaApplication.java:6)
at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:15)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:44)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:83)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:6)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
ERROR - ij.components.ComponentManager - IntelliJ IDEA 7.0M1 Build #6819
ERROR - ij.components.ComponentManager - JDK: 1.5.0_11
ERROR - ij.components.ComponentManager - VM: Java HotSpot(TM) Client VM
ERROR - ij.components.ComponentManager - Vendor: Sun Microsystems Inc.
ERROR - ij.components.ComponentManager - OS: Windows 2000
ERROR - ij.components.ComponentManager - Last Action:
IDEA version used is 7.0 M1

4 comments

Hello Thibaut,

I'm trying to port modifications I made to the MKS plugin to the new
Selena VCS OpenAPI.

I added a toolwindow to the plugin allowing a quick view of all
modified files, and used to register this window during the plugin
initComponent method.


Why do you do that? If you do use the Selena API, the correct thing to do
is to implement ChangeProvider, so that modified files will be displayed
in the Changes toolwindow. A proper ChangeProvider implementation gives you
a lot of stuff for free (for example - line status highlighting, create patch
and so on).

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

I guessed I would get that reply , fair enough :)

I guess i could cut my question in 2 parts :
- If a plugin needs to create a toolwindow, is the process is described wrong and how are we supposed to do it ?
- the particular case of MKS : MKS itself has the concept of "change package" which is an MKS object (explicitly created by the developper) which groups together a set of changes. It seems really close to the concept of changeset exposed via the IDEA changes toolwindow.

Thing is, the new OpenAPI VCS global architecture does not yet look familiar enough to me and I was at first trying the plugin work as it did in previous versions.

Based on the delivered sources for the svn plugin It seems a lot of abstractions has to be implemented in order to get it to work. I'll need some time to understand how it all fits together with just the svn plugin source (which is always better than nothing ;))

0

Hello Thibaut,

I guessed I would get that reply , fair enough :)

I guess i could cut my question in 2 parts :

- If a plugin needs to create a toolwindow, is the process is
described wrong and how are we supposed to do it ?


You're registering a toolwindow too early. The registration should be wrapped
in StartupManager.runPostStartupActivity(). You can find many examples of
this pattern in published plugins.

- the particular case of MKS : MKS itself has the concept of "change
package" which is an MKS object (explicitly created by the developper)
which groups together a set of changes. It seems really close to the
concept of changeset exposed via the IDEA changes toolwindow.

Thing is, the new OpenAPI VCS global architecture does not yet look
familiar enough to me and I was at first trying the plugin work as it
did in previous versions.

Based on the delivered sources for the svn plugin It seems a lot of
abstractions has to be implemented in order to get it to work. I'll
need some time to understand how it all fits together with just the
svn plugin source (which is always better than nothing ;))


You may also want to look at the source of the Perforce integration plugin.
Perforce also has a concept of changelists, and the plugin shows how changelists
defined by an external VCS can be made to work with IDEA's changelists.

If you have any questions, feel free to ask, and I'll try to help.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0

thx a lot for those 2 tips, i'll have a look =)

0

Please sign in to leave a comment.