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