From df1def9dc9be51a7f98f5909837b29b13494bf3f Mon Sep 17 00:00:00 2001 From: Konstantin Kolosovsky Date: Thu, 25 Jul 2013 18:06:03 +0400 Subject: [PATCH] IDEA-110144 --- .../openapi/vcs/changes/ui/CommitHelper.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java index 44e5e0179cb9..1735ba563616 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/ui/CommitHelper.java @@ -119,7 +119,7 @@ public class CommitHelper { ProgressManager.getInstance().runProcessWithProgressSynchronously(action, myActionName, true, myProject); boolean success = doesntContainErrors(processor.getVcsExceptions()); if (success) { - reportSuccess(processor); + reportResult(processor); } return success; } @@ -140,7 +140,7 @@ public class CommitHelper { @Override public NotificationInfo notifyFinished() { if (myCustomResultHandler == null) { - String text = reportSuccess(processor); + String text = reportResult(processor); return new NotificationInfo("VCS Commit", "VCS Commit Finished", text, true); } return null; @@ -182,7 +182,7 @@ public class CommitHelper { } } - private String reportSuccess(GeneralCommitProcessor processor) { + private String reportResult(GeneralCommitProcessor processor) { final List changesFailedToCommit = processor.getChangesFailedToCommit(); int failed = changesFailedToCommit.size(); @@ -197,10 +197,18 @@ public class CommitHelper { content.append("\n"); content.append(s); } - VcsBalloonProblemNotifier.NOTIFICATION_GROUP.createNotification(content.toString(), NotificationType.INFORMATION).notify(myProject); + NotificationType notificationType = resolveNotificationType(processor); + VcsBalloonProblemNotifier.NOTIFICATION_GROUP.createNotification(content.toString(), notificationType).notify(myProject); return text; } + private static NotificationType resolveNotificationType(@NotNull GeneralCommitProcessor processor) { + boolean hasExceptions = !processor.getVcsExceptions().isEmpty(); + boolean hasOnlyWarnings = doesntContainErrors(processor.getVcsExceptions()); + + return hasExceptions ? (hasOnlyWarnings ? NotificationType.WARNING : NotificationType.ERROR) : NotificationType.INFORMATION; + } + /* Commit message is passed to NotificationManagerImpl#doNotify and displayed as HTML. Thus HTML tag braces (< and >) should be escaped,