diff --git a/platform/platform-api/src/com/intellij/openapi/ui/popup/util/PopupUtil.java b/platform/platform-api/src/com/intellij/openapi/ui/popup/util/PopupUtil.java index ae9026859ec5..8126071cd3e9 100644 --- a/platform/platform-api/src/com/intellij/openapi/ui/popup/util/PopupUtil.java +++ b/platform/platform-api/src/com/intellij/openapi/ui/popup/util/PopupUtil.java @@ -15,6 +15,7 @@ */ package com.intellij.openapi.ui.popup.util; +import com.intellij.openapi.Disposable; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; @@ -136,15 +137,15 @@ public class PopupUtil { final Project project = projects == null || projects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : projects[0]; final JFrame jFrame = WindowManager.getInstance().getFrame(project); if (jFrame != null) { - showBalloonForComponent(jFrame, message, type, true); + showBalloonForComponent(jFrame, message, type, true, project); } else { LOG.info("Can not get component to show message: " + message); } return; } - showBalloonForComponent(frame.getComponent(), message, type, true); + showBalloonForComponent(frame.getComponent(), message, type, true, frame.getProject()); } else { - showBalloonForComponent(targetWindow, message, type, true); + showBalloonForComponent(targetWindow, message, type, true, null); } } }; @@ -152,9 +153,9 @@ public class PopupUtil { } public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type, - final boolean atTop) { + final boolean atTop, @Nullable final Disposable disposable) { BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, type, null); - balloonBuilder.setDisposable(ApplicationManager.getApplication()); + balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable); Balloon balloon = balloonBuilder.createBalloon(); Dimension size = component.getSize(); Balloon.Position position; diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java index b5a636473a27..591cbd1a6268 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/impl/VcsHistoryDialog.java @@ -228,7 +228,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider { @Override public void run() { if (! VcsHistoryDialog.this.isShowing()) return; - PopupUtil.showBalloonForComponent(VcsHistoryDialog.this.getRootPane(), canNoLoadMessage(e), MessageType.ERROR, true); + PopupUtil.showBalloonForComponent(VcsHistoryDialog.this.getRootPane(), canNoLoadMessage(e), MessageType.ERROR, true, myProject); } }); } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java index 206ab80e43f5..908a3d9f8433 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/ui/VcsBalloonProblemNotifier.java @@ -22,20 +22,13 @@ import com.intellij.notification.NotificationType; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; -import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.ui.MessageType; -import com.intellij.openapi.ui.popup.util.PopupUtil; import com.intellij.openapi.util.NamedRunnable; import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager; -import com.intellij.openapi.wm.IdeFocusManager; -import com.intellij.openapi.wm.IdeFrame; -import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import javax.swing.*; import javax.swing.event.HyperlinkEvent; -import java.awt.*; /** * Shows a notification balloon over one of version control related tool windows: Changes View or Version Control View. @@ -126,37 +119,4 @@ public class VcsBalloonProblemNotifier implements Runnable { } notification.notify(myProject.isDefault() ? null : myProject); } - - public static void showBalloonForActiveComponent(@NotNull final String message, final MessageType type) { - Runnable runnable = new Runnable() { - public void run() { - Window[] windows = Window.getWindows(); - Window targetWindow = null; - for (Window each : windows) { - if (each.isActive()) { - targetWindow = each; - break; - } - } - - if (targetWindow == null) { - targetWindow = JOptionPane.getRootFrame(); - } - - if (targetWindow == null) { - final IdeFrame frame = IdeFocusManager.findInstance().getLastFocusedFrame(); - if (frame == null) { - final Project[] projects = ProjectManager.getInstance().getOpenProjects(); - showOverChangesView(projects == null || projects.length == 0 ? ProjectManager.getInstance().getDefaultProject() : projects[0], - message, type); - return; - } - PopupUtil.showBalloonForComponent(frame.getComponent(), message, type, true); - } else { - PopupUtil.showBalloonForComponent(targetWindow, message, type, true); - } - } - }; - UIUtil.invokeLaterIfNeeded(runnable); - } }