From d380afae5e6a5bb88dc0fc74853dd0d1aee40c4b Mon Sep 17 00:00:00 2001 From: axelcl Date: Thu, 6 Jan 2005 18:43:30 +0000 Subject: [PATCH] Better event handling for browser preview refreshs in Wikipedia plugin --- .../phpeclipse/webbrowser/views/BrowserView.java | 48 ++++++++++++------- 1 files changed, 30 insertions(+), 18 deletions(-) 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 3cd384e..d9a386e 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 @@ -29,7 +29,8 @@ import org.eclipse.ui.part.ViewPart; public class BrowserView extends ViewPart { public final static String ID_BROWSER = "net.sourceforge.phpeclipse.webbrowser.views"; - WebBrowser instance = null; + WebBrowser fInstance = null; + String fUrl = null; /** * Create the example @@ -39,10 +40,10 @@ public class BrowserView extends ViewPart { public void createPartControl(Composite frame) { try { if (WebBrowserUtil.isInternalBrowserOperational()) { - instance = new WebBrowser(frame, true, true); + fInstance = new WebBrowser(frame, true, true); } } catch (Exception e) { - instance = null; + fInstance = null; } } @@ -52,8 +53,8 @@ public class BrowserView extends ViewPart { * @see org.eclipse.ui.part.ViewPart#setFocus */ public void setFocus() { - if (instance != null) { - instance.setFocus(); + if (fInstance != null) { + fInstance.setFocus(); } } @@ -61,16 +62,17 @@ public class BrowserView extends ViewPart { * Called when the View is to be disposed */ public void dispose() { - if (instance != null) { - instance.dispose(); - instance = null; + if (fInstance != null) { + fInstance.dispose(); + fInstance = null; } super.dispose(); } public void setUrl(final String url) { - if (instance != null) { - instance.setURL(url); + if (fInstance != null) { + fUrl = url; + fInstance.setURL(url); // try { // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { // public void run(IProgressMonitor monitor) throws CoreException { @@ -85,8 +87,8 @@ public class BrowserView extends ViewPart { } public void refresh() { - if (instance != null) { - instance.refresh(); + if (fInstance != null) { + fInstance.refresh(); // try { // ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { // public void run(IProgressMonitor monitor) throws CoreException { @@ -100,21 +102,31 @@ public class BrowserView extends ViewPart { } } + public void refresh(String url) { + if (fInstance != null) { + if (fUrl==null || !fUrl.equals(url) ) { + setUrl(url); + } else { + refresh(); + } + } + } + public void addProgressListener(ProgressListener listener) { - if (instance != null) { - instance.addProgressListener(listener); + if (fInstance != null) { + fInstance.addProgressListener(listener); } } public void addStatusTextListener(StatusTextListener listener) { - if (instance != null) { - instance.addStatusTextListener(listener); + if (fInstance != null) { + fInstance.addStatusTextListener(listener); } } public void addTitleListener(TitleListener listener) { - if (instance != null) { - instance.addTitleListener(listener); + if (fInstance != null) { + fInstance.addTitleListener(listener); } } } \ No newline at end of file -- 1.7.1