01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common
08: * Development and Distribution License("CDDL") (collectively, the
09: * "License"). You may not use this file except in compliance with the
10: * License. You can obtain a copy of the License at
11: * http://www.netbeans.org/cddl-gplv2.html
12: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13: * specific language governing permissions and limitations under the
14: * License. When distributing the software, include this License Header
15: * Notice in each file and include the License file at
16: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17: * particular file as subject to the "Classpath" exception as provided
18: * by Sun in the GPL Version 2 section of the License file that
19: * accompanied this code. If applicable, add the following below the
20: * License Header, with the fields enclosed by brackets [] replaced by
21: * your own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Contributor(s):
25: *
26: * The Original Software is NetBeans. The Initial Developer of the Original
27: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28: * Microsystems, Inc. All Rights Reserved.
29: *
30: * If you wish your version of this file to be governed by only the CDDL
31: * or only the GPL Version 2, indicate your decision by adding
32: * "[Contributor] elects to include this software in this distribution
33: * under the [CDDL or GPL Version 2] license." If you do not indicate a
34: * single choice of license, a recipient has the option to distribute
35: * your version of this file under either the CDDL, the GPL Version 2 or
36: * to extend the choice of license to its licensees as provided above.
37: * However, if you add GPL Version 2 code and therefore, elected the GPL
38: * Version 2 license, then the option applies only if the new code is
39: * made subject to such option by the copyright holder.
40: */
41: package org.netbeans.modules.xml.text.completion;
42:
43: import java.util.HashMap;
44:
45: import javax.swing.ImageIcon;
46:
47: /**
48: * @author Sandeep Singh Randhawa
49: * @version 0.1
50: */
51: final class IconStore extends Object {
52:
53: public static final String EMPTY_TAG = "/org/netbeans/modules/xml/text/completion/resources/emptyTag";
54: public static final String END_TAG = "/org/netbeans/modules/xml/text/completion/resources/endTag";
55: public static final String CHILDREN = "/org/netbeans/modules/xml/text/completion/resources/typeChildren";
56: public static final String MIXED = "/org/netbeans/modules/xml/text/completion/resources/typeMixed";
57: public static final String PCDATA = "/org/netbeans/modules/xml/text/completion/resources/typePCDATA";
58:
59: public static final String TYPE_ENTITY = "/org/netbeans/modules/xml/text/completion/resources/attTypeENTITY";
60: public static final String TYPE_ENTITIES = "/org/netbeans/modules/xml/text/completion/resources/attTypeENTITIES";
61: public static final String TYPE_ENUMERATION = "/org/netbeans/modules/xml/text/completion/resources/attTypeEn";
62: public static final String TYPE_ID = "/org/netbeans/modules/xml/text/completion/resources/attTypeID";
63: public static final String TYPE_IDREF = "/org/netbeans/modules/xml/text/completion/resources/attTypeIDREF";
64: public static final String TYPE_IDREFS = "/org/netbeans/modules/xml/text/completion/resources/attTypeIDREFS";
65: public static final String TYPE_NMTOKEN = "/org/netbeans/modules/xml/text/completion/resources/attTypeNMTOKEN";
66: public static final String TYPE_NMTOKENS = "/org/netbeans/modules/xml/text/completion/resources/attTypeNMTOKENS";
67: public static final String TYPE_NOTATION = "/org/netbeans/modules/xml/text/completion/resources/attTypeNOTATION";
68: public static final String TYPE_CDATA = "/org/netbeans/modules/xml/text/completion/resources/typeCDATA";
69:
70: public static final String SPACER_16 = "/org/netbeans/modules/xml/text/completion/resources/spacer_16";
71: public static final String SPACER_8 = "/org/netbeans/modules/xml/text/completion/resources/spacer_8";
72: public static final String ICON_SUFFIX = ".gif";
73:
74: /** HashMap{@link java.util.HashMap } that acts as a store for the icons.
75: */
76: private static HashMap iconsMap = new HashMap();
77:
78: /** Main method to retrieve the ImageIcon{@link javax.swing.ImageIcon}
79: * @param name Name of the icon to retrieve. In most instances would be one of the variables of
80: * this class.
81: * @return ImageIcon{@link javax.swing.ImageIcon}
82: */
83:
84: public static ImageIcon getImageIcon(String name) {
85: if (name == null)
86: name = SPACER_16;
87:
88: if (iconsMap.containsKey(name))
89: return (ImageIcon) iconsMap.get(name);
90: else {
91: iconsMap.put(name, new ImageIcon(IconStore.class
92: .getResource(name + ICON_SUFFIX)));
93: return (ImageIcon) iconsMap.get(name);
94: }
95: }
96: }
|