X-Git-Url: http://git.phpeclipse.com 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..8ba89aa 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) { @@ -64,7 +64,7 @@ public class ShowExternalPreviewAction extends TextEditorAction { IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); if (autoPreview) { - IWorkbenchPage page = WebUI.getDefault().getActivePage(); + IWorkbenchPage page = WebUI.getActivePage(); try { IViewPart part = page.findView(BrowserView.ID_BROWSER); if (part == 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