Get Instance of Toolwindow
Answered
Is there a way to get the Instance of my Toolwindow?
MyToolWindowFactory instance = ServiceManager.getService(project, MyToolWindowFactory.class);
..doesnt work.
Any suggestions?
Please sign in to leave a comment.
@Aleksey, the `window` I get from ToolWindowManager is of type `ToolWindowImpl`. But I don't want that, I want MY Implementation class, like `MyToolWindow`.
Right now, `window.getClass() = ToolWindowImpl.class`, but what I want is `window.getClass() = MyToolWindow.class`. How do I get this?
UPDATED: So what I want is not the `ToolWindow` but my `ToolWindowFactory`, so that I can update the JBTable in the ToolWindow.
I'm not sure, that it's possible.
What do you need it for?
I have a `JBTable` in the ToolWindow and I want to update that in the `AnAction.actionPerformed()` method. So I wanted to get a hold of my ToolWindowFactory, since I have the methods to update the JBTable in that class.
Probably, you're looking for `toolwindow.getContentManager().getContents()` method.
It will return all tabs in a ToolWindow, that can be added using `ContentManager.addContent`.
Hey thanks for that, I got it. I did as below:
The below code is in my AnAction.actionPerformed() :
In my MyToolWindowFactory.createToolWindowContent() (which extends ToolWindowFactory) I put the below code:
And finally, my MyToolWindowPanel which extends SimpleToolWindowPanel has the below code:
mContentPanel contains my JBTable. So now I can get a reference to MyToolWindowPanel anywhere I want, and all my JBTable update code is in MyToolWindowPanel.
Perfect!