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 a2b5786..4862efa 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 @@ -9,58 +9,59 @@ import org.eclipse.core.resources.IFile; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; - public class BrowserUtil { - public static void showPreview(IFile previewFile, boolean forceDBGPreview, String postFix) { - if (previewFile == null) { - // 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; - } - localhostURL += postFix; - - try { - IWorkbenchPage page = WebUI.getActivePage(); - IViewPart part = page.findView(BrowserView.ID_BROWSER); - if (part == null) { - part = page.showView(BrowserView.ID_BROWSER); - } else { - if (bringToTopPreview) { - page.bringToTop(part); - } - } - ((BrowserView) part).setUrl(localhostURL); - - } catch (Exception e) { -// PHPeclipsePlugin.log(e); - } - } - } + public static void showPreview(IFile previewFile, boolean forceDBGPreview, String postFix) { + if (previewFile == null) { + // 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; + } + 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) { + page.bringToTop(part); + } + ((BrowserView) part).setUrl(localhostURL); + } + // } + + } catch (Exception e) { + // PHPeclipsePlugin.log(e); + } + } + } }