KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > welcome > content > BundleSupport


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.welcome.content;
21
22 import java.text.MessageFormat JavaDoc;
23 import javax.swing.JComponent JavaDoc;
24 import org.openide.util.NbBundle;
25
26 public class BundleSupport {
27
28     private static final String JavaDoc BUNDLE_NAME = "org.netbeans.modules.welcome.resources.Bundle"; // NOI18N
29

30     private static final String JavaDoc LABEL_PREFIX = "LBL_"; // NOI18N
31
private static final String JavaDoc URL_PREFIX = "URL_"; // NOI18N
32
private static final String JavaDoc CATEGORY_PREFIX = "CATEGORY_"; // NOI18N
33
private static final String JavaDoc TEMPLATE_PREFIX = "TEMPLATE_"; // NOI18N
34
private static final String JavaDoc ACN_PREFIX = "ACN_"; // NOI18N
35
private static final String JavaDoc ACD_PREFIX = "ACD_"; // NOI18N
36
private static final String JavaDoc MNM_PREFIX = "MNM_"; // NOI18N
37

38     public static String JavaDoc getLabel(String JavaDoc bundleKey) {
39         return NbBundle.getBundle(BUNDLE_NAME).getString(LABEL_PREFIX + bundleKey);
40     }
41     
42     public static String JavaDoc getURL(String JavaDoc bundleKey) {
43         return NbBundle.getBundle(BUNDLE_NAME).getString(URL_PREFIX + bundleKey);
44     }
45     
46     public static char getMnemonic(String JavaDoc bundleKey) {
47         return NbBundle.getBundle(BUNDLE_NAME).getString(MNM_PREFIX + bundleKey).charAt(0);
48     }
49     
50     public static String JavaDoc getSampleCategory(String JavaDoc bundleKey) {
51         return NbBundle.getBundle(BUNDLE_NAME).getString(CATEGORY_PREFIX + bundleKey);
52     }
53
54     public static String JavaDoc getSampleTemplate(String JavaDoc bundleKey) {
55         return NbBundle.getBundle(BUNDLE_NAME).getString(TEMPLATE_PREFIX + bundleKey);
56     }
57
58     public static String JavaDoc getAccessibilityName(String JavaDoc bundleKey) {
59         return NbBundle.getBundle(BUNDLE_NAME).getString(ACN_PREFIX + bundleKey);
60     }
61     
62     public static String JavaDoc getAccessibilityName(String JavaDoc bundleKey, String JavaDoc param) {
63         return MessageFormat.format( NbBundle.getBundle(BUNDLE_NAME).getString(ACN_PREFIX + bundleKey), param );
64     }
65     
66     public static String JavaDoc getAccessibilityDescription(String JavaDoc bundleKey, String JavaDoc param) {
67         return MessageFormat.format( NbBundle.getBundle(BUNDLE_NAME).getString(ACD_PREFIX + bundleKey), param );
68     }
69     
70     public static void setAccessibilityProperties(JComponent JavaDoc component, String JavaDoc bundleKey) {
71         String JavaDoc aName = NbBundle.getBundle(BUNDLE_NAME).getString(ACN_PREFIX + bundleKey);
72         String JavaDoc aDescr = NbBundle.getBundle(BUNDLE_NAME).getString(ACD_PREFIX + bundleKey);
73       
74         component.getAccessibleContext().setAccessibleName(aName);
75         component.getAccessibleContext().setAccessibleDescription(aDescr);
76     }
77 }
78
Popular Tags