1) Fire 'Terminate' event on every thread on script termination. Fixes bug #1548528.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.ui / src / net / sourceforge / phpeclipse / xdebug / ui / php / launching / PHPMainTab.java
index 03e5e3e..ba510c2 100644 (file)
@@ -1,5 +1,6 @@
 package net.sourceforge.phpeclipse.xdebug.ui.php.launching;
 
+import java.io.File;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 import net.sourceforge.phpdt.internal.ui.util.PHPFileSelector;
 import net.sourceforge.phpdt.internal.ui.util.PHPProjectSelector;
@@ -9,6 +10,7 @@ import net.sourceforge.phpeclipse.xdebug.php.launching.IXDebugConstants;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
@@ -28,7 +30,6 @@ import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.FileDialog;
 import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
@@ -48,7 +49,6 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
        private Button fUseDefaultInterpreterButton;
        private Button fInterpreterButton;
        private Text fInterpreterText;
-       private Label fInterpreterLabel;
 
        public PHPMainTab() {
                super();
@@ -56,7 +56,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
 
        public void createControl(Composite parent) {
                Font font = parent.getFont();
-               
+
                Composite comp = new Composite(parent, SWT.NONE);
                setControl(comp);
 //             PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_MAIN_TAB);
@@ -64,17 +64,17 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                topLayout.verticalSpacing = 0;
                comp.setLayout(topLayout);
                comp.setFont(font);
-               
+
                createProjectEditor(comp);
                createVerticalSpacer(comp, 1);
                createMainTypeEditor(comp);
                createVerticalSpacer(comp, 1);
                createInterpreterEditor(comp);
        }
-       
+
        /**
         * Creates the widgets for specifying a main type.
-        * 
+        *
         * @param parent the parent composite
         */
        private void createProjectEditor(Composite parent) {
@@ -96,18 +96,18 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                                updateLaunchConfigurationDialog();
                        }
                });
-       }       
+       }
+
 
-       
        /**
         * Creates the widgets for specifying a php file.
-        * 
+        *
         * @param parent the parent composite
         */
        private void createMainTypeEditor(Composite parent) {
                Font font= parent.getFont();
                Group mainGroup= new Group(parent, SWT.NONE);
-               mainGroup.setText("File: "); 
+               mainGroup.setText("File: ");
                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
                mainGroup.setLayoutData(gd);
                GridLayout layout = new GridLayout();
@@ -124,30 +124,23 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                        }
                });
        }
-       
+
        /**
         * Creates the widgets for specifying debug settings.
-        * 
+        *
         * @param parent the parent composite
         */
        private void createInterpreterEditor(Composite parent) {
                Font font= parent.getFont();
                Group interpreterGroup= new Group(parent, SWT.NONE);
-               interpreterGroup.setText("Interpreter: "); 
+               interpreterGroup.setText("Interpreter: ");
                GridData gd = new GridData(GridData.FILL_HORIZONTAL);
                interpreterGroup.setLayoutData(gd);
                GridLayout layout = new GridLayout();
                layout.numColumns = 2;
                interpreterGroup.setLayout(layout);
                interpreterGroup.setFont(font);
-               
-//             fInterpreterLabel= new Label(interpreterGroup, SWT.NONE);
-//             fInterpreterLabel.setText("Interpreter: "); 
-//             gd= new GridData();
-//             gd.horizontalSpan = 2;
-//             fInterpreterLabel.setLayoutData(gd);
-//             fInterpreterLabel.setFont(font);
-               
+
                fInterpreterText= new Text(interpreterGroup, SWT.SINGLE | SWT.BORDER);
                gd= new GridData(GridData.FILL_HORIZONTAL);
                fInterpreterText.setLayoutData(gd);
@@ -158,14 +151,14 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                        }
                });
 
-               
+
                fInterpreterButton= createPushButton(interpreterGroup,"Browse..", null);
                fInterpreterButton.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent event) {
                                handleBrowseSellected(event);
                        }
                });
-               
+
                fUseDefaultInterpreterButton = new Button(interpreterGroup,SWT.CHECK);
                fUseDefaultInterpreterButton.setText("Use default interpreter");
                gd = new GridData(GridData.FILL_HORIZONTAL);
@@ -178,7 +171,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                });
 
        }
-       
+
        /**
         * Set the appropriate enabled state for the appletviewqer text widget.
         */
@@ -191,7 +184,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                        fInterpreterButton.setEnabled(true);
                }
        }
-       
+
        /**
         * Returns whether the default appletviewer is to be used
         */
@@ -260,7 +253,7 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                        if (file != null) {
                                fileSelector.setSelectionText(file);
                        }
-                       
+
                        String interpreterFile=configuration.getAttribute(IXDebugConstants.ATTR_PHP_INTERPRETER, (String) null);
                        if(interpreterFile!=null)
                                fInterpreterText.setText(interpreterFile);
@@ -287,35 +280,43 @@ public class PHPMainTab extends AbstractLaunchConfigurationTab {
                configuration.setAttribute(IXDebugConstants.ATTR_PHP_INTERPRETER, this.fInterpreterText.getText());
 
        }
-       
+
        /* (non-Javadoc)
         * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
         */
        public boolean isValid(ILaunchConfiguration launchConfig) {
-               try {
-
-                       String projectName = launchConfig.getAttribute(IXDebugConstants.ATTR_PHP_PROJECT, "");
-                       if (projectName.length() == 0) {
-                               setErrorMessage("Iinvalid Project");
-                               return false;
-                       }
-
-                       String fileName = launchConfig.getAttribute(IXDebugConstants.ATTR_PHP_FILE, "");
-                       if (fileName.length() == 0) {
-                               setErrorMessage("Invalid File");
+               setErrorMessage(null);
+               String projectName=projectSelector.getSelectionText().trim();
+               IProject project=ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+               if (!project.exists()) {
+                       setErrorMessage("Project does not exist");
+                       return false;
+               }
+               String fileName=fileSelector.getSelectionText().trim();
+               if (fileName.equals("")) {
+                       setErrorMessage("No file selected.");
+                       return false;
+               }
+               IFile file=project.getFile(fileName);
+               if (!file.exists()) {
+                       setErrorMessage("File does not exist");
+                       return false;
+               }
+               if (!fUseDefaultInterpreterButton.getSelection()) {
+                       File exe = new File(fInterpreterText.getText());
+                       System.out.println(exe.toString());
+                       if (!exe.exists()) {
+                               setErrorMessage("Invalid Interpreter");
                                return false;
                        }
-               } catch (CoreException e) {
-//                     XDebugCorePlugin.log(e);
                }
-
-               setErrorMessage(null);
-               return super.isValid(launchConfig);
+               return true;
        }
+
        public Image getImage() {
                return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP_PAGE);
        }
-       
+
        public String getName() {
                return "Main";
        }