/********************************************************************** Copyright (c) 2000, 2002 IBM Corp. and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/cpl-v10.html Contributors: IBM Corporation - Initial implementation Vicente Fernando - www.alfersoft.com.ar **********************************************************************/ package net.sourceforge.phpeclipse.xdebug.php.launching; import java.io.File; import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import net.sourceforge.phpeclipse.xdebug.core.IXDebugPreferenceConstants; import net.sourceforge.phpeclipse.xdebug.core.XDebugCorePlugin; import net.sourceforge.phpeclipse.xdebug.php.model.XDebugTarget; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.LaunchConfigurationDelegate; public class PHPLaunchConfigurationDelegate extends LaunchConfigurationDelegate { /** * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String, ILaunch, IProgressMonitor) */ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { List commandList = new ArrayList(); String phpInterpreter = configuration.getAttribute(IXDebugConstants.ATTR_PHP_INTERPRETER, (String)null); boolean useDefaultInterpreter= configuration.getAttribute(IXDebugConstants.ATTR_PHP_DEFAULT_INTERPRETER, true); if (useDefaultInterpreter) phpInterpreter=XDebugCorePlugin.getDefault().getPreferenceStore().getString(IXDebugPreferenceConstants.PHP_INTERPRETER_PREFERENCE); File exe = new File(phpInterpreter); if (!exe.exists()) { abort(MessageFormat.format("Specified PHP executable {0} does not exist. Check value of PHP-Interpreter.", new String[]{phpInterpreter}), null); } commandList.add(phpInterpreter); // program name String projectName = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null); IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); if (project == null) { abort("PHP-Script unspecified.", null); } String fileName = configuration.getAttribute(IXDebugConstants.ATTR_PHP_FILE, (String)null); // String program = project.getFile(fileName); IFile file = project.getFile(fileName); // IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(program)); if (!file.exists()) { abort(MessageFormat.format("PHP-Script {0} does not exist.", new String[] {file.getFullPath().toString()}), null); } commandList.add(file.getLocation().toOSString()); // Map nativeEnvVars = DebugPlugin.getDefault().getLaunchManager().getNativeEnvironment(); // Environment variables String[] envp=DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration); // Map envVars=configuration.getAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES, nativeEnvVars); int debugPort=XDebugCorePlugin.getDefault().getPreferenceStore().getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE); if (debugPort<1024) debugPort=IXDebugPreferenceConstants.DEFAULT_DEBUGPORT; // if (mode.equals(ILaunchManager.DEBUG_MODE)) { // nativeEnvVars.put("XDEBUG_CONFIG", "idekey=xdebug_test remote_enable=1"); // } if (mode.equals(ILaunchManager.DEBUG_MODE)) { String[] env; if (envp!=null) { env = new String[envp.length+1]; for(int i=0;i