void (@NotNull AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final IdeFocusManager manager = IdeFocusManager.getGlobalInstance(); if (!(manager instanceof FocusManagerImpl focusManager)) { return; } myActive = !myActive; if (myActive) { myFocusTracker = new AWTEventListener() { @Override public void eventDispatched(AWTEvent event) { if (event instanceof FocusEvent && event.getID() == FocusEvent.FOCUS_GAINED) { focusManager.recordFocusRequest(((FocusEvent)event).getComponent(), false); } } }; Toolkit.getDefaultToolkit().addAWTEventListener(myFocusTracker, AWTEvent.FOCUS_EVENT_MASK); } if (!myActive) { final List<FocusRequestInfo> requests = focusManager.getRequests(); new FocusTracesDialog(project, new ArrayList<>(requests)).show(); Toolkit.getDefaultToolkit().removeAWTEventListener(myFocusTracker); myFocusTracker = null; requests.clear(); } }