void (@NotNull FileEditorManagerEvent event) { if (!isValid()) return; ApplicationManager.getApplication().invokeLater(() -> { if (myUndoHelper.isShowing() && !getComponent().isShowing()) { deselectNotify(); } else if (!myUndoHelper.isShowing() && getComponent().isShowing()) { selectNotify(); } }); FileEditor oldEditor = event.getOldEditor(); FileEditor newEditor = event.getNewEditor(); if (oldEditor == null || newEditor == null) return; if (oldEditor.getComponent().isShowing() && newEditor.getComponent().isShowing()) return; if (PerspectiveFileEditor.this.equals(oldEditor)) { if (newEditor instanceof TextEditor) { ensureInitialized(); DomElement selectedDomElement = getSelectedDomElement(); if (selectedDomElement != null) { setSelectionInTextEditor((TextEditor)newEditor, selectedDomElement); } } } else if (PerspectiveFileEditor.this.equals(newEditor)) { if (oldEditor instanceof TextEditor) { DomElement element = getSelectedDomElementFromTextEditor((TextEditor)oldEditor); if (element != null) { ensureInitialized(); setSelectedDomElement(element); } } else if (oldEditor instanceof PerspectiveFileEditor) { ensureInitialized(); DomElement selectedDomElement = ((PerspectiveFileEditor)oldEditor).getSelectedDomElement(); if (selectedDomElement != null) { setSelectedDomElement(selectedDomElement); } } } }