Initial implementation of the new Debug Plugin
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / core / XDebugCorePlugin.java
1 package net.sourceforge.phpeclipse.xdebug.core;
2
3
4 import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
5
6 import org.eclipse.ui.plugin.*;
7 import org.eclipse.core.resources.IWorkspace;
8 import org.eclipse.core.resources.ResourcesPlugin;
9 import org.eclipse.core.runtime.IStatus;
10 import org.eclipse.core.runtime.Status;
11 import org.eclipse.debug.core.DebugPlugin;
12 import org.eclipse.debug.core.IBreakpointManager;
13 import org.eclipse.debug.core.model.IBreakpoint;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.osgi.framework.BundleContext;
16
17 /**
18  * The main plugin class to be used in the desktop.
19  */
20 public class XDebugCorePlugin extends AbstractUIPlugin {
21
22         //The shared instance.
23         private static XDebugCorePlugin plugin;
24         public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.xdebug.core"; //$NON-NLS-1$
25
26         
27         /**
28          * The constructor.
29          */
30         public XDebugCorePlugin() {
31                 plugin = this;
32         }
33
34         /**
35          * This method is called upon plug-in activation
36          */
37         public void start(BundleContext context) throws Exception {
38                 super.start(context);
39         }
40
41         /**
42          * This method is called when the plug-in is stopped
43          */
44         public void stop(BundleContext context) throws Exception {
45                 super.stop(context);
46                 plugin = null;
47         }
48
49         /**
50          * Returns the shared instance.
51          */
52         public static XDebugCorePlugin getDefault() {
53                 return plugin;
54         }
55         
56         public static IBreakpoint[] getBreakpoints() {
57                 return getBreakpointManager().getBreakpoints(IXDebugConstants.ID_PHP_DEBUG_MODEL);
58         }
59         
60         public static IBreakpointManager getBreakpointManager() {
61                 return DebugPlugin.getDefault().getBreakpointManager();
62         }
63
64         /**
65          * Returns an image descriptor for the image file at the given
66          * plug-in relative path.
67          *
68          * @param path the path
69          * @return the image descriptor
70          */
71         public static ImageDescriptor getImageDescriptor(String path) {
72                 return AbstractUIPlugin.imageDescriptorFromPlugin("net.sourceforge.phpeclipse.xdebug.core", path);
73         }
74         
75         public static void log(int severity, String message) {
76                 Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null) ;
77                 XDebugCorePlugin.log(status) ;
78         }
79
80         public static void log(IStatus status) {
81                 getDefault().getLog().log(status);
82         }
83
84         public static void log(Throwable e) {
85                 log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPLaunchingPlugin.internalErrorOccurred", e)); //$NON-NLS-1$
86         }
87         
88           /**
89            * Returns the workspace instance.
90            */
91           public static IWorkspace getWorkspace() {
92             return ResourcesPlugin.getWorkspace();
93           }
94         
95         
96 }