added a builder to parse files with eclipse's build mechanisms
[phpeclipse.git] / net.sourceforge.phpeclipse.launching / src / net / sourceforge / phpdt / internal / launching / PHPLaunchConfigurationDelegate.java
1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
7
8 Contributors:
9         IBM Corporation - Initial implementation
10         Vicente Fernando - www.alfersoft.com.ar
11 **********************************************************************/
12 package net.sourceforge.phpdt.internal.launching;
13
14 import org.eclipse.core.runtime.CoreException;
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.core.runtime.IStatus;
17 import org.eclipse.core.runtime.Status;
18 import org.eclipse.debug.core.ILaunch;
19 import org.eclipse.debug.core.ILaunchConfiguration;
20 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
21
22
23 public class PHPLaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
24         protected static final InterpreterRunner interpreterRunner = new InterpreterRunner();
25         protected static final DebuggerRunner debuggerRunner = new DebuggerRunner();
26
27         public PHPLaunchConfigurationDelegate() {
28                 super();
29         }
30
31         /**
32          * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor)
33          */
34         public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
35                 if (PHPRuntime.getDefault().getSelectedInterpreter() == null)
36                         throw new CoreException(new Status(IStatus.ERROR, PHPLaunchingPlugin.PLUGIN_ID, IStatus.OK, "You must define an interpreter before running PHP.", null));
37
38                 if (mode.equals("debug")) {
39                         debuggerRunner.run(new InterpreterRunnerConfiguration(configuration), launch);
40                 } else {
41                         interpreterRunner.run(new InterpreterRunnerConfiguration(configuration), launch, null);
42                 }               
43         }
44 }