From db04f4cd789ed35609ba6c6f7d94949a0eb93c68 Mon Sep 17 00:00:00 2001 From: toshihiro Date: Mon, 30 Jul 2007 10:28:49 +0000 Subject: [PATCH] a bit more changes... --- .../ui/editor/ShowExternalPreviewAction.java | 22 +++++++++++++++++++- 1 files changed, 21 insertions(+), 1 deletions(-) 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 154ddff..8e8c9b8 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,6 +7,7 @@ import net.sourceforge.phpeclipse.webbrowser.views.BrowserView; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.preference.IPreferenceStore; @@ -15,6 +16,7 @@ import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; +import org.eclipse.ui.progress.WorkbenchJob; import org.eclipse.ui.texteditor.ITextEditor; import org.eclipse.ui.texteditor.TextEditorAction; @@ -70,6 +72,10 @@ public class ShowExternalPreviewAction extends TextEditorAction { if (autoPreview) { IWorkbenchPage page = WebUI.getActivePage(); + if (page == null) { + // startup stage + return; + } try { // IViewPart part = page.findView(BrowserView.ID_BROWSER); // if (part == null) { @@ -79,7 +85,21 @@ public class ShowExternalPreviewAction extends TextEditorAction { IWorkbenchPage.VIEW_CREATE); if (part != null) { if (bringToTopPreview) { - page.bringToTop(part); + // page.bringToTop(part); + new WorkbenchJob(getClass().getName()) { + public IStatus runInUIThread( + IProgressMonitor monitor) { + IWorkbenchPage page = WebUI.getActivePage(); + if (page != null) { + IViewPart part = page + .findView(BrowserView.ID_BROWSER); + if (part != null) { + page.bringToTop(part); + } + } + return Status.OK_STATUS; + } + }.schedule(); } // ((BrowserView) part).refresh(); String localhostURL = getLocalhostURL(null, previewFile); -- 1.7.1