KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > core > TaskAnnotation


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.core;
21
22 import org.openide.text.Annotation;
23
24 /** Annotation which shows tasks in the editor
25  */

26 public class TaskAnnotation extends Annotation {
27
28     /** Construct a new TaskAnnotation which shows both a gutter
29      * icon and a line highlight. */

30     public TaskAnnotation(Task task) {
31         this(task, true);
32     }
33
34     /** Construct a new TaskAnnotation.
35      * @param task The task to show the annotation for
36      * @param highlight When true, show a highlight for the task,
37      * not just a gutter icon.
38      */

39     public TaskAnnotation(Task task, boolean highlight) {
40         this.task = task;
41         this.highlight = highlight;
42     }
43
44     /**
45      * Constructs annotation that is capable to locate
46      * task in other tasks views (implementing TaskSelector).
47      *
48      * @param task
49      * @param view
50      */

51     public TaskAnnotation(Task task, TaskSelector view) {
52         this.task = task;
53         this.view = view;
54         highlight = true;
55     }
56
57     public String JavaDoc getAnnotationType () {
58         // THE TYPE IS DEFINED IN THE TASKLIST EDITOR MODULE!
59
// (because it registers an Editor action - New Task, to be
60
// added to the editor glyph gutter/margin menu)
61
if (highlight) {
62             return "Task"; // NOI18N
63
} else {
64             return "TaskNoHighlight"; // NOI18N
65
}
66     }
67     
68     public String JavaDoc getShortDescription () {
69         // Use details summary, if available
70
showTask();
71
72         if (task.getDetails().length() > 0) {
73             return task.getSummary() + "\n\n" + task.getDetails();
74         } else {
75             return task.getSummary();
76         }
77     }
78
79     /** Show the task for this annotation in its view */
80     protected void showTask() {
81         if (view != null) view.select(task);
82     }
83
84     /** Return the task associated with this annotation */
85     public Task getTask() {
86         return task;
87     }
88
89
90
91     protected Task task = null;
92     private boolean highlight = false;
93     private TaskSelector view;
94 }
95
Popular Tags