private static @Nullable Balloon notifyByBalloon(Notification notification,
                                                   NotificationDisplayType displayType,
                                                   @Nullable Project project) {
    if (isDummyEnvironment()) {
      return null;
    }
    if (!notification.canShowFor(project)) {
      return null;
    }

    Window window = findWindowForBalloon(project);
    if (!(window instanceof IdeFrame)) {
      return null;
    }

    BalloonLayout layout = ((IdeFrame)window).getBalloonLayout();
    if (layout == null) {
      return null;
    }

    Ref<BalloonLayoutData> layoutDataRef = new Ref<>();
    if (project == null || project.isDefault()) {
      BalloonLayoutData layoutData = new BalloonLayoutData();
      layoutData.groupId = "";
      layoutData.welcomeScreen = layout instanceof WelcomeBalloonLayoutImpl;
      layoutData.type = notification.getType();
      layoutDataRef.set(layoutData);
    }
    else {
      BalloonLayoutData.MergeInfo mergeData = ((BalloonLayoutImpl)layout).preMerge(notification);
      if (mergeData != null) {
        BalloonLayoutData layoutData = new BalloonLayoutData();
        layoutData.mergeData = mergeData;
        layoutDataRef.set(layoutData);
      }
    }

    Disposable disposable = project != null ? project : ApplicationManager.getApplication();
    Balloon balloon = createBalloon((IdeFrame)window, notification, false, false, layoutDataRef, disposable);

    if (notification.isExpired()) {
      return null;
    }

    BalloonLayoutData layoutData = layoutDataRef.get();
    layout.add(balloon, layoutData);
    if (balloon.isDisposed()) {
      return null;
    }
    if (layoutData != null) {
      layoutData.project = project;
    }

    if (balloon instanceof BalloonImpl) {
      frameActivateBalloonListener(balloon, () -> {
        if (!balloon.isDisposed()) {
          int delay = displayType == NotificationDisplayType.STICKY_BALLOON ? 300000 : 10000;
          ((BalloonImpl)balloon).startSmartFadeoutTimer(delay);
        }
      });
    }

    NotificationCollector.getInstance().logBalloonShown(project, displayType, notification, layoutData != null && layoutData.isExpandable);

    return balloon;
  }
private static @Nullable Balloon notifyByBalloon(Notification notification,
                                                   NotificationDisplayType displayType,
                                                   @Nullable Project project)