X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java index e76037f..32256fa 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java @@ -8,6 +8,7 @@ package net.sourceforge.phpeclipse.phpeditor; * Contributors: IBM Corporation - Initial implementation Klaus Hartlage - * www.eclipseproject.de ******************************************************************************/ +import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil; import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.actions.PHPEclipseShowAction; @@ -44,19 +45,25 @@ public static ShowExternalPreviewAction getInstance() { * Code called when the action is fired. */ public void run() { - IFile fileToParse = getFile(); - if (fileToParse == null) { + IFile previewFile = getFile(); + if (previewFile == null) { // should never happen return; } - boolean autoPreview = Util.getPreviewBooleanValue(fileToParse, + boolean autoPreview = Util.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); - boolean bringToTopPreview = Util.getPreviewBooleanValue(fileToParse, + boolean bringToTopPreview = Util.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); - if (autoPreview) { + boolean showHTMLFilesLocal = Util.getPreviewBooleanValue(previewFile, + IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL); + boolean isPHPFileName = PHPFileUtil.isPHPFileName(previewFile.getLocation().toString()); + + if (autoPreview) { String localhostURL; - if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, - fileToParse)) == null) { + if (showHTMLFilesLocal && (!isPHPFileName)) { + localhostURL = previewFile.getLocation().toString(); + } else if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, + previewFile)) == null) { return; } IWorkbenchPage page = PHPeclipsePlugin.getActivePage(); @@ -71,11 +78,12 @@ public static ShowExternalPreviewAction getInstance() { } ((BrowserView) part).setUrl(localhostURL); - } catch (PartInitException e) { - PHPeclipsePlugin.log(e); + } catch (Exception e) { + //PHPeclipsePlugin.log(e); } } } + public void refresh() { IFile fileToParse = getFile(); if (fileToParse == null) { @@ -99,8 +107,8 @@ public static ShowExternalPreviewAction getInstance() { } ((BrowserView) part).refresh(); - } catch (PartInitException e) { - PHPeclipsePlugin.log(e); + } catch (Exception e) { + // PHPeclipsePlugin.log(e); } } }