From: axelcl Date: Thu, 28 Apr 2005 17:10:58 +0000 (+0000) Subject: Avoid NPE when deleting a project X-Git-Url: http://git.phpeclipse.com?hp=20623ebfbd798f9290f885b4d9c5e2358d125e57 Avoid NPE when deleting a project --- diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java index bef108a..7b6dd8e 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java @@ -52,7 +52,7 @@ public class ShowExternalPreviewAction extends TextEditorAction { IFile previewFile = getFile(); BrowserUtil.showPreview(previewFile, false, ""); } - + public void refresh(int type) { IFile fileToParse = getFile(); if (fileToParse == null) { @@ -99,22 +99,25 @@ public class ShowExternalPreviewAction extends TextEditorAction { } public static String getLocalhostURL(IPreferenceStore store, IFile file) { - if (store == null) { - store = WebUI.getDefault().getPreferenceStore(); - } - // IPath path = file.getFullPath(); - String localhostURL = file.getLocation().toString(); - String lowerCaseFileName = localhostURL.toLowerCase(); - // String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); - IPath documentRootPath = ProjectPrefUtil.getDocumentRoot(file.getProject()); - String documentRoot = documentRootPath.toString().toLowerCase(); - if (lowerCaseFileName.startsWith(documentRoot)) { - localhostURL = localhostURL.substring(documentRoot.length()); - } else { - return null; + if (file != null) { + if (store == null) { + store = WebUI.getDefault().getPreferenceStore(); + } + // IPath path = file.getFullPath(); + String localhostURL = file.getLocation().toString(); + String lowerCaseFileName = localhostURL.toLowerCase(); + // String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + IPath documentRootPath = ProjectPrefUtil.getDocumentRoot(file.getProject()); + String documentRoot = documentRootPath.toString().toLowerCase(); + if (lowerCaseFileName.startsWith(documentRoot)) { + localhostURL = localhostURL.substring(documentRoot.length()); + } else { + return null; + } + // return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL; + return ProjectPrefUtil.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) + + localhostURL; } - // return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL; - return ProjectPrefUtil.getMiscProjectsPreferenceValue(file.getProject(), IPreferenceConstants.PHP_LOCALHOST_PREF) - + localhostURL; + return "http://localhost"; } } \ No newline at end of file