Source Code Cross Referenced for Task.java in  » IDE-Netbeans » spi » org » netbeans » spi » tasklist » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » spi » org.netbeans.spi.tasklist 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.spi.tasklist;
043:
044:        import java.awt.event.ActionListener;
045:        import java.util.HashSet;
046:        import java.util.Map;
047:        import java.util.Set;
048:        import org.netbeans.modules.tasklist.trampoline.TaskGroupFactory;
049:        import java.util.logging.Level;
050:        import java.util.logging.Logger;
051:        import org.netbeans.modules.tasklist.trampoline.Accessor;
052:        import org.netbeans.modules.tasklist.trampoline.TaskGroup;
053:        import org.openide.filesystems.FileObject;
054:        import org.openide.util.NbBundle;
055:
056:        /**
057:         * A class holding the description of a single Task that will appear in TaskList's window.
058:         * 
059:         * @author S. Aubrecht
060:         */
061:        public final class Task {
062:
063:            private FileObject resource;
064:            private TaskGroup group;
065:            private String description;
066:            private int line;
067:            private ActionListener al;
068:
069:            static {
070:                Accessor.DEFAULT = new AccessorImpl();
071:            }
072:
073:            /**
074:             * Create a new Task
075:             * 
076:             * @param resource File or folder which the Task applies to, cannot be null.
077:             * @param groupName Name of the group this task belongs to (error, warning, todo, etc).
078:             * @param description A brief summary of the task (one line if possible), cannot be null.
079:             * @param line Line number in a text file, use negative value if line number is not applicable.
080:             * 
081:             * @return New task.
082:             */
083:            public static Task create(FileObject resource, String groupName,
084:                    String description, int line) {
085:                return new Task(resource, getTaskGroup(groupName), description,
086:                        line, null);
087:            }
088:
089:            /**
090:             * Create a new Task
091:             * 
092:             * @param resource File or folder which the Task applies to, cannot be null.
093:             * @param groupName Name of the group this task belongs to (error, warning, todo, etc).
094:             * @param description A brief summary of the task (one line if possible), cannot be null.
095:             * @param al Task's default action, e.g. double-click or Enter key in the Task List window.
096:             * 
097:             * @return New task.
098:             */
099:            public static Task create(FileObject resource, String groupName,
100:                    String description, ActionListener al) {
101:                return new Task(resource, getTaskGroup(groupName), description,
102:                        -1, al);
103:            }
104:
105:            /** Creates a new instance of Task */
106:            private Task(FileObject resource, TaskGroup group,
107:                    String description, int line, ActionListener al) {
108:                assert null != group;
109:                assert null != description;
110:                assert null != resource;
111:
112:                this .resource = resource;
113:                this .group = group;
114:                this .description = description;
115:                this .line = line;
116:                this .al = al;
117:            }
118:
119:            /**
120:             * Resource (file or folder) this taks applies to.
121:             * @return Resource (file or folder) this taks applies to.
122:             */
123:            FileObject getResource() {
124:                return resource;
125:            }
126:
127:            /**
128:             * The group this task belongs to (error, warning, todo, etc)
129:             * @return The group this task belongs to (error, warning, todo, etc)
130:             */
131:            TaskGroup getGroup() {
132:                return group;
133:            }
134:
135:            /**
136:             * Task description.
137:             * @return Task description.
138:             */
139:            String getDescription() {
140:                return description;
141:            }
142:
143:            /**
144:             * One-based line number in a text file this task applies to, -1 if the line number is not applicable. 
145:             * @return One-based line number in a text file this task applies to, -1 if the line number is not applicable. 
146:             */
147:            int getLine() {
148:                return line;
149:            }
150:
151:            /**
152:             * Action to be invoked when user double-clicks the task in the Task List window.
153:             * @return Task's default action or null if not available.
154:             */
155:            ActionListener getActionListener() {
156:                return al;
157:            }
158:
159:            /**
160:             * Create a new TaskGroup, called from XML layer.
161:             */
162:            static TaskGroup createGroup(Map<String, String> attrs) {
163:                return TaskGroupFactory.create(attrs);
164:            }
165:
166:            private static Set<String> unknownTaskGroups;
167:
168:            private static TaskGroup getTaskGroup(String groupName) {
169:                TaskGroup group = TaskGroupFactory.getDefault().getGroup(
170:                        groupName);
171:                if (null == group) {
172:                    if (null == unknownTaskGroups
173:                            || !unknownTaskGroups.contains(groupName)) {
174:                        //show only one warning that the group name is not supported
175:                        Logger.getLogger(Task.class.getName()).log(
176:                                Level.INFO,
177:                                NbBundle.getMessage(Task.class,
178:                                        "Err_UnknownGroupName"), groupName); //NOI18N
179:                        if (null == unknownTaskGroups)
180:                            unknownTaskGroups = new HashSet<String>(10);
181:                        unknownTaskGroups.add(groupName);
182:                    }
183:
184:                    group = TaskGroupFactory.getDefault().getDefaultGroup();
185:                }
186:                return group;
187:            }
188:
189:            @Override
190:            public boolean equals(Object o) {
191:                if (o == null)
192:                    return false;
193:                if (getClass() != o.getClass())
194:                    return false;
195:                final Task test = (Task) o;
196:
197:                if (this .line != test.line)
198:                    return false;
199:                if (this .description != test.description
200:                        && this .description != null
201:                        && !this .description.equals(test.description))
202:                    return false;
203:                if (this .group != test.group && this .group != null
204:                        && !this .group.equals(test.group))
205:                    return false;
206:                if (this .resource != test.resource && this .resource != null
207:                        && !this .resource.equals(test.resource))
208:                    return false;
209:                return true;
210:            }
211:
212:            @Override
213:            public int hashCode() {
214:                int hash = 7;
215:
216:                hash = 17 * hash + this .line;
217:                hash = 17
218:                        * hash
219:                        + (this .description != null ? this .description
220:                                .hashCode() : 0);
221:                hash = 17 * hash
222:                        + (this .group != null ? this .group.hashCode() : 0);
223:                hash = 17
224:                        * hash
225:                        + (this .resource != null ? this .resource.hashCode() : 0);
226:                return hash;
227:            }
228:
229:            @Override
230:            public String toString() {
231:                StringBuffer buffer = new StringBuffer();
232:                buffer.append("[");
233:                buffer.append(getResource());
234:                buffer.append(", ");
235:                buffer.append(getLine());
236:                buffer.append(", ");
237:                buffer.append(getDescription());
238:                buffer.append(", ");
239:                buffer.append(getGroup());
240:                buffer.append("]");
241:                return buffer.toString();
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.