1) Fixed issue #751: Pathmap 'Edit' button enable/disable handling.
[phpeclipse.git] / net.sourceforge.phpeclipse.xdebug.ui / src / net / sourceforge / phpeclipse / xdebug / ui / php / launching / PHPPathMapTab.java
index 0992e5d..64fdb10 100644 (file)
@@ -16,6 +16,8 @@ import net.sourceforge.phpeclipse.xdebug.ui.MultipleInputDialog;
 import net.sourceforge.phpeclipse.xdebug.ui.php.launching.PHPEnvironmentTab.EnvironmentVariableContentProvider;
 import net.sourceforge.phpeclipse.xdebug.ui.php.launching.PHPEnvironmentTab.EnvironmentVariableLabelProvider;
 */
+//import org.eclipse.core.resources.IProject;
+//import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
@@ -281,16 +283,22 @@ public class PHPPathMapTab extends AbstractLaunchConfigurationTab {
         * @param event the selection change event
         */
        protected void handleTableSelectionChanged(SelectionChangedEvent event) {
-               int size = ((IStructuredSelection)event.getSelection()).size();
-               int idx = fPathMapTable.getTable().getSelectionIndex();
-               int count = fPathMapTable.getTable().getItemCount();
-               if (size==1) {
-                       fEditButton.setEnabled(idx>0);
-                       fUpButton.setEnabled(idx>0);
-                       fDownButton.setEnabled((idx>=0)&&(idx<count-1));
+               int size  = ((IStructuredSelection)event.getSelection()).size();  // Get number of selected items
+               int idx   = fPathMapTable.getTable().getSelectionIndex();         // Get the index of the selected item
+               int count = fPathMapTable.getTable().getItemCount();              // Get the number of entries within the pathmap list
+               
+               if (size == 1) {                                              // If one pathmap entry is selected
+                       fEditButton.setEnabled (idx >= 0);                        // Enable 'Edit' button if a pathmap entry is selected
+                       fUpButton.setEnabled (idx > 0);                           // Enable 'Up' button only if the selected entry is not the very first one
+                       fDownButton.setEnabled ((idx >= 0) && (idx < count-1));   // Enable 'Down' button only if the selected entry is not the very last one
+               }
+               else {                                                        // If nothing selected, or more than one entry selected
+                   fEditButton.setEnabled (false);                           // Disable 'Edit' button 
+                   fUpButton.setEnabled (false);                             // Disable 'Up' button
+                   fDownButton.setEnabled (false);                           // Disable 'Down' button
                }
                
-               fRemoveButton.setEnabled(size > 0);
+               fRemoveButton.setEnabled (size > 0);                          // Enable 'Remove' if at least on entry is selected                    
        }
        
        /**
@@ -470,6 +478,20 @@ public class PHPPathMapTab extends AbstractLaunchConfigurationTab {
                }
        }
 
+       /* (non-Javadoc)
+        * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
+        */
+       public boolean isValid(ILaunchConfiguration launchConfig) {
+               // need to use exception here!
+               setErrorMessage(null);
+               
+               if (fPathMapTable.getTable().getItems().length == 0) {
+                       setErrorMessage("Mappath empty!");
+                       return false;
+               }
+               return true;
+       }
+               
        public String getName() {
                return "Pathmap";
        }