Initial implementation of the new Debug Plugin
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / core / XDebugCorePlugin.java
diff --git a/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java b/net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge/phpeclipse/xdebug/core/XDebugCorePlugin.java
new file mode 100644 (file)
index 0000000..716b582
--- /dev/null
@@ -0,0 +1,96 @@
+package net.sourceforge.phpeclipse.xdebug.core;
+
+
+import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
+
+import org.eclipse.ui.plugin.*;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IBreakpointManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class XDebugCorePlugin extends AbstractUIPlugin {
+
+       //The shared instance.
+       private static XDebugCorePlugin plugin;
+       public static final String PLUGIN_ID = "net.sourceforge.phpeclipse.xdebug.core"; //$NON-NLS-1$
+
+       
+       /**
+        * The constructor.
+        */
+       public XDebugCorePlugin() {
+               plugin = this;
+       }
+
+       /**
+        * This method is called upon plug-in activation
+        */
+       public void start(BundleContext context) throws Exception {
+               super.start(context);
+       }
+
+       /**
+        * This method is called when the plug-in is stopped
+        */
+       public void stop(BundleContext context) throws Exception {
+               super.stop(context);
+               plugin = null;
+       }
+
+       /**
+        * Returns the shared instance.
+        */
+       public static XDebugCorePlugin getDefault() {
+               return plugin;
+       }
+       
+       public static IBreakpoint[] getBreakpoints() {
+               return getBreakpointManager().getBreakpoints(IXDebugConstants.ID_PHP_DEBUG_MODEL);
+       }
+       
+       public static IBreakpointManager getBreakpointManager() {
+               return DebugPlugin.getDefault().getBreakpointManager();
+       }
+
+       /**
+        * Returns an image descriptor for the image file at the given
+        * plug-in relative path.
+        *
+        * @param path the path
+        * @return the image descriptor
+        */
+       public static ImageDescriptor getImageDescriptor(String path) {
+               return AbstractUIPlugin.imageDescriptorFromPlugin("net.sourceforge.phpeclipse.xdebug.core", path);
+       }
+       
+       public static void log(int severity, String message) {
+               Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null) ;
+               XDebugCorePlugin.log(status) ;
+       }
+
+       public static void log(IStatus status) {
+               getDefault().getLog().log(status);
+       }
+
+       public static void log(Throwable e) {
+               log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPLaunchingPlugin.internalErrorOccurred", e)); //$NON-NLS-1$
+       }
+       
+         /**
+          * Returns the workspace instance.
+          */
+         public static IWorkspace getWorkspace() {
+           return ResourcesPlugin.getWorkspace();
+         }
+       
+       
+}