DataContext () { IdeFocusManager focusManager = IdeFocusManager.findInstance(); Component focusedComponent = focusManager.getFocusOwner(); Window ideWindow = focusManager.getLastFocusedIdeWindow(); return ideWindow == focusedComponent || focusedComponent == focusManager.getLastFocusedFor(ideWindow) ? DataManager.getInstance().getDataContext(focusedComponent) : DataManager.getInstance().getDataContext(); }