Removed
Link Here
|
1 |
/****************************************************************************** |
2 |
* Copyright (c) 2005 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
10 |
****************************************************************************/ |
11 |
|
12 |
package org.eclipse.gmf.runtime.emf.type.ui.internal.l10n; |
13 |
|
14 |
import org.eclipse.core.runtime.Plugin; |
15 |
|
16 |
import org.eclipse.gmf.runtime.common.core.l10n.AbstractResourceManager; |
17 |
import org.eclipse.gmf.runtime.emf.type.ui.internal.EMFTypeUIPlugin; |
18 |
|
19 |
/** |
20 |
* A Singleton which provides a single point of reference for all of the |
21 |
* plug-in's localization needs. |
22 |
* <P> |
23 |
* This class is not intended to be used by clients. |
24 |
* |
25 |
* @author ldamus |
26 |
*/ |
27 |
public class ResourceManager |
28 |
extends AbstractResourceManager { |
29 |
|
30 |
/** |
31 |
* Singleton instance of the resource manager. |
32 |
*/ |
33 |
private static ResourceManager instance = new ResourceManager(); |
34 |
|
35 |
/** |
36 |
* Initializes me. |
37 |
*/ |
38 |
private ResourceManager() { |
39 |
super(); |
40 |
} |
41 |
|
42 |
/** |
43 |
* Retrieves the singleton instance of this resource manager. |
44 |
* |
45 |
* @return The singleton resource manager. |
46 |
*/ |
47 |
public static ResourceManager getInstance() { |
48 |
return instance; |
49 |
} |
50 |
|
51 |
/** |
52 |
* Retrieves a localized string for the specified key. |
53 |
* |
54 |
* @param key |
55 |
* The resource bundle key. |
56 |
* @return A localized string value, or the original <code>key</key> if the |
57 |
* bundle does not include this entry. |
58 |
*/ |
59 |
public static String getLocalizedString(String key) { |
60 |
return getInstance().getString(key); |
61 |
} |
62 |
|
63 |
/** |
64 |
* Creates a localized, parameterized message from the specified pattern and |
65 |
* argument keys in the resource bundle. |
66 |
* |
67 |
* @param patternKey |
68 |
* resource bundle key of the message pattern |
69 |
* @param argKeys |
70 |
* resource bundle keys of the arguments to the pattern |
71 |
* @return the formatted message |
72 |
* |
73 |
* @see java.text.MessageFormat |
74 |
*/ |
75 |
public static String getMessage(String patternKey, String[] argKeys) { |
76 |
ResourceManager mgr = getInstance(); |
77 |
|
78 |
Object[] args = new Object[argKeys.length]; |
79 |
|
80 |
for (int i = 0; i < argKeys.length; i++) { |
81 |
args[i] = mgr.getString(argKeys[i]); |
82 |
} |
83 |
|
84 |
return getMessage(patternKey, args); |
85 |
} |
86 |
|
87 |
/** |
88 |
* Creates a localized, parameterized message from the specified pattern and |
89 |
* argument keys in the resource bundle. |
90 |
* |
91 |
* @param patternKey |
92 |
* resource bundle key of the message pattern |
93 |
* @param args |
94 |
* literal values as arguments to the pattern |
95 |
* @return the formatted message |
96 |
* |
97 |
* @see java.text.MessageFormat |
98 |
*/ |
99 |
public static String getMessage(String patternKey, Object[] args) { |
100 |
return getInstance().formatMessage(patternKey, args); |
101 |
} |
102 |
|
103 |
/* |
104 |
* (non-Javadoc) |
105 |
* |
106 |
* @see org.eclipse.gmf.runtime.common.core.l10n.AbstractResourceManager#initializeResources() |
107 |
*/ |
108 |
protected void initializeResources() { |
109 |
initializeMessageResources(); |
110 |
} |
111 |
|
112 |
/** |
113 |
* Convenience method to obtain my plug-in instance. |
114 |
* |
115 |
* @return my plug-in |
116 |
*/ |
117 |
protected Plugin getPlugin() { |
118 |
return EMFTypeUIPlugin.getDefault(); |
119 |
} |
120 |
} |