From 77e189602064d4b6ddcc926343cea967eb73b7dc Mon Sep 17 00:00:00 2001 From: axelcl Date: Sat, 16 Jul 2005 07:51:47 +0000 Subject: [PATCH] Avoid NPE in EntryPointTab --- .../debug/ui/launcher/PHPEntryPointTab.java | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEntryPointTab.java b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEntryPointTab.java index 4ffdf1b..b233034 100644 --- a/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEntryPointTab.java +++ b/net.sourceforge.phpeclipse.debug.ui/src/net/sourceforge/phpdt/internal/debug/ui/launcher/PHPEntryPointTab.java @@ -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 -- 1.7.1