OSDN Git Service

copy from subversion repository r.68
[ginkgo/master.git] / org.ginkgo.gcov / src / org / ginkgo / gcov / GcovPlugin.java
1 package org.ginkgo.gcov;
2
3 import java.util.ArrayList;
4
5 import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
6 import org.eclipse.jface.resource.ImageDescriptor;
7 import org.eclipse.ui.plugin.AbstractUIPlugin;
8 import org.osgi.framework.BundleContext;
9
10 /**
11  * The activator class controls the plug-in life cycle
12  */
13 public class GcovPlugin extends AbstractUIPlugin {
14
15         // The plug-in ID
16         public static final String PLUGIN_ID = "org.ginkgo.gcov";
17
18         // The shared instance
19         private static GcovPlugin plugin;
20         private ArrayList myListeners;
21         /**
22          * The constructor
23          */
24         public GcovPlugin() {
25                 myListeners=new ArrayList();
26         }
27
28         /*
29          * (non-Javadoc)
30          * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
31          */
32         public void start(BundleContext context) throws Exception {
33                 super.start(context);
34                 plugin = this;
35         }
36
37         /*
38          * (non-Javadoc)
39          * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
40          */
41         public void stop(BundleContext context) throws Exception {
42                 plugin = null;
43                 super.stop(context);
44         }
45
46         /**
47          * Returns the shared instance
48          *
49          * @return the shared instance
50          */
51         public static GcovPlugin getDefault() {
52                 return plugin;
53         }
54
55         /**
56          * Returns an image descriptor for the image file at the given
57          * plug-in relative path
58          *
59          * @param path the path
60          * @return the image descriptor
61          */
62         public static ImageDescriptor getImageDescriptor(String path) {
63                 return imageDescriptorFromPlugin(PLUGIN_ID, path);
64         }
65         // A public method that allows listener registration
66         public void addPropertyChangeListener(IPropertyChangeListener listener) {
67                 if(!myListeners.contains(listener))
68                         myListeners.add(listener);
69         }
70
71         // A public method that allows listener registration
72         public void removePropertyChangeListener(IPropertyChangeListener listener) {
73                 myListeners.remove(listener);
74         }
75         public ArrayList getMyListeners() {
76                 return myListeners;
77         }
78 }