public void focusGained(final FocusEvent e) { if (e.getOppositeComponent() == null && shouldFocusEditor) { shouldFocusEditor = false; ToolWindowManager.getInstance(myPanel.getProject()).activateEditorComponent(); return; } myPanel.updateItems(); final List<NavBarItem> items = myPanel.getItems(); if (!myPanel.isInFloatingMode() && items.size() > 0) { myPanel.setContextComponent(items.get(items.size() - 1)); } else { myPanel.setContextComponent(null); } }
public void focusLost(final FocusEvent e) { if (myPanel.getProject().isDisposed()) { myPanel.setContextComponent(null); myPanel.hideHint(); return; } final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent()); shouldFocusEditor = dialog != null; if (dialog != null) { Disposer.register( dialog.getDisposable(), new Disposable() { @Override public void dispose() { if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) { shouldFocusEditor = false; } } }); } // required invokeLater since in current call sequence KeyboardFocusManager is not initialized // yet // but future focused component //noinspection SSBasedInspection SwingUtilities.invokeLater( new Runnable() { public void run() { processFocusLost(e); } }); }
private void processFocusLost(FocusEvent e) { final Component opposite = e.getOppositeComponent(); if (myPanel.isInFloatingMode() && opposite != null && DialogWrapper.findInstance(opposite) != null) { myPanel.hideHint(); return; } final boolean nodePopupInactive = !myPanel.isNodePopupActive(); boolean childPopupInactive = !JBPopupFactory.getInstance().isChildPopupFocused(myPanel); if (nodePopupInactive && childPopupInactive) { if (opposite != null && opposite != myPanel && !myPanel.isAncestorOf(opposite) && !e.isTemporary()) { myPanel.setContextComponent(null); myPanel.hideHint(); } } myPanel.updateItems(); }