Better event handling for browser preview refreshs
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / editor / WikiEditorContributor.java
index f3d93c9..b10a7fb 100644 (file)
@@ -8,18 +8,10 @@
 
 package net.sourceforge.phpeclipse.wiki.editor;
 
-import net.sourceforge.phpeclipse.webbrowser.views.BrowserView;
-import net.sourceforge.phpeclipse.wiki.editor.action.WeblogWikiAction;
-import net.sourceforge.phpeclipse.wiki.preferences.Util;
 
-import org.eclipse.core.resources.IFile;
 import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
 import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
 import org.eclipse.ui.texteditor.ITextEditor;
@@ -41,36 +33,8 @@ public class WikiEditorContributor extends BasicTextEditorActionContributor {
     super.setActiveEditor(part);
     ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
     fContentAssist.setAction(getAction(editor, CONTENTASSIST_ACTION));
-    // jsurfer
-    setBrowserPreview(editor);
-  }
-
-  public void setBrowserPreview(ITextEditor editor) {
-    IWorkbenchPage page = WikiEditorPlugin.getDefault().getActivePage();
-    try {
-      IViewPart part = page.findView(BrowserView.ID_BROWSER);
-      if (part == null) {
-        part = page.showView(BrowserView.ID_BROWSER);
-      } else {
-        //               if (bringToTopPreview) {
-        //                 page.bringToTop(part);
-        //               }
-      }
-      IEditorInput editorInput = null;
-      if (editor != null) {
-        editorInput = editor.getEditorInput();
-      }
-      if (editorInput instanceof IFileEditorInput) {
-        IFile file = ((IFileEditorInput) editorInput).getFile();
-        String srcBasePath = Util.getWikiTextsPath(file);
-        String binBasePath = Util.getProjectsWikiOutputPath(file.getProject(), WikiEditorPlugin.HTML_OUTPUT_PATH);
-        String htmlName = Util.getHTMLFileName(file, binBasePath, srcBasePath);
-        if (htmlName!=null) {
-          ((BrowserView) part).setUrl(htmlName);
-        }
-      }
-    } catch (Exception e) {
-    }
+    BrowserUtil.setBrowserPreview(editor);
   }
 
   public void contributeToMenu(IMenuManager menu) {