Plugin Development listen to file navigation listener
I need to capture event when user navigates to a different file (not do save just change the active file on their UI). The following code I am able to capture the change or save event. But this does not capture when user navigates to a new file without making any changes. Can someone please look into this and see how to get event when user navigates to a new file in IntelliJ Idea plugin. Thank you.
public class ExampleFileChangeListener implements ApplicationListener, BulkFileListener {
public ExampleFileChangeListener() {
Project project = ProjectHelper.getProject(DataManager.getInstance().getDataContext());
project.getMessageBus().connect().subscribe(
VirtualFileManager.VFS_CHANGES,
new BulkFileListener() {
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
System.out.println("File change detected" + events);
}
});
}
}
Plugin.xml file
<projectListeners>
<listener class="com.company.project.ide.intellij.listener.ExampleFileChangeListener"
topic="com.intellij.openapi.vfs.newvfs.BulkFileListener"/>
/>
</projectListeners>
<applicationListeners>
<listener
class="com.company.project.ide.intellij.listener.ExampleFileChangeListener"
topic="com.company.openapi.vfs.newvfs.BulkFileListener"/>
</applicationListeners>
请先登录再写评论。