X-Git-Url: http://secure.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 941829e..9b53e0e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/ShowExternalPreviewAction.java @@ -8,10 +8,10 @@ package net.sourceforge.phpeclipse.phpeditor; * Contributors: IBM Corporation - Initial implementation Klaus Hartlage - * www.eclipseproject.de ******************************************************************************/ +import net.sourceforge.phpeclipse.IPreferenceConstants; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.actions.PHPEclipseShowAction; import net.sourceforge.phpeclipse.views.browser.BrowserView; - import org.eclipse.core.resources.IFile; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; @@ -20,6 +20,7 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; +import net.sourceforge.phpeclipse.overlaypages.Util; //import org.eclipse.update.internal.ui.UpdatePerspective; //import org.eclipse.update.internal.ui.views.IEmbeddedWebBrowser; /** @@ -27,7 +28,6 @@ import org.eclipse.ui.texteditor.TextEditorAction; */ public class ShowExternalPreviewAction extends TextEditorAction { private static ShowExternalPreviewAction instance = new ShowExternalPreviewAction(); - protected IFile fileToParse; /** * Constructs and updates the action. */ @@ -42,26 +42,35 @@ public class ShowExternalPreviewAction extends TextEditorAction { * Code called when the action is fired. */ public void run() { - fileToParse = getFile(); + IFile fileToParse = getFile(); if (fileToParse == null) { // should never happen return; } - String localhostURL; - if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, fileToParse)) == null) { - return; - } - IWorkbenchPage page = PHPeclipsePlugin.getActivePage(); - try { - IViewPart part = page.findView(BrowserView.ID_BROWSER); - if (part == null) { - part = page.showView(BrowserView.ID_BROWSER); - } else { - page.bringToTop(part); + boolean autoPreview = Util.getPreviewBooleanValue(fileToParse, + IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); + boolean bringToTopPreview = Util.getPreviewBooleanValue(fileToParse, + IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); + if (autoPreview) { + String localhostURL; + if ((localhostURL = PHPEclipseShowAction.getLocalhostURL(null, + fileToParse)) == null) { + return; + } + IWorkbenchPage page = PHPeclipsePlugin.getActivePage(); + try { + 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 (PartInitException e) { + PHPeclipsePlugin.log(e); } - ((BrowserView) part).setUrl(localhostURL); - } catch (PartInitException e) { - PHPeclipsePlugin.log(e); } } /**