Avoid NPE in EntryPointTab
authoraxelcl <axelcl>
Sat, 16 Jul 2005 07:51:47 +0000 (07:51 +0000)
committeraxelcl <axelcl>
Sat, 16 Jul 2005 07:51:47 +0000 (07:51 +0000)
net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEntryPointTab.java

index 4ffdf1b..b233034 100644 (file)
@@ -31,7 +31,9 @@ import org.eclipse.ui.IWorkbenchPage;
 
 public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
        protected String originalFileName, originalProjectName;
+
        protected PHPProjectSelector projectSelector;
+
        protected PHPFileSelector fileSelector;
 
        public PHPEntryPointTab() {
@@ -43,7 +45,8 @@ public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
 
                new Label(composite, SWT.NONE).setText(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEntryPoint.projectLabel"));
                projectSelector = new PHPProjectSelector(composite);
-               projectSelector.setBrowseDialogMessage(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEntryPoint.projectSelectorMessage"));
+               projectSelector.setBrowseDialogMessage(PHPDebugUiMessages
+                               .getString("LaunchConfigurationTab.PHPEntryPoint.projectSelectorMessage"));
                projectSelector.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
                projectSelector.addModifyListener(new ModifyListener() {
                        public void modifyText(ModifyEvent evt) {
@@ -78,7 +81,9 @@ public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
                        if (part != null) {
                                IEditorInput input = part.getEditorInput();
                                IResource file = (IResource) input.getAdapter(IResource.class);
-                               return file.getProject();
+                               if (file != null) {
+                                       return file.getProject();
+                               }
                        }
                }
                return null;
@@ -106,7 +111,8 @@ public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
        public void performApply(ILaunchConfigurationWorkingCopy configuration) {
                configuration.setAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, projectSelector.getSelectionText());
                IFile file = fileSelector.getSelection();
-               configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_NAME, file == null ? "" : file.getProjectRelativePath().toString());
+               configuration.setAttribute(PHPLaunchConfigurationAttribute.FILE_NAME, file == null ? "" : file.getProjectRelativePath()
+                               .toString());
        }
 
        protected Composite createPageRoot(Composite parent) {
@@ -125,7 +131,7 @@ public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
 
        public boolean isValid(ILaunchConfiguration launchConfig) {
                try {
-                               
+
                        String projectName = launchConfig.getAttribute(PHPLaunchConfigurationAttribute.PROJECT_NAME, "");
                        if (projectName.length() == 0) {
                                setErrorMessage(PHPDebugUiMessages.getString("LaunchConfigurationTab.PHPEntryPoint.invalidProjectSelectionMessage"));
@@ -140,7 +146,7 @@ public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
                } catch (CoreException e) {
                        log(e);
                }
-               
+
                setErrorMessage(null);
                return true;
        }
@@ -155,6 +161,6 @@ public class PHPEntryPointTab extends AbstractLaunchConfigurationTab {
 
        public Image getImage() {
                return PHPUiImages.get(PHPUiImages.IMG_CTOOLS_PHP_PAGE);
-  }
+       }
 
 }
\ No newline at end of file