1 /*******************************************************************************
2 * Copyright (c) 2000, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.text;
13 import java.util.Iterator;
14 import java.util.List;
16 import org.eclipse.jface.internal.text.html.HTMLPrinter;
18 import org.eclipse.jface.text.source.DefaultAnnotationHover;
20 import org.eclipse.jdt.internal.ui.JavaUIMessages;
23 * Determines all markers for the given line and collects, concatenates, and formats
24 * returns their messages in HTML.
28 public class HTMLAnnotationHover extends DefaultAnnotationHover {
31 * Creates a new HTML annotation hover.
33 * @param showLineNumber <code>true</code> if the line number should be shown when no annotation is found
36 public HTMLAnnotationHover(boolean showLineNumber) {
37 super(showLineNumber);
41 * Formats a message as HTML text.
44 protected String formatSingleMessage(String message) {
45 StringBuffer buffer= new StringBuffer();
46 HTMLPrinter.addPageProlog(buffer);
47 HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
48 HTMLPrinter.addPageEpilog(buffer);
49 return buffer.toString();
53 * Formats several message as HTML text.
56 protected String formatMultipleMessages(List messages) {
57 StringBuffer buffer= new StringBuffer();
58 HTMLPrinter.addPageProlog(buffer);
59 HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(JavaUIMessages.JavaAnnotationHover_multipleMarkersAtThisLine));
61 HTMLPrinter.startBulletList(buffer);
62 Iterator<?> e= messages.iterator();
64 HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent((String) e.next()));
65 HTMLPrinter.endBulletList(buffer);
67 HTMLPrinter.addPageEpilog(buffer);
68 return buffer.toString();