KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > text > HTMLAnnotationHover


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.ui.text;
12
13 import java.util.Iterator JavaDoc;
14 import java.util.List JavaDoc;
15
16 import org.eclipse.jface.internal.text.html.HTMLPrinter;
17
18 import org.eclipse.jface.text.source.DefaultAnnotationHover;
19
20 import org.eclipse.jdt.internal.ui.JavaUIMessages;
21
22 /**
23  * Determines all markers for the given line and collects, concatenates, and formats
24  * returns their messages in HTML.
25  *
26  * @since 3.2
27  */

28 public class HTMLAnnotationHover extends DefaultAnnotationHover {
29
30     /*
31      * Formats a message as HTML text.
32      */

33     protected String JavaDoc formatSingleMessage(String JavaDoc message) {
34         StringBuffer JavaDoc buffer= new StringBuffer JavaDoc();
35         HTMLPrinter.addPageProlog(buffer);
36         HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(message));
37         HTMLPrinter.addPageEpilog(buffer);
38         return buffer.toString();
39     }
40
41     /*
42      * Formats several message as HTML text.
43      */

44     protected String JavaDoc formatMultipleMessages(List JavaDoc messages) {
45         StringBuffer JavaDoc buffer= new StringBuffer JavaDoc();
46         HTMLPrinter.addPageProlog(buffer);
47         HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(JavaUIMessages.JavaAnnotationHover_multipleMarkersAtThisLine));
48
49         HTMLPrinter.startBulletList(buffer);
50         Iterator JavaDoc e= messages.iterator();
51         while (e.hasNext())
52             HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent((String JavaDoc) e.next()));
53         HTMLPrinter.endBulletList(buffer);
54
55         HTMLPrinter.addPageEpilog(buffer);
56         return buffer.toString();
57     }
58 }
59
Popular Tags