Search in sources :

Example 1 with WelcomeBalloonLayoutImpl

use of com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl in project intellij-community by JetBrains.

the class NotificationsManagerImpl method notifyByBalloon.

@Nullable
private static Balloon notifyByBalloon(@NotNull final Notification notification, @NotNull final NotificationDisplayType displayType, @Nullable final Project project) {
    if (isDummyEnvironment())
        return null;
    Window window = findWindowForBalloon(project);
    if (window instanceof IdeFrame) {
        BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
        if (layout == null)
            return null;
        final ProjectManager projectManager = ProjectManager.getInstance();
        final boolean noProjects = projectManager.getOpenProjects().length == 0;
        final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
        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);
            }
        }
        final Balloon balloon = createBalloon((IdeFrame) window, notification, false, false, layoutDataRef, project != null ? project : ApplicationManager.getApplication());
        if (notification.isExpired()) {
            return null;
        }
        layout.add(balloon, layoutDataRef.get());
        if (balloon.isDisposed()) {
            return null;
        }
        if (layoutDataRef.get() != null) {
            layoutDataRef.get().project = project;
        }
        ((BalloonImpl) balloon).startFadeoutTimer(0);
        if (NotificationDisplayType.BALLOON == displayType) {
            FrameStateManager.getInstance().getApplicationActive().doWhenDone(() -> {
                if (!sticky && !balloon.isDisposed()) {
                    ((BalloonImpl) balloon).startSmartFadeoutTimer(10000);
                }
            });
        }
        return balloon;
    }
    return null;
}
Also used : IdeFrame(com.intellij.openapi.wm.IdeFrame) WelcomeBalloonLayoutImpl(com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl) ProjectManager(com.intellij.openapi.project.ProjectManager) Ref(com.intellij.openapi.util.Ref) WelcomeBalloonLayoutImpl(com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

ProjectManager (com.intellij.openapi.project.ProjectManager)1 Ref (com.intellij.openapi.util.Ref)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1 WelcomeBalloonLayoutImpl (com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl)1 Nullable (org.jetbrains.annotations.Nullable)1