X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=eclipse%2Fruntime%2Forg.argeo.eclipse.ui.jcr%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fui%2Fjcr%2FJcrUiPlugin.java;h=5f333f71d250430bc3641e012a5ddfbc93cbd4b9;hb=c0b7b3f9d1781d074ab35d24017042fa9415e1e4;hp=a533682969eb60d1702d0886b8ab671af4efafa5;hpb=ed36fb56ac5aff2d606b35be175eb32657d6ec56;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/JcrUiPlugin.java b/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/JcrUiPlugin.java index a53368296..5f333f71d 100644 --- a/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/JcrUiPlugin.java +++ b/eclipse/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/JcrUiPlugin.java @@ -1,17 +1,26 @@ package org.argeo.eclipse.ui.jcr; +import java.util.ResourceBundle; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; public class JcrUiPlugin extends AbstractUIPlugin { + private final static Log log = LogFactory.getLog(JcrUiPlugin.class); + public final static String ID = "org.argeo.eclipse.ui.jcr"; + private ResourceBundle messages; + private static JcrUiPlugin plugin; public void start(BundleContext context) throws Exception { super.start(context); plugin = this; + messages = ResourceBundle.getBundle("org.argeo.eclipse.ui.jcr"); } public static JcrUiPlugin getDefault() { @@ -22,4 +31,25 @@ public class JcrUiPlugin extends AbstractUIPlugin { return imageDescriptorFromPlugin(ID, path); } + /** Returns the internationalized label for the given key */ + public static String getMessage(String key) { + try { + return getDefault().messages.getString(key); + } catch (NullPointerException npe) { + log.warn(key + " not found."); + return key; + } + } + + /** + * Gives access to the internationalization message bundle. Returns null in + * case the ClientUiPlugin is not started (for JUnit tests, by instance) + */ + public static ResourceBundle getMessagesBundle() { + if (getDefault() != null) + // To avoid NPE + return getDefault().messages; + else + return null; + } }