void (final FocusEvent e) { if (myPanel.allowNavItemsFocus()) { // If focus reaches anything in nav bar panel, ignore the event if (UIUtil.isAncestor(myPanel, e.getOppositeComponent())) { return; } } if (myPanel.getProject().isDisposed()) { myPanel.setContextComponent(null); myPanel.hideHint(); return; } final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent()); shouldFocusEditor = dialog != null; if (dialog != null) { Disposable parent = dialog.getDisposable(); Disposable onParentDispose = () -> { if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) { shouldFocusEditor = false; } }; if (dialog.isDisposed()) { Disposer.dispose(onParentDispose); } else { Disposer.register(parent, onParentDispose); } } // required invokeLater since in current call sequence KeyboardFocusManager is not initialized yet // but future focused component //noinspection SSBasedInspection SwingUtilities.invokeLater(() -> processFocusLost(e)); }