mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-79908 Balloons should be displayed in a not-focused window
This commit is contained in:
@@ -410,7 +410,7 @@ public class EventLog implements Notifications {
|
||||
|
||||
RelativePoint target = EventLog.getProjectComponent(project).myConsole.getHyperlinkLocation(this);
|
||||
if (target != null) {
|
||||
Balloon balloon = NotificationsManagerImpl.createBalloon(myNotification, true, true, false);
|
||||
Balloon balloon = NotificationsManagerImpl.createBalloon(myNotification, true, true);
|
||||
Disposer.register(project, balloon);
|
||||
balloon.show(target, Balloon.Position.above);
|
||||
}
|
||||
|
||||
+35
-38
@@ -148,32 +148,18 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
|
||||
}
|
||||
|
||||
if (NotificationsConfigurationImpl.getNotificationsConfigurationImpl().SHOW_BALLOONS) {
|
||||
showWhenVisible(notification, project);
|
||||
}
|
||||
}
|
||||
|
||||
private static void showWhenVisible(final Notification notification, final Project project) {
|
||||
FrameStateManager.getInstance().getApplicationActive().doWhenDone(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (project != null) {
|
||||
if (project.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!project.isInitialized()) {
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showWhenVisible(notification, project);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showNotification(notification, project);
|
||||
}
|
||||
showNotification(notification, project);
|
||||
};
|
||||
if (project == null) {
|
||||
runnable.run();
|
||||
} else if (!project.isDisposed()) {
|
||||
StartupManager.getInstance(project).runWhenProjectIsInitialized(runnable);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static void showNotification(final Notification notification, @Nullable final Project project) {
|
||||
@@ -244,18 +230,33 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
|
||||
Window window = findWindowForBalloon(project);
|
||||
if (window instanceof IdeFrameImpl) {
|
||||
final ProjectManager projectManager = ProjectManager.getInstance();
|
||||
boolean noProjects = projectManager.getOpenProjects().length == 0;
|
||||
boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
|
||||
final Balloon balloon = createBalloon(notification, false, false, !sticky);
|
||||
final boolean noProjects = projectManager.getOpenProjects().length == 0;
|
||||
final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
|
||||
final Balloon balloon = createBalloon(notification, false, false);
|
||||
Disposer.register(project != null ? project : ApplicationManager.getApplication(), balloon);
|
||||
((IdeFrameImpl)window).getBalloonLayout().add(balloon);
|
||||
if (noProjects && NotificationDisplayType.BALLOON == displayType) {
|
||||
projectManager.addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
if (NotificationDisplayType.BALLOON == displayType) {
|
||||
FrameStateManager.getInstance().getApplicationActive().doWhenDone(new Runnable() {
|
||||
@Override
|
||||
public void projectOpened(Project project) {
|
||||
projectManager.removeProjectManagerListener(this);
|
||||
if (!balloon.isDisposed()) {
|
||||
((BalloonImpl)balloon).startFadeoutTimer(300);
|
||||
public void run() {
|
||||
if (balloon.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sticky) {
|
||||
((BalloonImpl)balloon).startFadeoutTimer(3000);
|
||||
}
|
||||
else //noinspection ConstantConditions
|
||||
if (noProjects) {
|
||||
projectManager.addProjectManagerListener(new ProjectManagerAdapter() {
|
||||
@Override
|
||||
public void projectOpened(Project project) {
|
||||
projectManager.removeProjectManagerListener(this);
|
||||
if (!balloon.isDisposed()) {
|
||||
((BalloonImpl)balloon).startFadeoutTimer(300);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -274,7 +275,7 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
|
||||
return frame;
|
||||
}
|
||||
|
||||
public static Balloon createBalloon(final Notification notification, final boolean showCallout, final boolean hideOnClickOutside, final boolean fadeOut) {
|
||||
public static Balloon createBalloon(final Notification notification, final boolean showCallout, final boolean hideOnClickOutside) {
|
||||
final JEditorPane text = new JEditorPane();
|
||||
text.setEditorKit(UIUtil.getHTMLEditorKit());
|
||||
|
||||
@@ -312,10 +313,6 @@ public class NotificationsManagerImpl extends NotificationsManager implements No
|
||||
.setHideOnAction(hideOnClickOutside)
|
||||
.setHideOnKeyOutside(hideOnClickOutside).setHideOnFrameResize(false);
|
||||
|
||||
if (fadeOut) {
|
||||
builder.setFadeoutTime(3000);
|
||||
}
|
||||
|
||||
final Balloon balloon = builder.createBalloon();
|
||||
balloon.addListener(new JBPopupAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.openapi.wm.impl;
|
||||
|
||||
import com.intellij.Patches;
|
||||
import com.intellij.ide.FrameStateManager;
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.ui.LafManager;
|
||||
import com.intellij.ide.ui.LafManagerListener;
|
||||
@@ -47,6 +48,7 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.*;
|
||||
import com.intellij.openapi.wm.ex.*;
|
||||
import com.intellij.openapi.wm.impl.commands.*;
|
||||
import com.intellij.ui.BalloonImpl;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.switcher.QuickAccessSettings;
|
||||
import com.intellij.ui.switcher.SwitchManager;
|
||||
@@ -1326,7 +1328,13 @@ public final class ToolWindowManagerImpl extends ToolWindowManagerEx implements
|
||||
final BalloonHyperlinkListener listenerWrapper = new BalloonHyperlinkListener(listener);
|
||||
final Balloon balloon =
|
||||
JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(text.replace("\n", "<br>"), actualIcon, type.getPopupBackground(), listenerWrapper)
|
||||
.setHideOnClickOutside(true).setHideOnFrameResize(false).createBalloon();
|
||||
.setHideOnClickOutside(false).setHideOnFrameResize(false).createBalloon();
|
||||
FrameStateManager.getInstance().getApplicationActive().doWhenDone(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((BalloonImpl)balloon).setHideOnClickOutside(true);
|
||||
}
|
||||
});
|
||||
listenerWrapper.myBalloon = balloon;
|
||||
myWindow2Balloon.put(toolWindowId, balloon);
|
||||
Disposer.register(balloon, new Disposable() {
|
||||
|
||||
@@ -17,7 +17,6 @@ package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.IdeEventQueue;
|
||||
import com.intellij.ide.IdeTooltip;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.ActionManager;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -28,7 +27,6 @@ import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.impl.ShadowBorderPainter;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindow;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
@@ -178,7 +176,7 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
|
||||
private boolean myDisposed;
|
||||
private final JComponent myContent;
|
||||
private final boolean myHideOnMouse;
|
||||
private boolean myHideOnMouse;
|
||||
private final boolean myHideOnKey;
|
||||
private boolean myHideOnAction;
|
||||
private final boolean myEnableCloseButton;
|
||||
@@ -713,6 +711,10 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
|
||||
return myVisible;
|
||||
}
|
||||
|
||||
public void setHideOnClickOutside(boolean hideOnMouse) {
|
||||
myHideOnMouse = hideOnMouse;
|
||||
}
|
||||
|
||||
public void setShowPointer(final boolean show) {
|
||||
myShowPointer = show;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user