038c3d480b258990d911824cfe8efd0c45d22015
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / PHPDebugCorePlugin.java
1 package net.sourceforge.phpdt.internal.debug.core;
2
3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
4 import org.eclipse.core.resources.IWorkspace;
5 import org.eclipse.core.runtime.IPluginDescriptor;
6 import org.eclipse.core.runtime.IStatus;
7 import org.eclipse.core.runtime.Plugin;
8 import org.eclipse.core.runtime.Status;
9 import org.eclipse.core.runtime.*;
10
11 /**
12  * The main plugin class to be used in the desktop.
13  */
14 public class PHPDebugCorePlugin extends Plugin {
15         public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.debug.core"; //$NON-NLS-1$
16         //      The shared instance.
17         protected static PHPDebugCorePlugin plugin;
18
19         /**
20          * The constructor.
21          */
22         public PHPDebugCorePlugin(IPluginDescriptor descriptor) {
23                 super(descriptor);
24                 plugin = this;
25         } 
26
27         /**
28          * Returns the shared instance.
29          */
30         public static PHPDebugCorePlugin getDefault() {
31                 return plugin;
32         }
33
34         /**
35          * Returns the workspace instance.
36          */
37         public static IWorkspace getWorkspace() {
38                 return PHPeclipsePlugin.getWorkspace();
39         }
40         
41         public static void log(int severity, String message) {
42                 Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null) ;
43                 PHPDebugCorePlugin.log(status) ;
44         }
45
46         public static void log(IStatus status) {
47                 getDefault().getLog().log(status);
48         }
49
50         public static void log(Throwable e) {
51                 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPLaunchingPlugin.internalErrorOccurred", e)); //$NON-NLS-1$
52         }
53
54         /**
55          * Convenience method which returns the unique identifier of this plugin.
56          */
57         public static String getUniqueIdentifier() {
58                 if (getDefault() == null) {
59                         // If the default instance is not yet initialized,
60                         // return a static identifier. This identifier must
61                         // match the plugin id defined in plugin.xml
62                         return PLUGIN_ID;
63                 }
64                 return getDefault().getDescriptor().getUniqueIdentifier();
65         }
66         
67         /**
68          * @see Plugin#shutdown()
69          */
70         public void shutdown() throws CoreException {
71                 plugin = null;
72                 super.shutdown();
73         }
74 }