]> git.argeo.org Git - lgpl/argeo-commons.git/blob - jcr/JcrUiPlugin.java
Prepare next development cycle
[lgpl/argeo-commons.git] / jcr / JcrUiPlugin.java
1 package org.argeo.eclipse.ui.jcr;
2
3 import java.util.ResourceBundle;
4
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;
10
11 public class JcrUiPlugin extends AbstractUIPlugin {
12 private final static Log log = LogFactory.getLog(JcrUiPlugin.class);
13
14 public final static String ID = "org.argeo.eclipse.ui.jcr";
15
16 private ResourceBundle messages;
17
18 private static JcrUiPlugin plugin;
19
20 public void start(BundleContext context) throws Exception {
21 super.start(context);
22 plugin = this;
23 messages = ResourceBundle.getBundle("org.argeo.eclipse.ui.jcr");
24 }
25
26 public static JcrUiPlugin getDefault() {
27 return plugin;
28 }
29
30 public static ImageDescriptor getImageDescriptor(String path) {
31 return imageDescriptorFromPlugin(ID, path);
32 }
33
34 /** Returns the internationalized label for the given key */
35 public static String getMessage(String key) {
36 try {
37 return getDefault().messages.getString(key);
38 } catch (NullPointerException npe) {
39 log.warn(key + " not found.");
40 return key;
41 }
42 }
43
44 /**
45 * Gives access to the internationalization message bundle. Returns null in
46 * case the ClientUiPlugin is not started (for JUnit tests, by instance)
47 */
48 public static ResourceBundle getMessagesBundle() {
49 if (getDefault() != null)
50 // To avoid NPE
51 return getDefault().messages;
52 else
53 return null;
54 }
55 }