diff --git a/platform/platform-impl/src/com/intellij/notification/EventLog.java b/platform/platform-impl/src/com/intellij/notification/EventLog.java index 3a72da112979..d4b39dfdff33 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLog.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLog.java @@ -121,7 +121,7 @@ public class EventLog implements Notifications { return getLogModel(project).getStatusMessage(); } - public static LogEntry formatForLog(@NotNull final Notification notification) { + public static LogEntry formatForLog(@NotNull final Notification notification, String indent) { DocumentImpl logDoc = new DocumentImpl(true); AtomicBoolean showMore = new AtomicBoolean(false); Map links = new LinkedHashMap(); @@ -141,7 +141,7 @@ public class EventLog implements Notifications { String status = getStatusText(logDoc, showMore, lineSeparators, hasHtml); - indentNewLines(logDoc, lineSeparators, afterTitle, hasHtml); + indentNewLines(logDoc, lineSeparators, afterTitle, hasHtml, indent); ArrayList> list = new ArrayList>(); for (RangeMarker marker : links.keySet()) { @@ -165,7 +165,7 @@ public class EventLog implements Notifications { return new LogEntry(logDoc.getText(), status, list); } - private static void indentNewLines(DocumentImpl logDoc, List lineSeparators, RangeMarker afterTitle, boolean hasHtml) { + private static void indentNewLines(DocumentImpl logDoc, List lineSeparators, RangeMarker afterTitle, boolean hasHtml, String indent) { if (!hasHtml) { int i = -1; while (true) { @@ -187,8 +187,8 @@ public class EventLog implements Notifications { continue; } - logDoc.replaceString(start, separator.getEndOffset(), "\n\t"); - nextLineStart = start + 2; + logDoc.replaceString(start, separator.getEndOffset(), "\n" + indent); + nextLineStart = start + 1 + indent.length(); while (nextLineStart < logDoc.getTextLength() && Character.isWhitespace(logDoc.getCharsSequence().charAt(nextLineStart))) { logDoc.deleteString(nextLineStart, nextLineStart + 1); } diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java b/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java index f298cad20cdb..f4b45cd6f86c 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java @@ -38,6 +38,7 @@ import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.EditorPopupHandler; import com.intellij.util.text.DateFormatUtil; @@ -137,10 +138,11 @@ class EventLogConsole { if (notificationTime == null) { return; } - - append(document, DateFormatUtil.formatTimeWithSeconds(notificationTime) + " "); - EventLog.LogEntry pair = EventLog.formatForLog(notification); + String date = DateFormatUtil.formatTimeWithSeconds(notificationTime) + " "; + append(document, date); + + EventLog.LogEntry pair = EventLog.formatForLog(notification, StringUtil.repeatSymbol(' ', date.length())); final NotificationType type = notification.getType(); TextAttributesKey key = type == NotificationType.ERROR diff --git a/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java b/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java index 4e998c2833b0..a1e9e584c843 100644 --- a/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java +++ b/platform/platform-impl/src/com/intellij/notification/impl/actions/NotificationTestAction.java @@ -61,7 +61,7 @@ public class NotificationTestAction extends AnAction implements DumbAware { }; final Notification notification = new Notification(TEST_GROUP_ID, "This is a test notification", //"a", - "You can close this very very very very long notification by clicking this link. Long long long long. It should be long. Very long. Too long. And even longer.", + "You can
close this very

very very very long notification by clicking this link. Long long long long. It should be long. Very long. Too long. And even longer.", type, listener); messageBus.syncPublisher(Notifications.TOPIC).notify(notification); diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java index 3f90f74fd95d..53f1f9e0ff04 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/StatusPanel.java @@ -161,7 +161,7 @@ class StatusPanel extends JPanel { @Override public void run() { assert statusMessage != null; - String text = EventLog.formatForLog(statusMessage.first).status; + String text = EventLog.formatForLog(statusMessage.first, "").status; if (myDirty || System.currentTimeMillis() - statusMessage.second >= DateFormatUtil.MINUTE) { myTimeStart = text.length() + 1; text += " (" + StringUtil.decapitalize(DateFormatUtil.formatPrettyDateTime(statusMessage.second)) + ")"; diff --git a/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy b/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy index 4aea3283eb28..ffd1207a39cb 100644 --- a/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy +++ b/platform/platform-tests/testSrc/com/intellij/notification/EventLogTest.groovy @@ -30,17 +30,17 @@ class EventLogTest extends LightPlatformTestCase { } public void testHtmlEntities() { - def entry = EventLog.formatForLog(new Notification("xxx", "Title", "Hello world«»", NotificationType.ERROR)) + def entry = format("Title", "Hello world«»") assert entry.message == 'Title: Hello world<<>>' } public void testParseMultilineText() { - def entry = EventLog.formatForLog(new Notification("xxx", "Title", " " + + def entry = format("Title", " " + "first line
" + "second line
" + "third
" + "Action
" + - "", NotificationType.ERROR)) + "") assert entry.status == 'Title: first line second line third // Action' assert entry.message == '''Title \tfirst line @@ -52,13 +52,13 @@ class EventLogTest extends LightPlatformTestCase { } public void testInParagraph() { - def entry = EventLog.formatForLog(new Notification("xxx", "Title", "

message

", NotificationType.ERROR)) + def entry = format("Title", "

message

") assert entry.message == 'Title: message' assert entry.status == 'Title: message' } public void testJavaSeparators() { - def entry = EventLog.formatForLog(new Notification("xxx", "Title", "fst\nsnd", NotificationType.ERROR)) + def entry = format("Title", "fst\nsnd") assert entry.message == '''Title \tfst \tsnd''' @@ -71,7 +71,7 @@ class EventLogTest extends LightPlatformTestCase { } public void testMalformedLink() throws Exception { - def entry = EventLog.formatForLog(new Notification("xxx", 'link', "content", NotificationType.ERROR)) + def entry = format('link', "content") assert entry.message == 'link: content (show balloon)' } @@ -96,7 +96,7 @@ class EventLogTest extends LightPlatformTestCase { } EventLog.LogEntry format(String title, String content) { - EventLog.formatForLog(new Notification("xxx", title, content, NotificationType.ERROR)) + EventLog.formatForLog(new Notification("xxx", title, content, NotificationType.ERROR), '\t') } public void testManyNewlines() throws Exception {