01: package net.refractions.udig.catalog.internal.geotiff;
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 GeoTiffPlugin extends AbstractUIPlugin {
13: //The shared instance.
14: private static GeoTiffPlugin plugin;
15: //Resource bundle.
16: private ResourceBundle resourceBundle;
17:
18: /**
19: * The constructor.
20: */
21: public GeoTiffPlugin() {
22: super ();
23: plugin = this ;
24: }
25:
26: /**
27: * This method is called upon plug-in activation
28: * @param context
29: * @throws Exception
30: */
31: public void start(BundleContext context) throws Exception {
32: super .start(context);
33: }
34:
35: /**
36: * This method is called when the plug-in is stopped
37: * @param context
38: * @throws Exception
39: */
40: public void stop(BundleContext context) throws Exception {
41: plugin = null;
42: this .resourceBundle = null;
43: super .stop(context);
44: }
45:
46: /**
47: * Returns the shared instance.
48: * @return Default implementation of this plugin.
49: */
50: public static GeoTiffPlugin getDefault() {
51: return plugin;
52: }
53:
54: /**
55: * Returns the string from the plugin's resource bundle,
56: * or 'key' if not found.
57: * @param key
58: * @return String value of the requsted resource.
59: */
60: public static String getResourceString(String key) {
61: ResourceBundle bundle = GeoTiffPlugin.getDefault()
62: .getResourceBundle();
63: try {
64: return (bundle != null) ? bundle.getString(key) : key;
65: } catch (MissingResourceException e) {
66: return key;
67: }
68: }
69:
70: /**
71: * Returns the plugin's resource bundle,
72: * @return Default ResourceBundle for this plugin.
73: */
74: public ResourceBundle getResourceBundle() {
75: try {
76: if (this .resourceBundle == null)
77: this .resourceBundle = ResourceBundle
78: .getBundle("net.refractions.udig.catalog.internal.geotiff.GeoTiffPluginResources"); //$NON-NLS-1$
79: } catch (MissingResourceException x) {
80: this.resourceBundle = null;
81: }
82: return this.resourceBundle;
83: }
84: }
|