testing around with plugin properties ;)
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / PHPeclipsePlugin.java
1 package net.sourceforge.phpeclipse;
2
3 import java.util.MissingResourceException;
4 import java.util.ResourceBundle;
5
6 import org.eclipse.core.resources.IWorkspace;
7 import org.eclipse.core.resources.ResourcesPlugin;
8 import org.eclipse.core.runtime.IPluginDescriptor;
9 import org.eclipse.ui.plugin.AbstractUIPlugin;
10
11 /**
12  * The main plugin class to be used in the desktop.
13  */
14 public class PHPeclipsePlugin extends AbstractUIPlugin {
15         //The shared instance.
16         private static PHPeclipsePlugin plugin;
17         //Resource bundle.
18         private ResourceBundle resourceBundle;
19
20         /**
21          * The constructor.
22          */
23         public PHPeclipsePlugin(IPluginDescriptor descriptor) {
24                 super(descriptor);
25                 plugin = this;
26                 try {
27                         resourceBundle =
28                                 ResourceBundle.getBundle(
29                                         "net.sourceforge.PHPeclipsePluginResources");
30                 } catch (MissingResourceException x) {
31                         resourceBundle = null;
32                 }
33         }
34
35         /**
36          * Returns the shared instance.
37          */
38         public static PHPeclipsePlugin getDefault() {
39                 return plugin;
40         }
41
42         /**
43          * Returns the workspace instance.
44          */
45         public static IWorkspace getWorkspace() {
46                 return ResourcesPlugin.getWorkspace();
47         }
48
49         /**
50          * Returns the string from the plugin's resource bundle,
51          * or 'key' if not found.
52          */
53         public static String getResourceString(String key) {
54                 ResourceBundle bundle =
55                         PHPeclipsePlugin.getDefault().getResourceBundle();
56                 try {
57                         return bundle.getString(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 }