Fixed: 1760857 - Avoid refreshing the preview when phpeditor got focus.
authortoshihiro <toshihiro>
Sun, 29 Jul 2007 06:39:49 +0000 (06:39 +0000)
committertoshihiro <toshihiro>
Sun, 29 Jul 2007 06:39:49 +0000 (06:39 +0000)
If Browser View is already showing the URL, do nothing.

net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/ShowExternalPreviewAction.java
net.sourceforge.phpeclipse.webbrowser/src/net/sourceforge/phpeclipse/webbrowser/views/BrowserView.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java

index abe117e..c471f50 100644 (file)
@@ -54,15 +54,15 @@ public class ShowExternalPreviewAction extends TextEditorAction {
        }
 
        public void refresh(int type) {
-               IFile fileToParse = getFile();
-               if (fileToParse == null) {
+               IFile previewFile = getFile();
+               if (previewFile == null) {
                        // should never happen
                        return;
                }
                boolean autoPreview = ProjectPrefUtil.getPreviewBooleanValue(
-                               fileToParse, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
+                               previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
                boolean bringToTopPreview = ProjectPrefUtil.getPreviewBooleanValue(
-                               fileToParse,
+                               previewFile,
                                IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
 
                if (autoPreview) {
@@ -77,7 +77,9 @@ public class ShowExternalPreviewAction extends TextEditorAction {
                                        }
                                }
                                if (part != null) {
-                                       ((BrowserView) part).refresh();
+                                       // ((BrowserView) part).refresh();
+                                       String localhostURL = getLocalhostURL(null, previewFile);
+                                       ((BrowserView) part).refresh(localhostURL);
                                }
                        } catch (Exception e) {
                                // PHPeclipsePlugin.log(e);
index 04a4cb7..52f6ab4 100644 (file)
@@ -14,6 +14,7 @@ import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowser;
 import net.sourceforge.phpeclipse.webbrowser.internal.WebBrowserUtil;
 
 import org.eclipse.core.resources.IFile;
+import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.browser.CloseWindowListener;
 import org.eclipse.swt.browser.ProgressListener;
 import org.eclipse.swt.browser.StatusTextListener;
@@ -95,7 +96,7 @@ public class BrowserView extends ViewPart implements IShowInTarget {
                        // }
                        // }, null);
                        // } catch (CoreException e) {
-                       // // TODO Auto-generated catch block
+                       // // TO DO Auto-generated catch block
                        // e.printStackTrace();
                        // }
                }
@@ -111,18 +112,21 @@ public class BrowserView extends ViewPart implements IShowInTarget {
                        // }
                        // }, null);
                        // } catch (CoreException e) {
-                       // // TODO Auto-generated catch block
+                       // // TO DO Auto-generated catch block
                        // e.printStackTrace();
                        // }
                }
        }
 
        public void refresh(String url) {
-               if (fInstance != null) {
-                       if (fUrl == null || !fUrl.equals(url)) {
+               if (fInstance != null && url != null) {
+                       if (fUrl == null) {
                                setUrl(url);
                        } else {
-                               refresh();
+                               Browser browser = fInstance.getBrowser();
+                               if (browser != null && !browser.getUrl().equals(url)) {
+                                       setUrl(url);
+                               }
                        }
                }
        }
index 57ed72d..b77af3e 100644 (file)
@@ -65,10 +65,12 @@ public class CompilationUnitEditorActionContributor extends
                                        .getInstance();
                        fShowExternalPreviewAction.setEditor(textEditor);
                        fShowExternalPreviewAction.update();
-                       if (fShowExternalPreviewAction != null) {
-                               fShowExternalPreviewAction
-                                               .doRun(ShowExternalPreviewAction.PHP_TYPE);
-                       }
+                       // if (fShowExternalPreviewAction != null) {
+                       // fShowExternalPreviewAction
+                       // .doRun(ShowExternalPreviewAction.PHP_TYPE);
+                       // }
+                       fShowExternalPreviewAction
+                                       .refresh(ShowExternalPreviewAction.PHP_TYPE);
                }
        }
 }
\ No newline at end of file