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 abe117e..154ddff 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 @@ -7,11 +7,14 @@ import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; @@ -54,32 +57,40 @@ public class ShowExternalPreviewAction extends TextEditorAction { } public void refresh(int type) { - IFile fileToParse = getFile(); - if (fileToParse == null) { + IFile previewFile = getFile(); + if (previewFile == null) { // should never happen return; } boolean autoPreview = ProjectPrefUtil.getPreviewBooleanValue( - fileToParse, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); + previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT); boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue( - fileToParse, + previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT); if (autoPreview) { IWorkbenchPage page = WebUI.getActivePage(); try { - IViewPart part = page.findView(BrowserView.ID_BROWSER); - if (part == null) { - part = page.showView(BrowserView.ID_BROWSER); - } else { + // IViewPart part = page.findView(BrowserView.ID_BROWSER); + // if (part == null) { + // part = page.showView(BrowserView.ID_BROWSER); + // } + IViewPart part = page.showView(BrowserView.ID_BROWSER, null, + IWorkbenchPage.VIEW_CREATE); + if (part != null) { if (bringToTopPreview) { page.bringToTop(part); } + // ((BrowserView) part).refresh(); + String localhostURL = getLocalhostURL(null, previewFile); + ((BrowserView) part).refresh(localhostURL); } - if (part != null) { - ((BrowserView) part).refresh(); - } - } catch (Exception e) { + } catch (PartInitException e) { + // ad hoc + WebUI.getDefault().getLog().log( + new Status(IStatus.ERROR, + "net.sourceforge.phpeclipse.ui", IStatus.OK, + "Failed to show Browser View", e)); // PHPeclipsePlugin.log(e); } }