Action <=> ProjectComponent
I'm developping a little plugin and I have some questions.
I have made a ProjectComponent and a ToolWindow. Now I have added an
action on the ToolWindow, and of course I want the action to call some
method on my ToolWindow, or on my ProjectComponent.
What is the "right" way to have a reference to the ProjectComponent in
an Action ? I would pass a reference in the constructor but since it is
instanciated according to the plugin.xml I can't do that. So how do I do
? :)
Thanks for your help.
BoD
Please sign in to leave a comment.
In actionPerformed of the action you can pickup the Project from
DataContext being used, after that you can take the instance of the
project level component:
Project project =
(Project)event.getDataContext()..getData(DataConstants.PROJECT);
YourProjectComponent component =
(YourProjectComponent)project.getComponent(YourProjectComponent.class);
BoD wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Héhéhé thanks, it works fine ! (Well I had to figure that
YourProjectComponent.class was the interface class but that's in the doc :)
BoD
Maxim Mossienko wrote:
>> I'm developping a little plugin and I have some questions.
>>
>> I have made a ProjectComponent and a ToolWindow. Now I have added an
>> action on the ToolWindow, and of course I want the action to call some
>> method on my ToolWindow, or on my ProjectComponent.
>>
>> What is the "right" way to have a reference to the ProjectComponent in
>> an Action ? I would pass a reference in the constructor but since it
>> is instanciated according to the plugin.xml I can't do that. So how do
>> I do ? :)
>>
>> Thanks for your help.
>>
>> BoD