A massive organize imports and formatting of the sources using default Eclipse code...
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.core / src / net / sourceforge / phpeclipse / xdebug / php / launching / PHPLaunchConfigurationDelegate.java
index 6117961..5880ca0 100644 (file)
@@ -38,93 +38,118 @@ 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)
+        * @see ILaunchConfigurationDelegate#launch(ILaunchConfiguration, String,
+        *      ILaunch, IProgressMonitor)
         */
-       public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+       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);
+               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);
                // Just to get sure that the interpreter exists
                if (!exe.exists()) {
-                       abort(MessageFormat.format("Specified PHP executable {0} does not exist. Check value of PHP-Interpreter.", new String[]{phpInterpreter}), null);
+                       abort(
+                                       MessageFormat
+                                                       .format(
+                                                                       "Specified PHP executable {0} does not exist. Check value of PHP-Interpreter.",
+                                                                       new String[] { phpInterpreter }), null);
                }
                commandList.add(phpInterpreter);
-               
+
                // Project name
-               String projectName = configuration.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, (String)null);
-               IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
-//              Just to get sure that the project exists
+               String projectName = configuration.getAttribute(
+                               IXDebugConstants.ATTR_PHP_PROJECT, (String) null);
+               IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(
+                               projectName);
+               // Just to get sure that the project exists
                if (project == null) {
                        abort("Project does not exist.", null);
                }
-               String fileName = configuration.getAttribute(IXDebugConstants.ATTR_PHP_FILE, (String)null);
+               String fileName = configuration.getAttribute(
+                               IXDebugConstants.ATTR_PHP_FILE, (String) null);
 
                IFile file = project.getFile(fileName);
                // Just to get sure that the script exists
                if (!file.exists()) {
-                       abort(MessageFormat.format("PHP-Script {0} does not exist.", new String[] {file.getFullPath().toString()}), null);
+                       abort(MessageFormat.format("PHP-Script {0} does not exist.",
+                                       new String[] { file.getFullPath().toString() }), null);
                }
-               
+
                commandList.add(file.getLocation().toOSString());
 
                // Get de Debugport form the Launchconfiguration or from the preferences
-               int debugPort  = configuration.getAttribute(IXDebugConstants.ATTR_PHP_DEBUGPORT,-1);
-               boolean useDefaultPort= configuration.getAttribute(IXDebugConstants.ATTR_PHP_DEFAULT_DEBUGPORT, true);
+               int debugPort = configuration.getAttribute(
+                               IXDebugConstants.ATTR_PHP_DEBUGPORT, -1);
+               boolean useDefaultPort = configuration.getAttribute(
+                               IXDebugConstants.ATTR_PHP_DEFAULT_DEBUGPORT, true);
                if (useDefaultPort)
-                       debugPort=XDebugCorePlugin.getDefault().getPreferenceStore().getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE);
-               if (debugPort<1024)
-                       debugPort=IXDebugPreferenceConstants.DEFAULT_DEBUGPORT;
+                       debugPort = XDebugCorePlugin.getDefault().getPreferenceStore()
+                                       .getInt(IXDebugPreferenceConstants.DEBUGPORT_PREFERENCE);
+               if (debugPort < 1024)
+                       debugPort = IXDebugPreferenceConstants.DEFAULT_DEBUGPORT;
 
-               String[] envp=DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
+               String[] envp = DebugPlugin.getDefault().getLaunchManager()
+                               .getEnvironment(configuration);
                // appends the environment to the native environment
-               if (envp==null) {
-                       Map stringVars = DebugPlugin.getDefault().getLaunchManager().getNativeEnvironment();
-                       int idx=0;
-                       envp= new String[stringVars.size()];
+               if (envp == null) {
+                       Map stringVars = DebugPlugin.getDefault().getLaunchManager()
+                                       .getNativeEnvironment();
+                       int idx = 0;
+                       envp = new String[stringVars.size()];
                        for (Iterator i = stringVars.keySet().iterator(); i.hasNext();) {
                                String key = (String) i.next();
                                String value = (String) stringVars.get(key);
-                               envp[idx++]=key+"="+value;
+                               envp[idx++] = key + "=" + value;
                        }
                }
                if (mode.equals(ILaunchManager.DEBUG_MODE)) {
-                       String[] env = new String[envp.length+1];
-                       for(int i=0;i<envp.length;i++)
-                                       env[i+1]=envp[i];
-                       env[0]="XDEBUG_CONFIG=idekey=xdebug_test remote_enable=1";
-                       envp=env;
+                       String[] env = new String[envp.length + 1];
+                       for (int i = 0; i < envp.length; i++)
+                               env[i + 1] = envp[i];
+                       env[0] = "XDEBUG_CONFIG=idekey=xdebug_test remote_enable=1";
+                       envp = env;
                }
 
-               String[] commandLine = (String[]) commandList.toArray(new String[commandList.size()]);
-               Process process = DebugPlugin.exec(commandLine, null,envp);
+               String[] commandLine = (String[]) commandList
+                               .toArray(new String[commandList.size()]);
+               Process process = DebugPlugin.exec(commandLine, null, envp);
                IProcess p = DebugPlugin.newProcess(launch, process, phpInterpreter);
                if (mode.equals(ILaunchManager.DEBUG_MODE)) {
                        IDebugTarget target = new XDebugTarget(launch, p, debugPort);
                        launch.addDebugTarget(target);
                }
        }
-       
+
        /**
-        * Throws an exception with a new status containing the given
-        * message and optional exception.
+        * Throws an exception with a new status containing the given message and
+        * optional exception.
         * 
-        * @param message error message
-        * @param e underlying exception
+        * @param message
+        *            error message
+        * @param e
+        *            underlying exception
         * @throws CoreException
         */
        private void abort(String message, Throwable e) throws CoreException {
-               // TODO: the plug-in code should be the example plug-in, not Perl debug model id
-               throw new CoreException(new Status(IStatus.ERROR, IXDebugConstants.ID_PHP_DEBUG_MODEL, 0, message, e));
+               // TODO: the plug-in code should be the example plug-in, not Perl debug
+               // model id
+               throw new CoreException(new Status(IStatus.ERROR,
+                               IXDebugConstants.ID_PHP_DEBUG_MODEL, 0, message, e));
        }
 
 }