private void highlightNotification(
      final Notification notification, String message, final int line1, final int line2) {

    final MarkupModel markupModel = myLogEditor.getValue().getMarkupModel();
    TextAttributes bold = new TextAttributes(null, null, null, null, Font.BOLD);
    final List<RangeHighlighter> lineColors = new ArrayList<RangeHighlighter>();
    for (int line = line1; line < line2; line++) {
      final RangeHighlighter lineHighlighter =
          markupModel.addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, bold);
      Color color =
          notification.getType() == NotificationType.ERROR
              ? JBColor.RED
              : notification.getType() == NotificationType.WARNING ? JBColor.YELLOW : JBColor.GREEN;
      lineHighlighter.setErrorStripeMarkColor(color);
      lineHighlighter.setErrorStripeTooltip(message);
      lineColors.add(lineHighlighter);
    }

    final Runnable removeHandler =
        new Runnable() {
          @Override
          public void run() {
            for (RangeHighlighter color : lineColors) {
              markupModel.removeHighlighter(color);
            }

            TextAttributes attributes =
                EditorColorsManager.getInstance()
                    .getGlobalScheme()
                    .getAttributes(ConsoleViewContentType.LOG_EXPIRED_ENTRY);
            for (int line = line1; line < line2; line++) {
              markupModel.addLineHighlighter(line, HighlighterLayer.CARET_ROW + 1, attributes);
            }

            TextAttributes italic = new TextAttributes(null, null, null, null, Font.ITALIC);
            for (int line = line1; line < line2; line++) {
              for (RangeHighlighter highlighter :
                  myHyperlinkSupport.getValue().findAllHyperlinksOnLine(line)) {
                markupModel.addRangeHighlighter(
                    highlighter.getStartOffset(),
                    highlighter.getEndOffset(),
                    HighlighterLayer.CARET_ROW + 2,
                    italic,
                    HighlighterTargetArea.EXACT_RANGE);
                myHyperlinkSupport.getValue().removeHyperlink(highlighter);
              }
            }
          }
        };
    if (!notification.isExpired()) {
      myProjectModel.removeHandlers.put(notification, removeHandler);
    } else {
      removeHandler.run();
    }
  }
 public void actionPerformed(final AnActionEvent e) {
   LogModel model = myConsole.myProjectModel;
   for (Notification notification : model.getNotifications()) {
     notification.expire();
     model.removeNotification(notification);
   }
   model.setStatusMessage(null, 0);
   final Editor editor = e.getData(CommonDataKeys.EDITOR);
   if (editor != null) {
     editor.getDocument().deleteString(0, editor.getDocument().getTextLength());
   }
 }
  void doPrintNotification(final Notification notification) {
    Editor editor = myLogEditor.getValue();
    if (editor.isDisposed()) {
      return;
    }

    Document document = editor.getDocument();
    boolean scroll =
        document.getTextLength() == editor.getCaretModel().getOffset()
            || !editor.getContentComponent().hasFocus();

    Long notificationTime = myProjectModel.getNotificationTime(notification);
    if (notificationTime == null) {
      return;
    }

    String date = DateFormatUtil.formatTimeWithSeconds(notificationTime) + " ";
    append(document, date);

    int startLine = document.getLineCount() - 1;

    EventLog.LogEntry pair =
        EventLog.formatForLog(notification, StringUtil.repeatSymbol(' ', date.length()));

    final NotificationType type = notification.getType();
    TextAttributesKey key =
        type == NotificationType.ERROR
            ? ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY
            : type == NotificationType.INFORMATION
                ? ConsoleViewContentType.NORMAL_OUTPUT_KEY
                : ConsoleViewContentType.LOG_WARNING_OUTPUT_KEY;

    int msgStart = document.getTextLength();
    String message = pair.message;
    append(document, message);

    TextAttributes attributes =
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key);
    int layer = HighlighterLayer.CARET_ROW + 1;
    editor
        .getMarkupModel()
        .addRangeHighlighter(
            msgStart,
            document.getTextLength(),
            layer,
            attributes,
            HighlighterTargetArea.EXACT_RANGE);

    for (Pair<TextRange, HyperlinkInfo> link : pair.links) {
      myHyperlinkSupport
          .getValue()
          .addHyperlink(
              link.first.getStartOffset() + msgStart,
              link.first.getEndOffset() + msgStart,
              null,
              link.second);
    }

    append(document, "\n");

    if (scroll) {
      editor.getCaretModel().moveToOffset(document.getTextLength());
      editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
    }

    if (notification.isImportant()) {
      highlightNotification(notification, pair.status, startLine, document.getLineCount() - 1);
    }
  }