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.modules.javadoc.search;
043:
044: import java.util.EnumSet;
045: import javax.lang.model.element.ElementKind;
046: import javax.lang.model.element.Modifier;
047: import javax.swing.Icon;
048: import javax.swing.ImageIcon;
049: import org.netbeans.api.java.source.UiUtils;
050:
051: import org.openide.util.Utilities;
052:
053: /** <DESCRIPTION>
054:
055: @author Petr Hrebejk
056: */
057: final class DocSearchIcons extends Object {
058:
059: public static final int ICON_NOTRESOLVED = 0;
060: public static final int ICON_PACKAGE = ICON_NOTRESOLVED + 1;
061: public static final int ICON_CLASS = ICON_PACKAGE + 1;
062: public static final int ICON_INTERFACE = ICON_CLASS + 1;
063: public static final int ICON_ENUM = ICON_INTERFACE + 1;
064: public static final int ICON_ANNTYPE = ICON_ENUM + 1;
065: public static final int ICON_EXCEPTION = ICON_ANNTYPE + 1;
066: public static final int ICON_ERROR = ICON_EXCEPTION + 1;
067: public static final int ICON_CONSTRUCTOR = ICON_ERROR + 1;
068: public static final int ICON_METHOD = ICON_CONSTRUCTOR + 1;
069: public static final int ICON_METHOD_ST = ICON_METHOD + 1;
070: public static final int ICON_VARIABLE = ICON_METHOD_ST + 1;
071: public static final int ICON_VARIABLE_ST = ICON_VARIABLE + 1;
072: public static final int ICON_NOT_FOUND = ICON_VARIABLE_ST + 1;
073: public static final int ICON_WAIT = ICON_NOT_FOUND + 1;
074:
075: private static final Icon[] icons = new Icon[ICON_WAIT + 1];
076:
077: static {
078: try {
079: final EnumSet<Modifier> mods = EnumSet.of(Modifier.PUBLIC);
080: final EnumSet<Modifier> modsSt = EnumSet.of(
081: Modifier.PUBLIC, Modifier.STATIC);
082: icons[ICON_NOTRESOLVED] = new ImageIcon(
083: Utilities
084: .loadImage("org/netbeans/modules/javadoc/resources/pending.gif")); // NOI18N
085: icons[ICON_PACKAGE] = new ImageIcon(
086: Utilities
087: .loadImage("org/netbeans/modules/javadoc/comments/resources/package.gif")); // NOI18N
088: icons[ICON_CLASS] = UiUtils.getElementIcon(
089: ElementKind.CLASS, mods);
090: icons[ICON_INTERFACE] = UiUtils.getElementIcon(
091: ElementKind.INTERFACE, mods);
092: icons[ICON_ENUM] = UiUtils.getElementIcon(ElementKind.ENUM,
093: mods);
094: icons[ICON_ANNTYPE] = UiUtils.getElementIcon(
095: ElementKind.ANNOTATION_TYPE, mods);
096: icons[ICON_EXCEPTION] = new ImageIcon(
097: Utilities
098: .loadImage("org/netbeans/modules/javadoc/resources/exception.gif")); // NOI18N
099: icons[ICON_ERROR] = new ImageIcon(
100: Utilities
101: .loadImage("org/netbeans/modules/javadoc/resources/error.gif")); // NOI18N
102: icons[ICON_CONSTRUCTOR] = UiUtils.getElementIcon(
103: ElementKind.CONSTRUCTOR, mods);
104: icons[ICON_METHOD] = UiUtils.getElementIcon(
105: ElementKind.METHOD, mods);
106: icons[ICON_METHOD_ST] = UiUtils.getElementIcon(
107: ElementKind.METHOD, modsSt);
108: icons[ICON_VARIABLE] = UiUtils.getElementIcon(
109: ElementKind.FIELD, mods);
110: icons[ICON_VARIABLE_ST] = UiUtils.getElementIcon(
111: ElementKind.FIELD, modsSt);
112: icons[ICON_NOT_FOUND] = new ImageIcon(
113: Utilities
114: .loadImage("org/netbeans/modules/javadoc/resources/notFound.gif")); // NOI18N
115: icons[ICON_WAIT] = new ImageIcon(
116: Utilities
117: .loadImage("org/netbeans/modules/javadoc/resources/wait.png")); // NOI18N
118: } catch (Throwable w) {
119: w.printStackTrace();
120: }
121: }
122:
123: static Icon getIcon(int index) {
124: return icons[index];
125: }
126:
127: }
|