Workaround for feature request #1154254 (sticky browser URL) that solves bug #1827766...
authorscorphus <scorphus>
Thu, 8 Nov 2007 01:37:07 +0000 (01:37 +0000)
committerscorphus <scorphus>
Thu, 8 Nov 2007 01:37:07 +0000 (01:37 +0000)
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreviewProjectPreferences.java
net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java

index 73cd6f5..7b7d286 100644 (file)
@@ -12,6 +12,8 @@ public interface IPreferenceConstants {
        public static final String PHP_AUTO_PREVIEW_DEFAULT = "_auto_preview";
 
        public static final String PHP_BRING_TO_TOP_PREVIEW_DEFAULT = "_bring_to_top_preview";
+
+       public static final String PHP_STICKY_BROWSER_URL_DEFAULT = "_sticky_browser_url";
        // public static final String PHP_SHOW_HTML_FILES_LOCAL =
        // "_show_html_files_local";
        // public static final String PHP_SHOW_XML_FILES_LOCAL =
index adc6a51..a23b7e4 100644 (file)
@@ -8,7 +8,7 @@
  * Contributors:
  *     Christopher Lenz - initial implementation
  *
- * $Id: WebUI.java,v 1.10 2007-08-23 06:42:09 toshihiro Exp $
+ * $Id: WebUI.java,v 1.11 2007-11-08 01:37:06 scorphus Exp $
  */
 
 package net.sourceforge.phpeclipse.ui;
@@ -173,6 +173,7 @@ public class WebUI extends AbstractUIPlugin implements IPreferenceConstants {
 
                store.setDefault(PHP_AUTO_PREVIEW_DEFAULT, "false");
                store.setDefault(PHP_BRING_TO_TOP_PREVIEW_DEFAULT, "false");
+               store.setDefault(PHP_STICKY_BROWSER_URL_DEFAULT, "false");
                // store.setDefault(PHP_SHOW_HTML_FILES_LOCAL, "true");
                // store.setDefault(PHP_SHOW_XML_FILES_LOCAL, "false");
        }
index 0282fd9..9634f2f 100644 (file)
@@ -157,8 +157,17 @@ public class BrowserUtil {
                                        }
                                        if (view != null) {
                                                IShowInTarget target = getShowInTarget(view);
-                                               if (target != null && target.show(context)) {
-                                                       // success
+                                               boolean stickyBrowserURL = ProjectPrefUtil.getPreviewBooleanValue(
+                                                               previewFile,
+                                                               IPreferenceConstants.PHP_STICKY_BROWSER_URL_DEFAULT);
+                                               if (target != null) {
+                                                       if (stickyBrowserURL
+                                                                       && ((BrowserView) target).getUrl() != null
+                                                                       && ((BrowserView) target).getUrl().length() > 0) {
+                                                               ((BrowserView) target).refresh();
+                                                       } else {
+                                                               target.show(context);
+                                                       }
                                                }
                                                ((WorkbenchPage) page)
                                                                .performedShowIn(BrowserView.ID_BROWSER);
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
index ec58e3d..0826140 100644 (file)
@@ -24,6 +24,7 @@ PHPMiscProjectPreferences.obfuscator=Obfuscator directory:
 
 PHPPreviewProjectPreferences.auto_preview=Refresh PHP browser view when opening editor
 PHPPreviewProjectPreferences.bring_to_top_preview=Show PHP browser view when opening editor
+PHPPreviewProjectPreferences.sticky_browser_url=Make PHP browser view URL sticky
 PHPPreviewProjectPreferences.show_html_files_local=Show HTML files as local resources (no 'http://' url)
 PHPPreviewProjectPreferences.show_xml_files_local=Show XML files as local resources (no 'http://' url)
 
index 4c521b3..afc85d9 100644 (file)
@@ -49,6 +49,11 @@ public class PHPPreviewProjectPreferences extends FieldEditorOverlayPage
                                PHPPreferencesMessages
                                                .getString("PHPPreviewProjectPreferences.bring_to_top_preview"),
                                composite));
+               addField(new BooleanFieldEditor(
+                               IPreferenceConstants.PHP_STICKY_BROWSER_URL_DEFAULT,
+                               PHPPreferencesMessages
+                                               .getString("PHPPreviewProjectPreferences.sticky_browser_url"),
+                               composite));
                // addField(new BooleanFieldEditor(
                // IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL,
                // PHPPreferencesMessages
index c60b9e4..164a840 100644 (file)
@@ -88,15 +88,18 @@ public class BrowserView extends ViewPart implements IShowInTarget {
                super.dispose();
        }
 
+       public String getUrl() {
+               if (fInstance != null) {
+                       return fInstance.getURL();
+               } else {
+                       return null;
+               }
+       }
+
        public void setUrl(final String url) {
-               if (fInstance != null) {
-              if (fInstance.getURL() != null && fInstance.getURL().length() > 0) {
-                fUrl = fInstance.getURL();
-                fInstance.setURL(fUrl);
-            } else {
-                fUrl = url;
-                fInstance.setURL(url);
-            }
+               if (fInstance != null) {
+                               fUrl = url;
+                               fInstance.setURL(url);
                        // try {
                        // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
                        // public void run(IProgressMonitor monitor) throws CoreException {