01: package org.jdom;
02:
03: import org.eclipse.ui.plugin.*;
04: import org.osgi.framework.BundleContext;
05: import java.util.*;
06:
07: /**
08: * The main plugin class to be used in the desktop.
09: */
10: public class JDOMPlugin extends AbstractUIPlugin {
11: //The shared instance.
12: private static JDOMPlugin plugin;
13: //Resource bundle.
14: private ResourceBundle resourceBundle;
15:
16: /**
17: * The constructor.
18: */
19: public JDOMPlugin() {
20: super ();
21: plugin = this ;
22: try {
23: resourceBundle = ResourceBundle
24: .getBundle("Jdom.JdomPluginResources");
25: } catch (MissingResourceException x) {
26: resourceBundle = null;
27: }
28: }
29:
30: /**
31: * This method is called upon plug-in activation
32: */
33: public void start(BundleContext context) throws Exception {
34: super .start(context);
35: }
36:
37: /**
38: * This method is called when the plug-in is stopped
39: */
40: public void stop(BundleContext context) throws Exception {
41: super .stop(context);
42: }
43:
44: /**
45: * Returns the shared instance.
46: */
47: public static JDOMPlugin getDefault() {
48: return plugin;
49: }
50:
51: /**
52: * Returns the string from the plugin's resource bundle,
53: * or 'key' if not found.
54: */
55: public static String getResourceString(String key) {
56: ResourceBundle bundle = JDOMPlugin.getDefault()
57: .getResourceBundle();
58: try {
59: return (bundle != null) ? bundle.getString(key) : key;
60: } catch (MissingResourceException e) {
61: return key;
62: }
63: }
64:
65: /**
66: * Returns the plugin's resource bundle,
67: */
68: public ResourceBundle getResourceBundle() {
69: return resourceBundle;
70: }
71: }
|