From 1d90063dd0493282921afb6e19dc9cf7ac0637d2 Mon Sep 17 00:00:00 2001 From: scorphus Date: Thu, 8 Nov 2007 01:37:07 +0000 Subject: [PATCH] Workaround for feature request #1154254 (sticky browser URL) that solves bug #1827766 (DBG open wrong debug session) --- .../phpeclipse/ui/IPreferenceConstants.java | 2 ++ .../src/net/sourceforge/phpeclipse/ui/WebUI.java | 3 ++- .../phpeclipse/ui/editor/BrowserUtil.java | 13 +++++++++++-- .../ui/editor/ShowExternalPreviewAction.java | 13 +++++++++++-- .../preferences/PHPPreferencesMessages.properties | 1 + .../preferences/PHPPreviewProjectPreferences.java | 5 +++++ .../phpeclipse/webbrowser/views/BrowserView.java | 19 +++++++++++-------- 7 files changed, 43 insertions(+), 13 deletions(-) diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java index 73cd6f5..7b7d286 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/IPreferenceConstants.java @@ -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 = diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java index adc6a51..a23b7e4 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/WebUI.java @@ -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"); } diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java index 0282fd9..9634f2f 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java @@ -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); 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 8e8c9b8..5fb9670 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 @@ -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 diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties index ec58e3d..0826140 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreferencesMessages.properties @@ -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) diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreviewProjectPreferences.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreviewProjectPreferences.java index 4c521b3..afc85d9 100644 --- a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreviewProjectPreferences.java +++ b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/preferences/PHPPreviewProjectPreferences.java @@ -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 diff --git a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java index c60b9e4..164a840 100644 --- a/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java +++ b/net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java @@ -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 { -- 1.7.1