Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.ui / src / net / sourceforge / phpdt / internal / debug / ui / launcher / PHPEnvironmentTab.java
index 50d3212..87e8a33 100644 (file)
@@ -33,7 +33,7 @@ import org.eclipse.swt.events.MouseAdapter;
 import org.eclipse.swt.events.MouseEvent;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
+//import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
@@ -153,8 +153,8 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                tabFolder.setLayoutData(gridData);
 
                // addLoadPathTab(tabFolder);
-               addInterpreterTab(tabFolder);
                addRemoteDebugTab(tabFolder);
+               addInterpreterTab(tabFolder);
        }
 
        protected void addRemoteDebugTab(TabFolder tabFolder) {
@@ -479,22 +479,22 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
        // is customizable on the configuration
        // }
 
-       protected SelectionListener getLoadPathSelectionListener() {
-               return new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent e) {
-                               System.out.println("Loadpath list selection occurred: "
-                                               + e.getSource());
-                       }
-               };
-       }
-
-       protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
-               return new SelectionAdapter() {
-                       public void widgetSelected(SelectionEvent e) {
-                               setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
-                       }
-               };
-       }
+//     protected SelectionListener getLoadPathSelectionListener() {
+//             return new SelectionAdapter() {
+//                     public void widgetSelected(SelectionEvent e) {
+//                             System.out.println("Loadpath list selection occurred: "
+//                                             + e.getSource());
+//                     }
+//             };
+//     }
+
+//     protected SelectionListener getLoadPathDefaultButtonSelectionListener() {
+//             return new SelectionAdapter() {
+//                     public void widgetSelected(SelectionEvent e) {
+//                             setUseLoadPathDefaults(((Button) e.getSource()).getSelection());
+//                     }
+//             };
+//     }
 
        protected void addInterpreterTab(TabFolder tabFolder) {
                Composite interpreterComposite = new Composite(tabFolder, SWT.NONE);
@@ -574,7 +574,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                                IProject project = ResourcesPlugin.getWorkspace().getRoot()
                                                .getProject(projectName);
                                if (project != null) {
-                                       IPath remotePath = project.getLocation();
+                                       IPath remotePath = project.getFullPath();
                                        String fileName = configuration.getAttribute(
                                                        PHPLaunchConfigurationAttribute.FILE_NAME, "");
                                        if (fileName != "") {
@@ -606,9 +606,7 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                } catch (CoreException ce) {
                        fRemoteDebugCheckBox.setSelection(DEFAULT_REMOTE_DEBUG);
                }
-               if (fRemoteDebugCheckBox.getSelection()) {
-                       tabFolder.setSelection(0);
-               }
+               tabFolder.setSelection(fRemoteDebugCheckBox.getSelection() ? 0 : 1);
                try {
                        fRemoteDebugTranslate.setSelection(configuration.getAttribute(
                                        PHPLaunchConfigurationAttribute.REMOTE_DEBUG_TRANSLATE,
@@ -713,10 +711,10 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
        // }
        // }
 
-       protected void setUseLoadPathDefaults(boolean useDefaults) {
-               loadPathListViewer.getList().setEnabled(!useDefaults);
-               // loadPathDefaultButton.setSelection(useDefaults);
-       }
+//     protected void setUseLoadPathDefaults(boolean useDefaults) {
+//             loadPathListViewer.getList().setEnabled(!useDefaults);
+//             // loadPathDefaultButton.setSelection(useDefaults);
+//     }
 
        protected void initializeInterpreterSelection(
                        ILaunchConfiguration configuration) {
@@ -727,8 +725,16 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
                } catch (CoreException e) {
                        log(e);
                }
-               if (interpreterName != null && !interpreterName.equals(""))
+               if (interpreterName != null && !interpreterName.equals("")) {
                        interpreterCombo.select(interpreterCombo.indexOf(interpreterName));
+               }
+               if (interpreterCombo.getSelectionIndex() < 0) {
+                       // previous definition had been deleted
+                       ((ILaunchConfigurationWorkingCopy) configuration).setAttribute(
+                                       PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
+                       setErrorMessage(PHPDebugUiMessages
+                                       .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
+               }
        }
 
        protected void initializeInterpreterCombo(Combo interpreterCombo) {
@@ -829,12 +835,15 @@ public class PHPEnvironmentTab extends AbstractLaunchConfigurationTab {
 
        public boolean isValid(ILaunchConfiguration launchConfig) {
                try {
-                       String selectedInterpreter = launchConfig.getAttribute(
-                                       PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
-                       if (selectedInterpreter.length() == 0) {
-                               setErrorMessage(PHPDebugUiMessages
-                                               .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
-                               return false;
+                       if (launchConfig.getAttribute(
+                                       PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "")
+                                       .equals("")) {
+                               if (!launchConfig.getAttribute(
+                                               PHPLaunchConfigurationAttribute.REMOTE_DEBUG, false)) {
+                                       setErrorMessage(PHPDebugUiMessages
+                                                       .getString("LaunchConfigurationTab.PHPEnvironment.interpreter_not_selected_error_message"));
+                                       return false;
+                               }
                        }
                } catch (CoreException e) {
                        log(e);