]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/JcrExplorerPlugin.java
Add class Java doc
[lgpl/argeo-commons.git] / server / plugins / org.argeo.jcr.ui.explorer / src / main / java / org / argeo / jcr / ui / explorer / JcrExplorerPlugin.java
1 package org.argeo.jcr.ui.explorer;
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 /**
12 * The activator class controls the plug-in life cycle
13 */
14 public class JcrExplorerPlugin extends AbstractUIPlugin {
15 private final static Log log = LogFactory.getLog(JcrExplorerPlugin.class);
16 private ResourceBundle messages;
17
18 // The plug-in ID
19 public static final String ID = "org.argeo.jcr.ui.explorer"; //$NON-NLS-1$
20
21 // The shared instance
22 private static JcrExplorerPlugin plugin;
23
24 /**
25 * The constructor
26 */
27 public JcrExplorerPlugin() {
28 }
29
30 /*
31 * (non-Javadoc)
32 *
33 * @see
34 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
35 * )
36 */
37 public void start(BundleContext context) throws Exception {
38 super.start(context);
39 plugin = this;
40 messages = ResourceBundle
41 .getBundle("org.argeo.jcr.ui.explorer.messages");
42
43 }
44
45 /*
46 * (non-Javadoc)
47 *
48 * @see
49 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
50 * )
51 */
52 public void stop(BundleContext context) throws Exception {
53 plugin = null;
54 super.stop(context);
55 }
56
57 /**
58 * Returns the shared instance
59 *
60 * @return the shared instance
61 */
62 public static JcrExplorerPlugin getDefault() {
63 return plugin;
64 }
65
66 public static ImageDescriptor getImageDescriptor(String path) {
67 return imageDescriptorFromPlugin(ID, path);
68 }
69
70 /** Returns the internationalized label for the given key */
71 public static String getMessage(String key) {
72 try {
73 return getDefault().messages.getString(key);
74 } catch (NullPointerException npe) {
75 log.warn(key + " not found.");
76 return key;
77 }
78 }
79
80 /**
81 * Gives access to the internationalization message bundle. Returns null in
82 * case the ClientUiPlugin is not started (for JUnit tests, by instance)
83 */
84 public static ResourceBundle getMessagesBundle() {
85 if (getDefault() != null)
86 // To avoid NPE
87 return getDefault().messages;
88 else
89 return null;
90 }
91
92 }