X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java index 4862efa..e9e2230 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java @@ -16,50 +16,45 @@ public class BrowserUtil { // should never happen return; } - String extension = previewFile.getFileExtension().toLowerCase(); - boolean autoPreview = forceDBGPreview; - boolean bringToTopPreview = true; - boolean showHTMLFilesLocal = false; - boolean showXMLFilesLocal = false; - boolean isHTMLFileName = false; - boolean isXMLFileName = false; - if (!forceDBGPreview) { - autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); - - bringToTopPreview = ProjectPrefUtil - .getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); - showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL); - showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL); - isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension); - isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension); - } - if (autoPreview) { - String localhostURL; - if (showHTMLFilesLocal && isHTMLFileName) { - localhostURL = previewFile.getLocation().toString(); - } else if (showXMLFilesLocal && isXMLFileName) { - localhostURL = previewFile.getLocation().toString(); - } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) { - return; + IWorkbenchPage page = WebUI.getActivePage(); + if (page!=null && page.isEditorAreaVisible()) { + String extension = previewFile.getFileExtension().toLowerCase(); + boolean autoPreview = forceDBGPreview; + boolean showHTMLFilesLocal = false; + boolean showXMLFilesLocal = false; + boolean isHTMLFileName = false; + boolean isXMLFileName = false; + if (!forceDBGPreview) { + autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); + + showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL); + showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL); + isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension); + isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension); } - localhostURL += postFix; + if (autoPreview) { + String localhostURL; + if (showHTMLFilesLocal && isHTMLFileName) { + localhostURL = previewFile.getLocation().toString(); + } else if (showXMLFilesLocal && isXMLFileName) { + localhostURL = previewFile.getLocation().toString(); + } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) { + return; + } + localhostURL += postFix; - try { - IWorkbenchPage page = WebUI.getActivePage(); - IViewPart part = page.showView(BrowserView.ID_BROWSER, null, IWorkbenchPage.VIEW_VISIBLE); - // if (part == null) { - // part = page.showView(BrowserView.ID_BROWSER); - // } else { - if (part != null) { - if (bringToTopPreview) { + try { + IViewPart part = page.showView(BrowserView.ID_BROWSER, null, IWorkbenchPage.VIEW_VISIBLE); + if (part == null) { + part = page.showView(BrowserView.ID_BROWSER); + } else { page.bringToTop(part); } ((BrowserView) part).setUrl(localhostURL); - } - // } - } catch (Exception e) { - // PHPeclipsePlugin.log(e); + } catch (Exception e) { + // PHPeclipsePlugin.log(e); + } } } }