void () { myConnection = myProject.getMessageBus().connect(); myConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() { @Override public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { bindToDesigner(getActiveDesigner()); } @Override public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { ApplicationManager.getApplication().invokeLater(() -> bindToDesigner(getActiveDesigner())); } @Override public void selectionChanged(@NotNull FileEditorManagerEvent event) { bindToDesigner(getDesigner(event.getNewEditor())); } }); }