void (@NotNull MessageBusConnection connection) { connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() { @Override public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { updateStatus(); } @Override public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { updateStatus(); } @Override public void selectionChanged(@NotNull FileEditorManagerEvent event) { updateStatus(); } }); PropertyChangeListener propertyChangeListener = event -> { String propertyName = event.getPropertyName(); if (EditorEx.PROP_INSERT_MODE.equals(propertyName) || EditorEx.PROP_COLUMN_MODE.equals(propertyName) || SWING_FOCUS_OWNER_PROPERTY.equals(propertyName)) { if (!getProject().isDisposed()) { updateStatus(); } } }; EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster(); if (multicaster instanceof EditorEventMulticasterEx) { ((EditorEventMulticasterEx)multicaster).addPropertyChangeListener(propertyChangeListener, this); } ApplicationManager.getApplication().invokeLater(() -> { FocusUtil.addFocusOwnerListener(this, propertyChangeListener); updateStatus(); }, getProject().getDisposed()); }