diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 39937c24bb2a..de97746dcd77 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -682,7 +682,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo } protected EditorEx createRealEditor() { - final EditorEx editor = ConsoleViewUtil.setupConsoleEditor(myProject, true); + final EditorEx editor = ConsoleViewUtil.setupConsoleEditor(myProject, true, false); editor.getDocument().addDocumentListener(new DocumentListener() { public void beforeDocumentChange(DocumentEvent event) { diff --git a/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java b/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java index a96912ad2be2..50abce57fe45 100644 --- a/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java +++ b/platform/platform-impl/src/com/intellij/execution/impl/ConsoleViewUtil.java @@ -33,13 +33,13 @@ import java.awt.*; * @author peter */ public class ConsoleViewUtil { - public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown) { + public static EditorEx setupConsoleEditor(Project project, final boolean foldingOutlineShown, final boolean lineMarkerAreaShown) { EditorEx editor = (EditorEx) EditorFactory .getInstance().createViewer(((EditorFactoryImpl)EditorFactory.getInstance()).createDocument(true), project); editor.setSoftWrapAppliancePlace(SoftWrapAppliancePlaces.CONSOLE); final EditorSettings editorSettings = editor.getSettings(); - editorSettings.setLineMarkerAreaShown(false); + editorSettings.setLineMarkerAreaShown(lineMarkerAreaShown); editorSettings.setIndentGuidesShown(false); editorSettings.setLineNumbersShown(false); editorSettings.setFoldingOutlineShown(foldingOutlineShown); diff --git a/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java b/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java index 369213ea0beb..414ae6b3c088 100644 --- a/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java +++ b/platform/platform-impl/src/com/intellij/notification/EventLogConsole.java @@ -28,12 +28,13 @@ import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.EditorFactory; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.editor.event.EditorMouseEvent; -import com.intellij.openapi.editor.markup.HighlighterLayer; -import com.intellij.openapi.editor.markup.HighlighterTargetArea; +import com.intellij.openapi.editor.ex.EditorMarkupModel; +import com.intellij.openapi.editor.markup.*; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.popup.Balloon; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.Pair; import com.intellij.ui.awt.RelativePoint; import com.intellij.util.EditorPopupHandler; @@ -54,7 +55,7 @@ class EventLogConsole { EventLogConsole(@NotNull Project project, LogModel model) { myProjectModel = model; - myLogEditor = ConsoleViewUtil.setupConsoleEditor(project, false); + myLogEditor = ConsoleViewUtil.setupConsoleEditor(project, false, true); Disposer.register(project, new Disposable() { @Override public void dispose() { @@ -62,6 +63,9 @@ class EventLogConsole { } }); + ((EditorMarkupModel) myLogEditor.getMarkupModel()).setErrorStripeVisible(true); + + myLogEditor.addEditorMouseListener(new EditorPopupHandler() { public void invokePopup(final EditorMouseEvent event) { final ActionManager actionManager = ActionManager.getInstance(); @@ -120,7 +124,8 @@ class EventLogConsole { : ConsoleViewContentType.WARNING_OUTPUT; int msgStart = document.getTextLength(); - append(document, pair.first); + String message = pair.first; + append(document, message); myLogEditor.getMarkupModel() .addRangeHighlighter(msgStart, document.getTextLength(), HighlighterLayer.CARET_ROW + 1, contentType.getAttributes(), HighlighterTargetArea.EXACT_RANGE); @@ -158,6 +163,66 @@ class EventLogConsole { myLogEditor.getCaretModel().moveToOffset(document.getTextLength()); myLogEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); } + + if (notification.isImportant()) { + highlightNotification(notification, message, document.getLineCount() - 2); + } + } + + private void highlightNotification(final Notification notification, + String message, final int line) { + TextAttributes attr = new TextAttributes(null, null, null, null, Font.BOLD); + final RangeHighlighter lineHighlighter = myLogEditor.getMarkupModel().addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, attr); + Color color = notification.getType() == NotificationType.ERROR + ? Color.red + : notification.getType() == NotificationType.WARNING ? Color.yellow : Color.green; + lineHighlighter.setErrorStripeMarkColor(color); + lineHighlighter.setErrorStripeTooltip(message); + lineHighlighter.setGutterIconRenderer(new GutterIconRenderer() { + @NotNull + @Override + public Icon getIcon() { + return IconLoader.getIcon("/general/reset.png"); + } + + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Override + public int hashCode() { + return 0; + } + + @Override + public String getTooltipText() { + return "Mark as read"; + } + + @Override + public boolean isNavigateAction() { + return true; + } + + @Override + public AnAction getClickAction() { + return new AnAction() { + @Override + public void actionPerformed(AnActionEvent e) { + myProjectModel.removeNotification(notification); + } + }; + } + }); + + myProjectModel.removeHandlers.put(notification, new Runnable() { + @Override + public void run() { + myLogEditor.getMarkupModel().removeHighlighter(lineHighlighter); + } + }); } public Editor getConsoleEditor() { diff --git a/platform/platform-impl/src/com/intellij/notification/LogModel.java b/platform/platform-impl/src/com/intellij/notification/LogModel.java index d626f73e8f53..3f01c6fc9588 100644 --- a/platform/platform-impl/src/com/intellij/notification/LogModel.java +++ b/platform/platform-impl/src/com/intellij/notification/LogModel.java @@ -21,11 +21,13 @@ import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Condition; import com.intellij.openapi.wm.StatusBar; import com.intellij.util.containers.ContainerUtil; +import gnu.trove.THashMap; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Map; /** * @author peter @@ -34,6 +36,7 @@ public class LogModel { private final List myNotifications = new ArrayList(); private Notification myStatusMessage; private final Project myProject; + final Map removeHandlers = new THashMap(); LogModel(@Nullable Project project) { myProject = project; @@ -88,6 +91,12 @@ public class LogModel { synchronized (myNotifications) { myNotifications.remove(notification); } + + Runnable handler = removeHandlers.remove(notification); + if (handler != null) { + handler.run(); + } + if (notification == getStatusMessage() && notification.isImportant()) { ArrayList notifications = getNotifications(); Collections.reverse(notifications); @@ -99,4 +108,5 @@ public class LogModel { })); } } + }