KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > suggestions > SuggestionType


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.suggestions;
21
22 import java.awt.Image JavaDoc;
23 import java.awt.Toolkit JavaDoc;
24 import java.net.URL JavaDoc;
25 import java.util.ResourceBundle JavaDoc;
26 import org.openide.util.NbBundle;
27 import java.util.List JavaDoc;
28
29 /**
30  * This class represents a SuggestionType. This concept is described
31  * in the TaskList api (org.netbeans.api.tasklist) documentation.
32  *
33  * @author Tor Norbye
34  */

35
36 final public class SuggestionType {
37
38     /**
39      * Create a SuggestionType
40      * @param name The name which identifies this Suggestion Type
41      * @param bundle The file where the localized name for the type is found
42      * @param key The key which holds the localized name in the bundle file
43      * @param longkey The key which holds the localized full, possibly
44      * multiline description of the type in the bundle file
45      * @param icon A url to the icon to be used by default for these suggestions */

46     SuggestionType(String JavaDoc name, String JavaDoc bundle, String JavaDoc key,
47                    String JavaDoc longkey, URL JavaDoc icon, List JavaDoc actions) {
48         this.name = name;
49         this.bundle = bundle;
50         this.key = key;
51         this.longkey = longkey;
52         this.icon = icon;
53         this.actions = actions;
54     }
55
56     List JavaDoc getActions() {
57         return actions;
58     }
59
60     /** @return The name which identifies this Suggestion Type */
61     public String JavaDoc getName() {
62         return name;
63     }
64         
65     /** @return The file where the localized name for the type is found */
66     String JavaDoc getBundle() {
67         return bundle;
68     }
69
70     /** @return The key which holds the localized name in the bundle file */
71     String JavaDoc getKey() {
72         return key;
73     }
74
75     /** @return A url to the icon to be used by default for these suggestions */
76     URL JavaDoc getIcon() {
77         return icon;
78     }
79
80     /** Gets Image which represents the icon. */
81     public Image JavaDoc getIconImage() {
82         if ((img == null) && (icon != null)) {
83             img = Toolkit.getDefaultToolkit().getImage(icon);
84         }
85         return img;
86     }
87
88     /** Return the name of the Suggestion type - localized. */
89     public String JavaDoc getLocalizedName() {
90         if (localizedName == null) {
91             ResourceBundle JavaDoc rb = NbBundle.getBundle(bundle);
92             localizedName = rb.getString(key);
93             if (localizedName == null) {
94                 localizedName = "";
95             }
96         }
97         return localizedName;
98     }
99
100     /** Return the description of the Suggestion type - localized. */
101     String JavaDoc getDescription() {
102         if (localizedDesc == null) {
103             if (longkey != null) {
104                 ResourceBundle JavaDoc rb = NbBundle.getBundle(bundle);
105                 localizedDesc = rb.getString(longkey);
106             }
107             if (localizedDesc == null) {
108                 localizedDesc = "";
109             }
110         }
111         return localizedDesc;
112     }
113
114    /** Return a description of this object. Format may change any time
115      * and is not localized. Do not depend on its content or format. */

116     public String JavaDoc toString() {
117         return "SuggestionType[name=" + name + ",bundle=" + bundle + // NOI18N
118
",key=" + key + ",icon=" + icon + ",pos=" + position +"]"; // NOI18N
119
}
120
121     /** Set the relative position of this type in the type hierarchy */
122     public void setPosition(int position) {
123         this.position = position;
124     }
125
126     /** Return the relative position of this type in the type hierarchy */
127     public int getPosition() {
128         return position;
129     }
130
131     private int position;
132     private String JavaDoc name;
133     private String JavaDoc bundle;
134     private String JavaDoc key;
135     private String JavaDoc longkey;
136     private URL JavaDoc icon;
137     private Image JavaDoc img = null;
138     private String JavaDoc localizedName = null;
139     private String JavaDoc localizedDesc = null;
140     private List JavaDoc actions;
141 }
142
Popular Tags