void (Document document) { if (myDocument != null) { uninstallDocumentListener(true); } myDocument = document; installDocumentListener(); Editor editor = getEditor(); if (editor != null) { boolean wasFocused = isFocusOwner(); EditorEx newEditor = createEditor(); scheduleEditorRelease(); myEditor = newEditor; add(newEditor.getComponent(), BorderLayout.CENTER); if (myNextFocusable != null) { newEditor.getContentComponent().setNextFocusableComponent(myNextFocusable); myNextFocusable = null; } if (wasFocused) { IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> requestFocus()); } releaseScheduledEditors(); validate(); } }