]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/text/HTMLAnnotationHover.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / text / HTMLAnnotationHover.java
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
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;
14 import java.util.List;
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          * Creates a new HTML annotation hover.
32          *
33          * @param showLineNumber <code>true</code> if the line number should be shown when no annotation is found
34          * @since 3.4
35          */
36         public HTMLAnnotationHover(boolean showLineNumber) {
37                 super(showLineNumber);
38         }
39
40         /*
41          * Formats a message as HTML text.
42          */
43         @Override
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();
50         }
51
52         /*
53          * Formats several message as HTML text.
54          */
55         @Override
56         protected String formatMultipleMessages(List messages) {
57                 StringBuffer buffer= new StringBuffer();
58                 HTMLPrinter.addPageProlog(buffer);
59                 HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(JavaUIMessages.JavaAnnotationHover_multipleMarkersAtThisLine));
60
61                 HTMLPrinter.startBulletList(buffer);
62                 Iterator<?> e= messages.iterator();
63                 while (e.hasNext())
64                         HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent((String) e.next()));
65                 HTMLPrinter.endBulletList(buffer);
66
67                 HTMLPrinter.addPageEpilog(buffer);
68                 return buffer.toString();
69         }
70 }