Update content of ToolWindow according to selected file


I want to update the content of my tool window according to the selected file/package (in the editor or project view). The same is done in the PropertiesComponent.java by the FollowSelectionAction of the SVN plugin: https://upsource.jetbrains.com/idea-ce/file/idea-ce-1731d054af4ca27aa827c03929e27eeb0e6a8366/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/PropertiesComponent.java?nav=14493:14514:focused

I also implemented a ToggleAction and try to get the VirtualFile in the update method like that:
public void update(final AnActionEvent e) {
VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());

However, the file is null.

How can I get the currently selected resource (file/package/...) in the context of a tool window?


Please sign in to leave a comment.