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;
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;
boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(
previewFile,
IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
+ boolean stickyBrowserURL = ProjectPrefUtil.getPreviewBooleanValue(
+ previewFile,
+ IPreferenceConstants.PHP_STICKY_BROWSER_URL_DEFAULT);
if (autoPreview) {
IWorkbenchPage page = WebUI.getActivePage();
+ if (page == null) {
+ // startup stage
+ return;
+ }
try {
// IViewPart part = page.findView(BrowserView.ID_BROWSER);
// if (part == null) {
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);
- ((BrowserView) part).refresh(localhostURL);
+ if (stickyBrowserURL
+ && ((BrowserView) part).getUrl() != null
+ && ((BrowserView) part).getUrl().length() > 0) {
+ ((BrowserView) part).refresh();
+ } else {
+ String localhostURL = getLocalhostURL(null, previewFile);
+ ((BrowserView) part).refresh(localhostURL);
+ }
}
} catch (PartInitException e) {
// ad hoc