Show browser preview only then editor area is visible
authoraxelcl <axelcl>
Sun, 10 Jul 2005 15:16:13 +0000 (15:16 +0000)
committeraxelcl <axelcl>
Sun, 10 Jul 2005 15:16:13 +0000 (15:16 +0000)
net.sourceforge.phpeclipse.smarty.ui/src/net/sourceforge/phpdt/smarty/ui/internal/editor/SmartyEditorActionContributor.java
net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpeclipse/ui/editor/BrowserUtil.java
net.sourceforge.phpeclipse.xml.ui/plugin.properties
net.sourceforge.phpeclipse.xml.ui/plugin.xml
net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditorActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java

index 5b565d5..4196b46 100644 (file)
@@ -23,29 +23,31 @@ import org.eclipse.ui.texteditor.ITextEditor;
  * Common base class for action contributors for Java editors.
  */
 public class SmartyEditorActionContributor extends BasicTextEditorActionContributor {
-       
-  /* (non-Javadoc)
-   * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
-   */
-  public void setActiveEditor(IEditorPart part) {
-    super.setActiveEditor(part);
-    ITextEditor textEditor = null;
-    if (part instanceof ITextEditor)
-      textEditor = (ITextEditor) part;
 
-    if (textEditor != null) {
-      IFile file = null;
-      IEditorInput editorInput = textEditor.getEditorInput();
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
+        */
+       public void setActiveEditor(IEditorPart part) {
+               super.setActiveEditor(part);
+               ITextEditor textEditor = null;
+               if (part instanceof ITextEditor)
+                       textEditor = (ITextEditor) part;
 
-      if (editorInput instanceof IFileEditorInput) {
-        file = ((IFileEditorInput) editorInput).getFile();
-      }
+               if (textEditor != null) {
+                       IFile file = null;
+                       IEditorInput editorInput = textEditor.getEditorInput();
 
-      ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
-      fShowExternalPreviewAction.setEditor(textEditor);
-      fShowExternalPreviewAction.update();
-      if (fShowExternalPreviewAction != null)
-        fShowExternalPreviewAction.doRun(ShowExternalPreviewAction.SMARTY_TYPE);
-    }
-  }
+                       if (editorInput instanceof IFileEditorInput) {
+                               file = ((IFileEditorInput) editorInput).getFile();
+                       }
+
+                       ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
+                       fShowExternalPreviewAction.setEditor(textEditor);
+                       fShowExternalPreviewAction.update();
+                       if (fShowExternalPreviewAction != null)
+                               fShowExternalPreviewAction.doRun(ShowExternalPreviewAction.SMARTY_TYPE);
+               }
+       }
 }
index 4862efa..e9e2230 100644 (file)
@@ -16,50 +16,45 @@ public class BrowserUtil {
                        // should never happen
                        return;
                }
-               String extension = previewFile.getFileExtension().toLowerCase();
-               boolean autoPreview = forceDBGPreview;
-               boolean bringToTopPreview = true;
-               boolean showHTMLFilesLocal = false;
-               boolean showXMLFilesLocal = false;
-               boolean isHTMLFileName = false;
-               boolean isXMLFileName = false;
-               if (!forceDBGPreview) {
-                       autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
-
-                       bringToTopPreview = ProjectPrefUtil
-                                       .getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_BRING_TO_TOP_PREVIEW_DEFAULT);
-                       showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL);
-                       showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL);
-                       isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension);
-                       isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension);
-               }
-               if (autoPreview) {
-                       String localhostURL;
-                       if (showHTMLFilesLocal && isHTMLFileName) {
-                               localhostURL = previewFile.getLocation().toString();
-                       } else if (showXMLFilesLocal && isXMLFileName) {
-                               localhostURL = previewFile.getLocation().toString();
-                       } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) {
-                               return;
+               IWorkbenchPage page = WebUI.getActivePage();
+               if (page!=null && page.isEditorAreaVisible()) {
+                       String extension = previewFile.getFileExtension().toLowerCase();
+                       boolean autoPreview = forceDBGPreview;
+                       boolean showHTMLFilesLocal = false;
+                       boolean showXMLFilesLocal = false;
+                       boolean isHTMLFileName = false;
+                       boolean isXMLFileName = false;
+                       if (!forceDBGPreview) {
+                               autoPreview = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_AUTO_PREVIEW_DEFAULT);
+
+                               showHTMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_HTML_FILES_LOCAL);
+                               showXMLFilesLocal = ProjectPrefUtil.getPreviewBooleanValue(previewFile, IPreferenceConstants.PHP_SHOW_XML_FILES_LOCAL);
+                               isHTMLFileName = "html".equals(extension) || "htm".equals(extension) || "xhtml".equals(extension);
+                               isXMLFileName = "xml".equals(extension) || "xsd".equals(extension) || "dtd".equals(extension);
                        }
-                       localhostURL += postFix;
+                       if (autoPreview) {
+                               String localhostURL;
+                               if (showHTMLFilesLocal && isHTMLFileName) {
+                                       localhostURL = previewFile.getLocation().toString();
+                               } else if (showXMLFilesLocal && isXMLFileName) {
+                                       localhostURL = previewFile.getLocation().toString();
+                               } else if ((localhostURL = ShowExternalPreviewAction.getLocalhostURL(null, previewFile)) == null) {
+                                       return;
+                               }
+                               localhostURL += postFix;
 
-                       try {
-                               IWorkbenchPage page = WebUI.getActivePage();
-                               IViewPart part = page.showView(BrowserView.ID_BROWSER, null, IWorkbenchPage.VIEW_VISIBLE);
-                               // if (part == null) {
-                               // part = page.showView(BrowserView.ID_BROWSER);
-                               // } else {
-                               if (part != null) {
-                                       if (bringToTopPreview) { 
+                               try {
+                                       IViewPart part = page.showView(BrowserView.ID_BROWSER, null, IWorkbenchPage.VIEW_VISIBLE);
+                                       if (part == null) {
+                                               part = page.showView(BrowserView.ID_BROWSER);
+                                       } else {
                                                page.bringToTop(part);
                                        }
                                        ((BrowserView) part).setUrl(localhostURL);
-                               }
-                               // }
 
-                       } catch (Exception e) {
-                               // PHPeclipsePlugin.log(e);
+                               } catch (Exception e) {
+                                       // PHPeclipsePlugin.log(e);
+                               }
                        }
                }
        }
index a9f2361..30fdf15 100644 (file)
@@ -8,7 +8,7 @@
 # Contributors:
 #     Christopher Lenz - initial english resources
 # 
-# $Id: plugin.properties,v 1.2 2004-09-04 08:59:28 jsurfer Exp $
+# $Id: plugin.properties,v 1.3 2005-07-10 15:16:13 axelcl Exp $
 #
 
 pluginName = PHPeclipse Web Development Tools XML UI
@@ -17,7 +17,7 @@ providerName= WDTE Project/PHPeclipse.de
 xmlEditorName = XML Editor
 dtdEditorName = DTD Editor
 
-xmlEditorPreferencePageName = HTML/XML Editor
+xmlEditorPreferencePageName = HTML in PHP Editor
 
 templates.xml.contextType.name = XML Context
 templates.html.contextType.name = HTML Context
\ No newline at end of file
index 5c5d3c6..5b3e8d2 100644 (file)
@@ -29,7 +29,6 @@
       <import plugin="org.eclipse.ui.workbench.texteditor"/>
    </requires>
 
-
    <extension
          point="org.eclipse.core.runtime.preferences">
       <initializer class="net.sourceforge.phpeclipse.xml.ui.internal.preferences.XMLPreferenceInitializer"/>
index 67a706e..95c2f5c 100644 (file)
@@ -23,29 +23,31 @@ import org.eclipse.ui.texteditor.ITextEditor;
  * Common base class for action contributors for Java editors.
  */
 public class XMLEditorActionContributor extends BasicTextEditorActionContributor {
-       
-  /* (non-Javadoc)
-   * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
-   */
-  public void setActiveEditor(IEditorPart part) {
-    super.setActiveEditor(part);
-    ITextEditor textEditor = null;
-    if (part instanceof ITextEditor)
-      textEditor = (ITextEditor) part;
 
-    if (textEditor != null) {
-      IFile file = null;
-      IEditorInput editorInput = textEditor.getEditorInput();
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
+        */
+       public void setActiveEditor(IEditorPart part) {
+               super.setActiveEditor(part);
+               ITextEditor textEditor = null;
+               if (part instanceof ITextEditor)
+                       textEditor = (ITextEditor) part;
 
-      if (editorInput instanceof IFileEditorInput) {
-        file = ((IFileEditorInput) editorInput).getFile();
-      }
+               if (textEditor != null) {
+                       IFile file = null;
+                       IEditorInput editorInput = textEditor.getEditorInput();
 
-      ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
-      fShowExternalPreviewAction.setEditor(textEditor);
-      fShowExternalPreviewAction.update();
-      if (fShowExternalPreviewAction != null)
-        fShowExternalPreviewAction.doRun(ShowExternalPreviewAction.PHP_TYPE);
-    }
-  }
+                       if (editorInput instanceof IFileEditorInput) {
+                               file = ((IFileEditorInput) editorInput).getFile();
+                       }
+
+                       ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
+                       fShowExternalPreviewAction.setEditor(textEditor);
+                       fShowExternalPreviewAction.update();
+                       if (fShowExternalPreviewAction != null)
+                               fShowExternalPreviewAction.doRun(ShowExternalPreviewAction.PHP_TYPE);
+               }
+       }
 }
index 1e62f92..524e966 100644 (file)
@@ -53,7 +53,7 @@ public class CompilationUnitEditorActionContributor extends BasicEditorActionCon
       }
 
       PHPeclipsePlugin.getDefault().setLastEditorFile(file);
-
       ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
       fShowExternalPreviewAction.setEditor(textEditor);
       fShowExternalPreviewAction.update();
index 9cf0602..585993d 100644 (file)
@@ -55,6 +55,7 @@ import net.sourceforge.phpdt.ui.text.JavaTextTools;
 import net.sourceforge.phpdt.ui.text.PHPSourceViewerConfiguration;
 import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.ui.editor.ShowExternalPreviewAction;
 
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IResource;
@@ -2883,6 +2884,7 @@ public abstract class PHPEditor extends AbstractDecoratedTextEditor implements I
     JavaTextTools textTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
     setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools.getColorManager(), store, this,
         IPHPPartitions.PHP_PARTITIONING));
+    
     // TODO changed in 3.x ?
     //    setRangeIndicator(new DefaultRangeIndicator());
     //    if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE))