]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - demo/plugins/org.argeo.demo.i18n/src/main/java/org/argeo/demo/i18n/I18nDemoPlugin.java
1 package org
.argeo
.demo
.i18n
;
3 import java
.util
.ResourceBundle
;
5 import org
.apache
.commons
.logging
.Log
;
6 import org
.apache
.commons
.logging
.LogFactory
;
7 import org
.eclipse
.jface
.resource
.ImageDescriptor
;
8 import org
.eclipse
.ui
.plugin
.AbstractUIPlugin
;
9 import org
.osgi
.framework
.BundleContext
;
12 * The activator class controls the plug-in life cycle
14 public class I18nDemoPlugin
extends AbstractUIPlugin
{
15 private final static Log log
= LogFactory
.getLog(I18nDemoPlugin
.class);
16 private ResourceBundle messages
;
19 public static final String ID
= "org.argeo.demo.i18n"; //$NON-NLS-1$
21 // The shared instance
22 private static I18nDemoPlugin plugin
;
27 public I18nDemoPlugin() {
34 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
37 public void start(BundleContext context
) throws Exception
{
40 messages
= ResourceBundle
.getBundle("org.argeo.demo.i18n.messages");
47 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
50 public void stop(BundleContext context
) throws Exception
{
56 * Returns the shared instance
58 * @return the shared instance
60 public static I18nDemoPlugin
getDefault() {
64 public static ImageDescriptor
getImageDescriptor(String path
) {
65 return imageDescriptorFromPlugin(ID
, path
);
68 /** Returns the internationalized label for the given key */
69 public static String
getMessage(String key
) {
71 return getDefault().messages
.getString(key
);
72 } catch (NullPointerException npe
) {
73 log
.warn(key
+ " not found.");
79 * Gives access to the internationalization message bundle. Returns null in
80 * case the ClientUiPlugin is not started (for JUnit tests, by instance)
82 public static ResourceBundle
getMessagesBundle() {
83 if (getDefault() != null)
85 return getDefault().messages
;