How to find topics ?
MessageBus bus = ApplicationManager.getApplication().getMessageBus();
MessageBusConnection connection = bus.connect();
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
@Override
public void fileOpened(FileEditorManager source, VirtualFile file) {
}
@Override
public void fileClosed(FileEditorManager source, VirtualFile file) {
}
@Override
public void selectionChanged(FileEditorManagerEvent event) {
}
});
I want to use the MessageBus to subscribe some event like: saved file, installed a plugin, run tests.
But I don't know the Topic of these event.
How to find the Topics I wanted?
Please sign in to leave a comment.
The only way seems to be using "Find Usages" on com.intellij.util.messages.Topic#create(java.lang.String, java.lang.Class<L>) or any of its other CTORs.
Note that topics aren't a general way to learn about everything happening inside the IDE; there is no such way. For example, IntelliJ IDEA does not broadcast notifications of any kind when a plugin is installed, and test execution listeners need to be attached to specific run configurations.
so what's the best way to do this?
To do what? As I said, there is no API to let you get notified about everything happening in the IDE.
Would it be possible to use enum (instead of String) for topics? ;)
No, of course not. Any component of the IDE, and any plugin, can provide its own topic.