removed unused methods: /net.sourceforge.phpeclipse.xdebug.core/src/net/sourceforge...
[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.DebugPlugin;
19 import org.eclipse.debug.core.ILaunch;
20 import org.eclipse.debug.core.ILaunchConfiguration;
21 import org.eclipse.debug.core.ILaunchManager;
22 import org.eclipse.debug.core.Launch;
23 import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
24 import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
25
26 public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate {
27
28         protected static final InterpreterRunner interpreterRunner;
29
30         protected static final DebuggerRunner debuggerRunner;
31
32         static {
33                 interpreterRunner = new InterpreterRunner();
34                 debuggerRunner = new DebuggerRunner();
35         }
36
37         /**
38          * (non-Javadoc)
39          * 
40          * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate2#getLaunch(org.eclipse.debug.core.ILaunchConfiguration,
41          *      java.lang.String)
42          */
43         public ILaunch getLaunch(ILaunchConfiguration configuration, String mode)
44                         throws CoreException {
45                 PHPSourceLocator locator = new PHPSourceLocator();
46                 locator.initializeDefaults(configuration);
47                 return new Launch(configuration, mode, locator);
48         }
49
50         /**
51          * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String,
52          *      ILaunch, IProgressMonitor)
53          */
54         public void launch(ILaunchConfiguration configuration, String mode,
55                         ILaunch launch, IProgressMonitor monitor) throws CoreException {
56                 //if (PHPRuntime.getDefault().getSelectedInterpreter() == null) {
57                 if (configuration.getAttribute(
58                                 PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "")
59                                 .equals("")) {
60                         if (!configuration.getAttribute(
61                                         PHPLaunchConfigurationAttribute.REMOTE_DEBUG, false)
62                                         && mode.equals("debug") || mode.equals("run")) {
63                                 String pid = PHPLaunchingPlugin.PLUGIN_ID;
64                                 String msg = "You must define an interpreter before running PHP.";
65                                 IStatus s = new Status(IStatus.ERROR, pid, IStatus.OK, msg,
66                                                 null);
67                                 throw new CoreException(s);
68                         }
69                 }
70
71                 InterpreterRunnerConfiguration conf = new InterpreterRunnerConfiguration(
72                                 configuration);
73                 ILaunchManager m = DebugPlugin.getDefault().getLaunchManager();
74                 conf.setEnvironment(m.getEnvironment(configuration));
75                 if (mode.equals("debug")) {
76                         debuggerRunner.run(conf, launch);
77                 } else {
78                         interpreterRunner.run(conf, launch);
79                 }
80         }
81 }