use of com.intellij.openapi.wm.impl.FocusRequestInfo in project intellij-community by JetBrains.
the class FocusTracesAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getData(CommonDataKeys.PROJECT);
final IdeFocusManager manager = IdeFocusManager.getGlobalInstance();
if (!(manager instanceof FocusManagerImpl))
return;
final FocusManagerImpl focusManager = (FocusManagerImpl) manager;
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();
}
}
Aggregations