how to register a universal editor onlick listener
已回答
I want to register an onclick listener for all text-editor tab in the coding area. More specifically, I want to register an onclick listener for all the current editor tabs and those which are open later.
Right now I am register the listener via
//In an action
final Editor editor = anActionEvent.getRequiredData(CommonDataKeys.EDITOR);
editor.addEditorMouseListener...
But this api will only add the listener for the editor-tabs that have already been open.
In this post,
https://intellij-support.jetbrains.com/hc/en-us/community/posts/205423050-listener-for-ide-actions
FileEditorManagerAdapter
has been deprecated.
Thx in advance!
请先登录再写评论。
>FileEditorManagerAdapter has been deprecated.
It was deprecated because FileEditorManagerListener was migrated to JDK8 and now uses default method implementations (so this adapter is no longer needed).
Also, you can take a look at `com.intellij.openapi.editor.EditorFactory#getAllEditors` and `com.intellij.openapi.editor.event.EditorFactoryListener`.
It'll allow you to track all other editors in IDE (ex: created to show some preview in toolwindow, as an input field in a dialog, etc).
Also, there are `com.intellij.openapi.editor.event.EditorEventMulticaster` and `com.intellij.openapi.editor.EditorFactory#getEventMulticaster`.
Probably, it will be better than manually tracking all opened editors.
Thx Aleksey, com.intellij.openapi.editor.event.EditorEventMulticaster makes my life much easier.