+ refactoring of the JCR UI Model (in a MVC point of view)
[lgpl/argeo-commons.git] / eclipse / runtime / org.argeo.eclipse.ui.jcr / src / main / java / org / argeo / eclipse / ui / jcr / JcrUiPlugin.java
index a533682969eb60d1702d0886b8ab671af4efafa5..5f333f71d250430bc3641e012a5ddfbc93cbd4b9 100644 (file)
@@ -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;
+       }
 }