KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > help > HelpPlugin


1 package org.hibernate.eclipse.help;
2
3
4 import java.util.MissingResourceException JavaDoc;
5 import java.util.ResourceBundle JavaDoc;
6
7 import org.eclipse.ui.plugin.AbstractUIPlugin;
8 import org.osgi.framework.BundleContext;
9
10
11 /**
12  * The main plugin class to be used in the desktop.
13  */

14 public class HelpPlugin extends AbstractUIPlugin {
15     //The shared instance.
16
private static HelpPlugin plugin;
17     //Resource bundle.
18
private ResourceBundle JavaDoc resourceBundle;
19     
20     /**
21      * The constructor.
22      */

23     public HelpPlugin() {
24         super();
25         plugin = this;
26     }
27
28     /**
29      * This method is called upon plug-in activation
30      */

31     public void start(BundleContext context) throws Exception JavaDoc {
32         super.start(context);
33     }
34
35     /**
36      * This method is called when the plug-in is stopped
37      */

38     public void stop(BundleContext context) throws Exception JavaDoc {
39         super.stop(context);
40         plugin = null;
41         resourceBundle = null;
42     }
43
44     /**
45      * Returns the shared instance.
46      */

47     public static HelpPlugin 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 JavaDoc getResourceString(String JavaDoc key) {
56         ResourceBundle JavaDoc bundle = HelpPlugin.getDefault().getResourceBundle();
57         try {
58             return (bundle != null) ? bundle.getString(key) : key;
59         } catch (MissingResourceException JavaDoc e) {
60             return key;
61         }
62     }
63
64     /**
65      * Returns the plugin's resource bundle,
66      */

67     public ResourceBundle JavaDoc getResourceBundle() {
68         try {
69             if (resourceBundle == null)
70                 resourceBundle = ResourceBundle.getBundle("org.hibernate.eclipse.help2.Help2PluginResources");
71         } catch (MissingResourceException JavaDoc x) {
72             resourceBundle = null;
73         }
74         return resourceBundle;
75     }
76 }
77
Popular Tags