From cd904178ec4465087f3c69b3537131b42e3031ab Mon Sep 17 00:00:00 2001 From: Pavel Fatin Date: Tue, 6 Mar 2012 16:31:18 +0400 Subject: [PATCH] ITNReporter: check whether parent component of message dialog is showing --- .../com/intellij/diagnostic/ITNReporter.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.java b/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.java index 7293f36dff5e..2bb2486a4dc9 100644 --- a/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.java +++ b/platform/platform-impl/src/com/intellij/diagnostic/ITNReporter.java @@ -43,6 +43,7 @@ import com.intellij.util.Consumer; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; +import javax.swing.*; import javax.swing.event.HyperlinkEvent; import java.awt.*; @@ -68,7 +69,7 @@ public class ITNReporter extends ErrorReportSubmitter { String additionalInfo, Component parentComponent, Consumer consumer) { - return sendError(events [0], additionalInfo, parentComponent, consumer); + return sendError(events[0], additionalInfo, parentComponent, consumer); } /** @@ -194,11 +195,10 @@ public class ITNReporter extends ErrorReportSubmitter { ApplicationInfoEx appInfo = (ApplicationInfoEx) ApplicationManager.getApplication().getComponent(ApplicationInfo.class); String message = DiagnosticBundle.message( appInfo.isEAP() ? "error.report.new.eap.build.message" : "error.report.new.build.message", e.getMessage()); - Messages.showMessageDialog(parentComponent, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()); + showMessageDialog(parentComponent, project, message, CommonBundle.getWarningTitle(), Messages.getWarningIcon()); callback.consume(new SubmittedReportInfo(null, "0", SubmittedReportInfo.SubmissionStatus.FAILED)); } - else if (Messages.showYesNoDialog(parentComponent, msg, - ReportMessages.ERROR_REPORT, Messages.getErrorIcon()) != 0) { + else if (showYesNoDialog(parentComponent, project, msg, ReportMessages.ERROR_REPORT, Messages.getErrorIcon()) != 0) { callback.consume(new SubmittedReportInfo(null, "0", SubmittedReportInfo.SubmissionStatus.FAILED)); } else { @@ -225,4 +225,20 @@ public class ITNReporter extends ErrorReportSubmitter { }); return true; } + + private static void showMessageDialog(Component parentComponent, Project project, String message, String title, Icon icon) { + if (parentComponent.isShowing()) { + Messages.showMessageDialog(parentComponent, message, title, icon); + } else { + Messages.showMessageDialog(project, message, title, icon); + } + } + + private static int showYesNoDialog(Component parentComponent, Project project, String message, String title, Icon icon) { + if (parentComponent.isShowing()) { + return Messages.showYesNoDialog(parentComponent, message, title, icon); + } else { + return Messages.showYesNoDialog(project, message, title, icon); + } + } }