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