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