KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > javadoc > JavaDocSuggestionPerformer


1 package org.netbeans.modules.tasklist.javadoc;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.List JavaDoc;
5 import org.netbeans.modules.tasklist.client.Suggestion;
6 import org.netbeans.modules.tasklist.client.SuggestionPerformer;
7 import org.netbeans.modules.tasklist.core.TLUtils;
8 import org.netbeans.modules.tasklist.javadoc.ext.JavadocProxy;
9 import org.openide.ErrorManager;
10 import org.openide.loaders.DataObject;
11 import org.openide.src.SourceException;
12 import org.openide.util.NbBundle;
13
14 /**
15  * Fixes JavaDoc errors
16  *
17  * @author TODO
18  * @author tl
19  */

20 public class JavaDocSuggestionPerformer implements SuggestionPerformer {
21     private DataObject dobj;
22     private JavadocProxy.ElementProxy element;
23     
24     /**
25      * Constructor
26      *
27      * @param element JavaDoc element
28      * @param env a suggestion context
29      */

30     public JavaDocSuggestionPerformer(JavadocProxy.ElementProxy element,
31     DataObject dobj) {
32         this.element = element;
33         this.dobj = dobj;
34     }
35     
36     public boolean hasConfirmation() {
37         return true;
38     }
39     
40     public Object JavaDoc getConfirmation(Suggestion s) {
41         String JavaDoc filename = dobj.getPrimaryFile().getNameExt();
42
43         StringBuffer JavaDoc sb = new StringBuffer JavaDoc(1000);
44         sb.append("<html><body><ul>"); // NOI18N
45
List JavaDoc resolutionList = element.getResolutionList();
46         Iterator JavaDoc it = resolutionList.iterator();
47         while (it.hasNext()) {
48             String JavaDoc resolution = it.next().toString();
49             sb.append("<li>"); // NOI18N
50
TLUtils.appendHTMLString(sb, resolution);
51         }
52         sb.append("</ul></body></html>"); // NOI18N
53
String JavaDoc afterContents = sb.toString();
54
55         String JavaDoc beforeDesc = NbBundle.getMessage(
56             JavaDocSuggestionPerformer.class, "ConfPanelAbove"); // NOI18N
57
sb.setLength(0);
58         sb.append("<html><body><i>/** "); // NOI18N
59
TLUtils.appendHTMLString(
60             sb,element.getJavaDoc().getRawText());
61         sb.append("*/</i></body></html>"); // NOI18N
62
String JavaDoc beforeContents = sb.toString();
63         String JavaDoc afterDesc = NbBundle.getMessage(
64             DocSuggester.class, "ConfPanelBelow"); // NOI18N
65

66         return new ConfPanel(beforeDesc, beforeContents,
67                              afterDesc,
68                              afterContents, filename, -1);
69
70     }
71     
72     public void perform(Suggestion s) {
73         element.viewSource(); // Check later
74
try {
75             element.autoCorrect();
76         } catch (SourceException e) {
77             ErrorManager.getDefault().notify(e);
78         }
79     }
80 };
81
Popular Tags