KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > base > NLBasePlugin


1 package com.nightlabs.base;
2
3 import org.eclipse.ui.plugin.*;
4 import org.osgi.framework.BundleContext;
5 import java.util.*;
6
7 /**
8  * The main plugin class to be used in the desktop.
9  */

10 public class NLBasePlugin extends AbstractUIPlugin {
11     //The shared instance.
12
private static NLBasePlugin plugin;
13     //Resource bundle.
14
private ResourceBundle resourceBundle;
15     
16     /**
17      * The constructor.
18      */

19     public NLBasePlugin() {
20         super();
21         plugin = this;
22         try {
23             resourceBundle = ResourceBundle.getBundle("com.nightlabs.base.plugin");
24         } catch (MissingResourceException x) {
25             resourceBundle = null;
26         }
27     }
28
29     /**
30      * This method is called upon plug-in activation
31      */

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

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

46     public static NLBasePlugin getDefault() {
47         return plugin;
48     }
49
50     /**
51      * Returns the string from the plugin's resource bundle,
52      * or 'key' if not found.
53      */

54     public static String JavaDoc getResourceString(String JavaDoc key) {
55         ResourceBundle bundle = NLBasePlugin.getDefault().getResourceBundle();
56         try {
57             return (bundle != null) ? bundle.getString(key) : key;
58         } catch (MissingResourceException e) {
59             return key;
60         }
61     }
62
63     /**
64      * Returns the plugin's resource bundle,
65      */

66     public ResourceBundle getResourceBundle() {
67         return resourceBundle;
68     }
69 }
70
Popular Tags