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