private static @Nullable Project getCurrentContextProject() {
    final List<Project> openProjects = getOpenProjects();
    if (openProjects.isEmpty()) {
      return null;
    }
    if (openProjects.size() == 1) {
      return openProjects.get(0);
    }

    Project project = null;
    if (!GraphicsEnvironment.isHeadless()) {
      Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
      if (window == null) {
        window = ComponentUtil.getActiveWindow();
      }

      Component component = ComponentUtil.findUltimateParent(window);
      if (component instanceof IdeFrame) {
        project = ((IdeFrame)component).getProject();
      }
    }

    return isValidProject(project)? project : null;
  }
private static @Nullable Project getCurrentContextProject()