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-2007 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 com.sun.rave.designtime.base;
043:
044: import com.sun.rave.designtime.CategoryDescriptor;
045: import java.util.HashMap;
046: import java.util.Locale;
047: import java.util.ResourceBundle;
048:
049: /**
050: * Defines the component property categories used by Creator design-time
051: * implementations.
052: */
053:
054: public class CategoryDescriptors {
055:
056: private static final ResourceBundle bundle = ResourceBundle
057: .getBundle("com.sun.rave.designtime.base.Bundle", // NOI18N
058: Locale.getDefault(), CategoryDescriptors.class
059: .getClassLoader());
060:
061: public static final CategoryDescriptor ACCESSIBILITY = new CategoryDescriptor(
062: bundle.getString("accessibility"), bundle
063: .getString("accessibilityCatDesc"), false); //NOI18N
064:
065: public static final CategoryDescriptor ADVANCED = new CategoryDescriptor(
066: bundle.getString("adv"), bundle.getString("advCatDesc"),
067: false); //NOI18N
068:
069: public static final CategoryDescriptor APPEARANCE = new CategoryDescriptor(
070: bundle.getString("appear"), bundle
071: .getString("appearCatDesc"), true); //NOI18N
072:
073: public static final CategoryDescriptor BEHAVIOR = new CategoryDescriptor(
074: bundle.getString("behavior"), bundle
075: .getString("behaviorCatDesc"), false); //NOI18N
076:
077: public static final CategoryDescriptor DATA = new CategoryDescriptor(
078: bundle.getString("data"), bundle.getString("dataCatDesc"),
079: true); //NOI18N
080:
081: public static final CategoryDescriptor EVENTS = new CategoryDescriptor(
082: bundle.getString("ev"), bundle.getString("evCatDesc"), true); //NOI18N
083:
084: public static final CategoryDescriptor GENERAL = new CategoryDescriptor(
085: bundle.getString("gen"), bundle.getString("genCatDesc"),
086: true); //NOI18N
087:
088: public static final CategoryDescriptor INTERNAL = new CategoryDescriptor(
089: bundle.getString("intern"), bundle
090: .getString("internCatDesc"), false); //NOI18N
091:
092: public static final CategoryDescriptor JAVASCRIPT = new CategoryDescriptor(
093: bundle.getString("js"), bundle.getString("jsCatDesc"),
094: false); //NOI18N
095:
096: public static final CategoryDescriptor LAYOUT = new CategoryDescriptor(
097: bundle.getString("layout"), bundle
098: .getString("layoutCatDesc"), false); //NOI18N
099:
100: public static final CategoryDescriptor NAVIGATION = new CategoryDescriptor(
101: bundle.getString("navigation"), bundle
102: .getString("navigationCatDesc"), false); //NOI18N
103:
104: private static CategoryDescriptor defaultCategoryDescriptors[] = {
105: GENERAL, APPEARANCE, LAYOUT, DATA, EVENTS, NAVIGATION,
106: BEHAVIOR, ACCESSIBILITY, JAVASCRIPT, ADVANCED, INTERNAL };
107:
108: protected static HashMap categoryHash;
109:
110: public static CategoryDescriptor getCategoryDescriptor(
111: String categoryName) {
112: Object[] pair;
113:
114: if (categoryName == null) {
115: return null;
116: }
117: pair = (Object[]) categoryHash.get(categoryName.toLowerCase());
118: if (pair == null) {
119: pair = new Object[] { null,
120: new CategoryDescriptor(categoryName, "") }; //NOI18N
121: categoryHash.put(categoryName, pair);
122: }
123: return (CategoryDescriptor) pair[1];
124: }
125:
126: public static String getCategoryDescriptorConstantName(
127: String categoryName) {
128: Object[] pair;
129:
130: if (categoryName == null) {
131: return null;
132: }
133: pair = (Object[]) categoryHash.get(categoryName.toLowerCase());
134: if (pair == null) {
135: return null;
136: }
137: return (String) pair[0];
138: }
139:
140: /**
141: * <p>Return an array of <code>CategoryDescriptor</code> instances
142: * describing the property categories supported by this library.</p>
143: */
144: public static CategoryDescriptor[] getDefaultCategoryDescriptors() {
145: return defaultCategoryDescriptors;
146: }
147:
148: }
|