1 package net.sourceforge.phpeclipse.xdebug.php.launching;
3 import net.sourceforge.phpeclipse.xdebug.core.IProxyEventListener;
4 import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin;
5 import net.sourceforge.phpeclipse.xdebug.core.XDebugProxy;
6 import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget;
8 import org.eclipse.core.resources.IProject;
9 import org.eclipse.core.resources.ResourcesPlugin;
10 import org.eclipse.core.runtime.CoreException;
11 import org.eclipse.core.runtime.IProgressMonitor;
12 import org.eclipse.core.runtime.IStatus;
13 import org.eclipse.core.runtime.Status;
14 import org.eclipse.debug.core.ILaunch;
15 import org.eclipse.debug.core.ILaunchConfiguration;
16 import org.eclipse.debug.core.ILaunchManager;
17 import org.eclipse.debug.core.model.IDebugTarget;
18 //import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
19 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
21 public class PHPRemoteLaunchConfigurationDelegate extends LaunchConfigurationDelegate /*implements ILaunchConfigurationDelegate*/ {
22 public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
23 String projectName = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null);
24 IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
25 // Just to get sure that the project exists
26 if (project == null) {
27 abort("Project does not exist.", null);
30 XDebugProxy proxy = XDebugCorePlugin.getDefault().getXDebugProxy();
32 String ideID = configuration.getAttribute(IXDebugConstants.ATTR_PHP_IDE_ID, "testID");
34 if (mode.equals(ILaunchManager.DEBUG_MODE)) {
35 IDebugTarget target = new XDebugTarget(launch, null, ideID);
36 proxy.addProxyEventListener((IProxyEventListener) target, ideID);
37 launch.addDebugTarget(target);
42 * Throws an exception with a new status containing the given
43 * message and optional exception.
45 * @param message error message
46 * @param e underlying exception
47 * @throws CoreException
49 private void abort(String message, Throwable e) throws CoreException {
50 throw new CoreException(new Status(IStatus.ERROR, IXDebugConstants.ID_PHP_DEBUG_MODEL, 0, message, e));