View | Details | Raw Unified | Return to bug 109445 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/emf/type/ui/internal/EMFTypeUIPlugin.java (-28 lines)
Lines 10-20 Link Here
10
 ****************************************************************************/
10
 ****************************************************************************/
11
package org.eclipse.gmf.runtime.emf.type.ui.internal;
11
package org.eclipse.gmf.runtime.emf.type.ui.internal;
12
12
13
import java.util.MissingResourceException;
14
15
import org.eclipse.gmf.runtime.common.core.l10n.AbstractResourceManager;
16
import org.eclipse.gmf.runtime.common.ui.plugin.XToolsUIPlugin;
13
import org.eclipse.gmf.runtime.common.ui.plugin.XToolsUIPlugin;
17
import org.eclipse.gmf.runtime.emf.type.ui.internal.l10n.ResourceManager;
18
14
19
/**
15
/**
20
 * Plug-in class for the UI portion of the Model Element Type framework.
16
 * Plug-in class for the UI portion of the Model Element Type framework.
Lines 32-52 Link Here
32
	private static EMFTypeUIPlugin plugin;
28
	private static EMFTypeUIPlugin plugin;
33
29
34
	/**
30
	/**
35
	 * Returns the string from the plugin's resource bundle, or 'key' if not
36
	 * found.
37
	 */
38
	public static String getResourceString(String key) {
39
		AbstractResourceManager resourceManager = EMFTypeUIPlugin.getDefault()
40
			.getResourceManager();
41
		try {
42
			return (resourceManager != null) ? resourceManager.getString(key)
43
				: key;
44
		} catch (MissingResourceException e) {
45
			return key;
46
		}
47
	}
48
49
	/**
50
	 * Creates new plug-in runtime object.
31
	 * Creates new plug-in runtime object.
51
	 */
32
	 */
52
	public EMFTypeUIPlugin() {
33
	public EMFTypeUIPlugin() {
Lines 60-72 Link Here
60
	public static EMFTypeUIPlugin getDefault() {
41
	public static EMFTypeUIPlugin getDefault() {
61
		return plugin;
42
		return plugin;
62
	}
43
	}
63
64
	/*
65
	 * (non-Javadoc)
66
	 * 
67
	 * @see org.eclipse.gmf.runtime.common.ui.plugin.XToolsUIPlugin#getResourceManager()
68
	 */
69
	public AbstractResourceManager getResourceManager() {
70
		return ResourceManager.getInstance();
71
	}
72
}
44
}
(-)src/org/eclipse/gmf/runtime/emf/type/ui/internal/l10n/ResourceManager.java (-120 lines)
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
}
(-)src/org/eclipse/gmf/runtime/emf/type/ui/internal/l10n/EMFTypeUIMessages.java (+27 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 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
package org.eclipse.gmf.runtime.emf.type.ui.internal.l10n;
12
13
import org.eclipse.osgi.util.NLS;
14
15
public final class EMFTypeUIMessages extends NLS {
16
17
	private static final String BUNDLE_NAME = "org.eclipse.gmf.runtime.emf.type.ui.internal.l10n.EMFTypeUIMessages";//$NON-NLS-1$
18
19
	private EMFTypeUIMessages() {
20
		// Do not instantiate
21
	}
22
23
24
	static {
25
		NLS.initializeMessages(BUNDLE_NAME, EMFTypeUIMessages.class);
26
	}
27
}

Return to bug 109445