Multiple Instances with my Plugin running parallel


My Plugin is almost ready to develope. In our Team were working with multiple instances of phpstorm - one for each repository. but unfort. my plugin work only with the last loaded window. it seems as the sources would be shared or something other strange things are happen in background. the first instance shut down my plugin completely. Its a toolwindow. it collapse and if i open it again i got a completely grey background with nothing in it OR it switches(!) to the other instance. bug?


It sounds like you mix up Application vs Project somewhere. Can you share your project sources?


You cannot store Toolwindow/Project instance variables in MyToolWindowFactory. They will be overwritten upon next call of com.intellij.openapi.wm.ToolWindowFactory#createToolWindowContent which explains perfectly your observation above.


and what can i do to avoid that? im beginner in java...


ah ok i understand


The ToolwindowFactory must be stateless. You must create and store all toolwindow-specific data in a newly created Toolwindow object of your own class.


The solution is in other words to intantiate the class of itself. That looks like that:


    public void createToolWindowContent(Project project, ToolWindow toolWindow) {
// process(project, toolWindow); // instead of process just like that, instantiate the class itself...
MyToolWindowFactory myToolWindowFactory = new MyToolWindowFactory();
myToolWindowFactory.process(project, toolWindow);

Thanks for help :-)

Please sign in to leave a comment.