KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > bugs > Bug


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.bugs;
21
22 import java.util.Date JavaDoc;
23
24 import org.netbeans.modules.tasklist.core.Task;
25 import org.openide.nodes.Node;
26
27
28 // XXX todo: fire property change whenever anything changes in the node...
29

30 /**
31  * Class which represents a task in the
32  * tasklist.
33  *
34  * @author Tor Norbye
35  */

36 public final class Bug extends Task {
37     private BugEngine engine = null;
38
39     // IMPORTANT: If you add additional fields, update copyFrom() as well
40
private String JavaDoc id = "";
41     private String JavaDoc synopsis = "";
42     private int priority;
43     private String JavaDoc type = "";
44     private String JavaDoc component = "";
45     private String JavaDoc subcomponent = "";
46     private Date JavaDoc created = null;
47     private String JavaDoc keywords = "";
48     private String JavaDoc assignedto = "";
49     private String JavaDoc reportedby = "";
50     private String JavaDoc status = "";
51     private String JavaDoc target = "";
52     private int votes = 0;
53     // IMPORTANT: If you add additional fields, update copyFrom() as well
54

55
56     public Bug() {
57     }
58
59     public Bug(String JavaDoc id,
60                String JavaDoc synopsis,
61                int priority,
62                String JavaDoc type,
63                String JavaDoc component,
64                String JavaDoc subcomponent,
65                Date JavaDoc created,
66                String JavaDoc keywords,
67                String JavaDoc assignedto,
68                String JavaDoc reportedby,
69                String JavaDoc status,
70                String JavaDoc target,
71                int votes) {
72         super(id, null);
73         this.id = id;
74         this.synopsis = synopsis;
75         this.priority = priority;
76         this.type = type;
77         this.component = component;
78         this.subcomponent = subcomponent;
79         this.created = created;
80         this.keywords = keywords;
81         this.assignedto = assignedto;
82         this.reportedby = reportedby;
83         this.status = status;
84         this.target = target;
85         this.votes = votes;
86
87         setSummary(id + ": " + synopsis); // NOI18N
88
}
89
90     /**
91      * Return the priority of the task.
92      *
93      * @return The priority of the task. "0" is considered
94      * "not prioritized". Lower number is considered
95      * a higher priority, by convention. The default
96      * priority of tasks is "3".
97      */

98     public int getPriorityNumber() {
99         return priority;
100     }
101
102     public void setPriorityNumber(int priority) {
103         this.priority = priority;
104     }
105
106     /**
107      * Return the bug number
108      *
109      * @return The bug number
110      */

111     public String JavaDoc getId() {
112         return id;
113     }
114
115     public void setId(String JavaDoc id) {
116         this.id = id;
117     }
118
119
120     /**
121      * Return the description for the bug
122      *
123      * @return Bug description.
124      */

125     public String JavaDoc getSynopsis() {
126         return synopsis;
127     }
128
129     public void setSynopsis(String JavaDoc synopsis) {
130         this.synopsis = synopsis;
131     }
132
133     /**
134      * Return the bug's component/category
135      */

136     public String JavaDoc getComponent() {
137         return component;
138     }
139
140     public void setComponent(String JavaDoc component) {
141         this.component = component;
142     }
143
144
145     /**
146      * Return the bug's subcomponent/subcategory
147      */

148     public String JavaDoc getSubComponent() {
149         return subcomponent;
150     }
151
152     public void setSubComponent(String JavaDoc subcomponent) {
153         this.subcomponent = subcomponent;
154     }
155
156
157     /**
158      * Return the bug's creation date
159      */

160     public Date JavaDoc getCreated() {
161         return created;
162     }
163
164     public void setCreated(Date JavaDoc created) {
165         this.created = created;
166     }
167
168
169     /**
170      * Return keywords associated with the bug
171      */

172     public String JavaDoc getKeywords() {
173         return keywords;
174     }
175
176     public void setKeywords(String JavaDoc keywords) {
177         this.keywords = keywords;
178     }
179
180     /**
181      * Return the name of the person assigned to the bug
182      */

183     public String JavaDoc getAssignedTo() {
184         return assignedto;
185     }
186
187     public void setAssignedTo(String JavaDoc assignedto) {
188         this.assignedto = assignedto;
189     }
190
191     /**
192      * Return the name of the person who filed the bug
193      */

194     public String JavaDoc getReportedBy() {
195         return reportedby;
196     }
197
198     public void setReportedBy(String JavaDoc reportedby) {
199         this.reportedby = reportedby;
200     }
201
202     /**
203      * Return the current status of the bug
204      */

205     public String JavaDoc getStatus() {
206         return status;
207     }
208
209     public void setStatus(String JavaDoc status) {
210         this.status = status;
211     }
212
213     /**
214      * Return the target milestone for the bug
215      */

216     public String JavaDoc getTarget() {
217         return target;
218     }
219
220     public void setTarget(String JavaDoc target) {
221         this.target = target;
222     }
223
224     /**
225      * Return the type of bug: enhancement, bug, ...
226      */

227     public String JavaDoc getType() {
228         return type;
229     }
230
231     public void setType(String JavaDoc type) {
232         this.type = type;
233     }
234
235     /**
236      * Return the number of votes for the bug
237      */

238     public int getVotes() {
239         return votes;
240     }
241
242     public void setVotes(int votes) {
243         this.votes = votes;
244     }
245
246     // TODO: Issuezilla also provides: getResolution, getDescriptions,
247
// getObservedBy, getBlocks, getDependsOn -- do I care about these
248

249     /**
250      * Generate a string summary of the task; only used
251      * for debugging. DO NOT depend on this format for anything!
252      * Use generate() instead.
253      *
254      * @return summary string
255      */

256     public String JavaDoc toString() {
257         return "Bug[\"" + id + "\", " + synopsis + ":" + priority + "]"; // NOI18N
258
}
259
260     /**
261      * Create a node for this item
262      */

263     public Node[] createNode() {
264         // PENDING Do I allow subnodes for bugs? IssueZilla depends on
265
// seems like something you could consider a "subtask", although
266
// not quite
267
// A: Exactly, I would use it for IZ depends mapping, in reality
268
// it can cause identity problems as the same IZ task is
269
// nodeled by multiple TL tasks
270
if (hasSubtasks()) {
271             return new Node[]{ new BugNode(this, new BugNode.BugChildren(this))};
272         } else {
273             return new Node[]{ new BugNode(this)};
274         }
275     }
276
277     /**
278      * Create an identical copy of a task (a deep copy, e.g. the
279      * list of subtasks will be cloned as well
280      */

281     protected Object JavaDoc clone() {
282         Bug t = new Bug();
283         t.copyFrom(this);
284         return t;
285     }
286
287     /**
288      * Copy all the fields in the given task into this object.
289      * Should only be called on an object of the EXACT same type.
290      * Thus, if you're implementing a subclass of Task, say
291      * UserTask, you can implement copy assuming that the passed
292      * in Task parameter is of type UserTask. When overriding,
293      * remember to call super.copyFrom.
294      * <p/>
295      * Make a deep copy - except when that doesn't make sense.
296      * For example, you can share the same icon reference.
297      * And in particular, the tasklist reference should be the same.
298      * But the list of subitems should be unique. You get the idea.
299      */

300     protected void copyFrom(Bug from) {
301         super.copyFrom(from);
302
303         engine = from.engine;
304
305         id = from.id;
306         synopsis = from.synopsis;
307         priority = from.priority;
308         type = from.type;
309         component = from.component;
310         subcomponent = from.subcomponent;
311         created = from.created;
312         keywords = from.keywords;
313         assignedto = from.assignedto;
314         reportedby = from.reportedby;
315         status = from.status;
316         target = from.target;
317         votes = from.votes;
318     }
319
320     /**
321      * View the particular bug in current view
322      */

323     void view() {
324         BugList list = (BugList) BugsView.getCurrent().getList();
325         list.viewBug(this);
326     }
327
328     /**
329      * Return the bug engine associated with this bug
330      */

331     public void setEngine(BugEngine engine) {
332         this.engine = engine;
333     }
334
335     /**
336      * Set the bug engine associated with this bug
337      */

338     public BugEngine getEngine() {
339         return engine;
340     }
341 }
342
343
344
345
Popular Tags