KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > EditorPlugin


1 package com.nightlabs.editor2d;
2
3 import org.eclipse.ui.plugin.*;
4 import org.osgi.framework.BundleContext;
5 import java.util.*;
6
7 /**
8  * The main plugin class to be used in the desktop.
9  */

10 public class EditorPlugin
11 extends AbstractUIPlugin
12 {
13     //The shared instance.
14
private static EditorPlugin plugin;
15     //Resource bundle.
16
private ResourceBundle resourceBundle;
17     
18     public static String JavaDoc PLUGIN_ID = "com.nightlabs.editor2d";
19     
20     /**
21      * The constructor.
22      */

23     public EditorPlugin() {
24         super();
25         plugin = this;
26         try {
27           resourceBundle = ResourceBundle.getBundle("com.nightlabs.editor2d.plugin");
28         } catch (MissingResourceException x) {
29             resourceBundle = null;
30         }
31     }
32
33     /**
34      * This method is called upon plug-in activation
35      */

36     public void start(BundleContext context) throws Exception JavaDoc {
37         super.start(context);
38     }
39
40     /**
41      * This method is called when the plug-in is stopped
42      */

43     public void stop(BundleContext context) throws Exception JavaDoc {
44         super.stop(context);
45     }
46
47     /**
48      * Returns the shared instance.
49      */

50     public static EditorPlugin getDefault() {
51         return plugin;
52     }
53
54     /**
55      * Returns the string from the plugin's resource bundle,
56      * or 'key' if not found.
57      */

58     public static String JavaDoc getResourceString(String JavaDoc key) {
59         ResourceBundle bundle = EditorPlugin.getDefault().getResourceBundle();
60         try {
61             return (bundle != null) ? bundle.getString(key) : key;
62         } catch (MissingResourceException e) {
63             return key;
64         }
65     }
66
67     /**
68      * Returns the plugin's resource bundle,
69      */

70     public ResourceBundle getResourceBundle()
71     {
72       if (resourceBundle == null)
73       {
74             try {
75               resourceBundle = ResourceBundle.getBundle("com.nightlabs.editor2d.plugin");
76             } catch (MissingResourceException x) {
77                 resourceBundle = null;
78             }
79       }
80         return resourceBundle;
81     }
82 }
83
Free Books   Free Magazines  
Popular Tags