KickJava   Java API By Example, From Geeks To Geeks.

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


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.List JavaDoc;
23 import java.util.Iterator JavaDoc;
24
25 import org.netbeans.modules.tasklist.core.filter.FilterAction;
26 import org.netbeans.modules.tasklist.core.TaskNode;
27 import org.netbeans.modules.tasklist.core.TaskListView;
28 import org.openide.ErrorManager;
29 import org.openide.actions.PropertiesAction;
30 import org.openide.nodes.Node;
31 import org.openide.nodes.Sheet;
32
33 import org.openide.nodes.Node.Property;
34 import org.openide.nodes.PropertySupport.Reflection;
35 import org.openide.nodes.Sheet.Set;
36 import org.openide.util.NbBundle;
37 import org.openide.util.actions.SystemAction;
38 import org.netbeans.modules.tasklist.core.TaskChildren;
39 import org.netbeans.modules.tasklist.core.Task;
40 import org.openide.nodes.Children;
41
42 import javax.swing.*;
43 import org.netbeans.modules.tasklist.core.export.ExportAction;
44
45
46 class BugNode extends TaskNode {
47     
48     // Leaf
49
BugNode(Bug item) {
50         super(item);
51         init();
52     }
53
54     // Non-leaf/parent
55
BugNode(Bug item, Children children) {
56         super(item, children);
57         init();
58     }
59
60     protected TaskChildren createChildren() {
61       return new BugChildren((Bug)this.item);
62     }
63
64
65   // children for BugNode , serve as a factory for nodes
66
static class BugChildren extends TaskChildren {
67       
68       BugChildren(Bug parent) { super(parent);}
69
70       protected TaskNode createNode(Task task) {
71     return new BugNode((Bug)task);
72       }
73     }
74
75     private void init() {
76         setDefaultAction(SystemAction.get(ViewBugAction.class));
77         setIconBase("org/netbeans/modules/tasklist/bugs/bug"); // NOI18N
78
}
79
80     // Handle cloning specially (so as not to invoke the overhead of FilterNode):
81
public Node cloneNode () {
82       return new BugNode((Bug)item);
83     }
84
85     protected void updateIcon() {
86     // Override so we don't reset it to task.gif here
87
}
88     
89     protected SystemAction[] createActions() {
90     
91     // TODO Perform lookup here to compute an aggregate
92
// menu from other modules as well. But how do we determine
93
// order? I think NetBeans 4.0's actions re-work will have
94
// some better support for integrating context menus so I won't
95
// try to be too clever here...
96

97     // XXX look up and locate actions
98

99
100         return new SystemAction[] {
101             SystemAction.get(NewQueryAction.class),
102             null,
103             SystemAction.get(ViewBugAction.class),
104             null,
105             SystemAction.get(RefreshAction.class),
106             null,
107             SystemAction.get(FilterAction.class),
108             null,
109             /*
110               SystemAction.get(CutAction.class),
111               SystemAction.get(CopyAction.class),
112               SystemAction.get(PasteAction.class),
113               null,
114               SystemAction.get(DeleteAction.class),
115               null,
116             */

117             SystemAction.get(ExportAction.class),
118             null,
119             SystemAction.get(PropertiesAction.class),
120         };
121     }
122
123     public Action[] getActions(boolean empty) {
124         if (empty) {
125             return new SystemAction[] {
126                 SystemAction.get(NewQueryAction.class),
127             };
128         } else {
129             return super.getActions(false);
130         }
131     }
132
133     /** Creates properties.
134      */

135     protected Sheet createSheet() {
136         Sheet s = Sheet.createDefault();
137         Set ss = s.get(Sheet.PROPERTIES);
138         
139         try {
140             Property p;
141             p = new Reflection(item, String JavaDoc.class, "getSummary", null); // NOI18N
142
p.setName(TaskListView.PROP_TASK_SUMMARY);
143             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Summary")); // NOI18N
144
p.setShortDescription(NbBundle.getMessage(BugNode.class, "SummaryHint")); // NOI18N
145
ss.put(p);
146
147             p = new Reflection(item, String JavaDoc.class, "getId", null); // NOI18N
148
p.setName(BugsView.PROP_BUG_ID);
149             p.setDisplayName(NbBundle.getMessage(BugNode.class, "BugId")); // NOI18N
150
p.setShortDescription(NbBundle.getMessage(BugNode.class, "BugIdHint")); // NOI18N
151
ss.put(p);
152             
153             p = new Reflection(item, String JavaDoc.class, "getSynopsis", null); // NOI18N
154
p.setName(BugsView.PROP_BUG_SYNOPSIS);
155             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Synopsis")); // NOI18N
156
p.setShortDescription(NbBundle.getMessage(BugNode.class, "SynopsisHint")); // NOI18N
157
ss.put(p);
158
159             p = new Reflection(item, Integer.TYPE, "getPriorityNumber", null); // NOI18N
160
p.setName(BugsView.PROP_BUG_PRIO);
161             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Priority")); // NOI18N
162
p.setShortDescription(NbBundle.getMessage(BugNode.class, "PriorityHint")); // NOI18N
163
ss.put(p);
164
165
166
167
168
169
170             p = new Reflection(item, String JavaDoc.class, "getType", null); // NOI18N
171
p.setName(BugsView.PROP_BUG_TYPE);
172             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Type")); // NOI18N
173
p.setShortDescription(NbBundle.getMessage(BugNode.class, "TypeHint")); // NOI18N
174
ss.put(p);
175
176
177
178
179             p = new Reflection(item, String JavaDoc.class, "getComponent", null); // NOI18N
180
p.setName(BugsView.PROP_BUG_COMP);
181             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Component")); // NOI18N
182
p.setShortDescription(NbBundle.getMessage(BugNode.class, "ComponentHint")); // NOI18N
183
ss.put(p);
184
185
186
187
188             p = new Reflection(item, String JavaDoc.class, "getSubComponent", null); // NOI18N
189
p.setName(BugsView.PROP_BUG_SUBCOMP);
190             p.setDisplayName(NbBundle.getMessage(BugNode.class, "SubComponent")); // NOI18N
191
p.setShortDescription(NbBundle.getMessage(BugNode.class, "SubComponentHint")); // NOI18N
192
ss.put(p);
193
194
195
196
197             p = new Reflection(item, String JavaDoc.class, "getCreated", null); // NOI18N
198
p.setName(BugsView.PROP_BUG_CREATED);
199             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Created")); // NOI18N
200
p.setShortDescription(NbBundle.getMessage(BugNode.class, "CreatedHint")); // NOI18N
201
ss.put(p);
202
203
204
205
206             p = new Reflection(item, String JavaDoc.class, "getKeywords", null); // NOI18N
207
p.setName(BugsView.PROP_BUG_KEYWORDS);
208             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Keywords")); // NOI18N
209
p.setShortDescription(NbBundle.getMessage(BugNode.class, "KeywordsHint")); // NOI18N
210
ss.put(p);
211
212
213
214
215             p = new Reflection(item, String JavaDoc.class, "getAssignedTo", null); // NOI18N
216
p.setName(BugsView.PROP_BUG_ASSIGNED);
217             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Assigned")); // NOI18N
218
p.setShortDescription(NbBundle.getMessage(BugNode.class, "AssignedHint")); // NOI18N
219
ss.put(p);
220
221
222
223
224             p = new Reflection(item, String JavaDoc.class, "getReportedBy", null); // NOI18N
225
p.setName(BugsView.PROP_BUG_REPORTEDBY);
226             p.setDisplayName(NbBundle.getMessage(BugNode.class, "ReportedBy")); // NOI18N
227
p.setShortDescription(NbBundle.getMessage(BugNode.class, "ReportedByHint")); // NOI18N
228
ss.put(p);
229
230
231             p = new Reflection(item, String JavaDoc.class, "getStatus", null); // NOI18N
232
p.setName(BugsView.PROP_BUG_STATUS);
233             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Status")); // NOI18N
234
p.setShortDescription(NbBundle.getMessage(BugNode.class, "StatusHint")); // NOI18N
235
ss.put(p);
236
237
238             p = new Reflection(item, String JavaDoc.class, "getTarget", null); // NOI18N
239
p.setName(BugsView.PROP_BUG_TARGET);
240             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Target")); // NOI18N
241
p.setShortDescription(NbBundle.getMessage(BugNode.class, "TargetHint")); // NOI18N
242
ss.put(p);
243
244
245
246             p = new Reflection(item, Integer.TYPE, "getVotes", null); // NOI18N
247
p.setName(BugsView.PROP_BUG_VOTES);
248             p.setDisplayName(NbBundle.getMessage(BugNode.class, "Votes")); // NOI18N
249
p.setShortDescription(NbBundle.getMessage(BugNode.class, "VotesHint")); // NOI18N
250
ss.put(p);
251
252
253
254
255     } catch (NoSuchMethodException JavaDoc nsme) {
256             ErrorManager.getDefault().notify(nsme);
257         }
258         return s;
259     }
260     
261     public boolean canRename() {
262         return false;
263     }
264
265     public boolean canDestroy() {
266         return false;
267     }
268
269     public boolean canCopy () {
270         return false;
271     }
272
273     public boolean canCut () {
274         return false;
275     }
276 }
277
278
Popular Tags