Proper way to create/use Tree component


Hello support team

In my plugin I use have a class which extends Tree component to expose some kind of objects. The issue is when I open 2 projects in IDEA these tree components don't show the same data( but the should). I have tried to make the tree static or define it as a app service(global singleton), but in these cases if I open new project the previos one is hidden. What is the propery way to implement a tree component which will be synchronized and has the same data across all idea open projects? It seems for me now that there is only way to create some kind of singleton manager which contains all trees and manages any data actions over trees nodes.



Having a single tree instance is not an option, as it is a UI component and can't be shared and displayed in multiple frames.

I think that you can try sharing a common TreeModel between multiple trees. You can create an application service that will initialize and expose it to trees.


althought it's not beautiful solution, because DefaultTreeModel constructor requires a tree and the model setup into other trees is a bit weird, but it works, thank you.


Please sign in to leave a comment.