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.welcome.content;
043:
044: import java.text.MessageFormat;
045: import javax.swing.JComponent;
046: import org.openide.util.NbBundle;
047:
048: public class BundleSupport {
049:
050: private static final String BUNDLE_NAME = "org.netbeans.modules.welcome.resources.Bundle"; // NOI18N
051:
052: private static final String LABEL_PREFIX = "LBL_"; // NOI18N
053: private static final String URL_PREFIX = "URL_"; // NOI18N
054: private static final String CATEGORY_PREFIX = "CATEGORY_"; // NOI18N
055: private static final String TEMPLATE_PREFIX = "TEMPLATE_"; // NOI18N
056: private static final String ACN_PREFIX = "ACN_"; // NOI18N
057: private static final String ACD_PREFIX = "ACD_"; // NOI18N
058: private static final String MNM_PREFIX = "MNM_"; // NOI18N
059:
060: public static String getLabel(String bundleKey) {
061: return NbBundle.getBundle(BUNDLE_NAME).getString(
062: LABEL_PREFIX + bundleKey);
063: }
064:
065: public static String getURL(String bundleKey) {
066: return NbBundle.getBundle(BUNDLE_NAME).getString(
067: URL_PREFIX + bundleKey);
068: }
069:
070: public static char getMnemonic(String bundleKey) {
071: return NbBundle.getBundle(BUNDLE_NAME).getString(
072: MNM_PREFIX + bundleKey).charAt(0);
073: }
074:
075: public static String getSampleCategory(String bundleKey) {
076: return NbBundle.getBundle(BUNDLE_NAME).getString(
077: CATEGORY_PREFIX + bundleKey);
078: }
079:
080: public static String getSampleTemplate(String bundleKey) {
081: return NbBundle.getBundle(BUNDLE_NAME).getString(
082: TEMPLATE_PREFIX + bundleKey);
083: }
084:
085: public static String getAccessibilityName(String bundleKey) {
086: return NbBundle.getBundle(BUNDLE_NAME).getString(
087: ACN_PREFIX + bundleKey);
088: }
089:
090: public static String getAccessibilityName(String bundleKey,
091: String param) {
092: return MessageFormat.format(NbBundle.getBundle(BUNDLE_NAME)
093: .getString(ACN_PREFIX + bundleKey), param);
094: }
095:
096: public static String getAccessibilityDescription(String bundleKey,
097: String param) {
098: return MessageFormat.format(NbBundle.getBundle(BUNDLE_NAME)
099: .getString(ACD_PREFIX + bundleKey), param);
100: }
101:
102: public static void setAccessibilityProperties(JComponent component,
103: String bundleKey) {
104: String aName = NbBundle.getBundle(BUNDLE_NAME).getString(
105: ACN_PREFIX + bundleKey);
106: String aDescr = NbBundle.getBundle(BUNDLE_NAME).getString(
107: ACD_PREFIX + bundleKey);
108:
109: component.getAccessibleContext().setAccessibleName(aName);
110: component.getAccessibleContext().setAccessibleDescription(
111: aDescr);
112: }
113:
114: public static String getMessage(String key, Object param) {
115: return MessageFormat.format(NbBundle.getBundle(BUNDLE_NAME)
116: .getString(key), param);
117: }
118: }
|