Workaround for feature request #1154254 (sticky browser URL) that solves bug #1827766...
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / ui / editor / ShowExternalPreviewAction.java
index 8e8c9b8..5fb9670 100644 (file)
@@ -69,6 +69,9 @@ public class ShowExternalPreviewAction extends 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();
@@ -102,8 +105,14 @@ public class ShowExternalPreviewAction extends TextEditorAction {
                                                }.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