From 584fe116c4000137ad8df4b034312d1ac085ba42 Mon Sep 17 00:00:00 2001 From: axelcl Date: Sun, 10 Jul 2005 15:16:13 +0000 Subject: [PATCH] Show browser preview only then editor area is visible --- .../editor/SmartyEditorActionContributor.java | 46 +++++++------ .../phpeclipse/ui/editor/BrowserUtil.java | 71 +++++++++----------- .../plugin.properties | 4 +- net.sourceforge.phpeclipse.xml.ui/plugin.xml | 1 - .../editor/XMLEditorActionContributor.java | 46 +++++++------ .../CompilationUnitEditorActionContributor.java | 2 +- .../phpeclipse/phpeditor/PHPEditor.java | 2 + 7 files changed, 86 insertions(+), 86 deletions(-) diff --git a/net.sourceforge.phpeclipse.smarty.ui/src/net/sourceforge/phpdt/smarty/ui/internal/editor/SmartyEditorActionContributor.java b/net.sourceforge.phpeclipse.smarty.ui/src/net/sourceforge/phpdt/smarty/ui/internal/editor/SmartyEditorActionContributor.java index 5b565d5..4196b46 100644 --- a/net.sourceforge.phpeclipse.smarty.ui/src/net/sourceforge/phpdt/smarty/ui/internal/editor/SmartyEditorActionContributor.java +++ b/net.sourceforge.phpeclipse.smarty.ui/src/net/sourceforge/phpdt/smarty/ui/internal/editor/SmartyEditorActionContributor.java @@ -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); + } + } } 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 4862efa..e9e2230 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 @@ -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); + } } } } diff --git a/net.sourceforge.phpeclipse.xml.ui/plugin.properties b/net.sourceforge.phpeclipse.xml.ui/plugin.properties index a9f2361..30fdf15 100644 --- a/net.sourceforge.phpeclipse.xml.ui/plugin.properties +++ b/net.sourceforge.phpeclipse.xml.ui/plugin.properties @@ -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 diff --git a/net.sourceforge.phpeclipse.xml.ui/plugin.xml b/net.sourceforge.phpeclipse.xml.ui/plugin.xml index 5c5d3c6..5b3e8d2 100644 --- a/net.sourceforge.phpeclipse.xml.ui/plugin.xml +++ b/net.sourceforge.phpeclipse.xml.ui/plugin.xml @@ -29,7 +29,6 @@ - diff --git a/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditorActionContributor.java b/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditorActionContributor.java index 67a706e..95c2f5c 100644 --- a/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditorActionContributor.java +++ b/net.sourceforge.phpeclipse.xml.ui/src/net/sourceforge/phpeclipse/xml/ui/internal/editor/XMLEditorActionContributor.java @@ -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); + } + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java index 1e62f92..524e966 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java @@ -53,7 +53,7 @@ public class CompilationUnitEditorActionContributor extends BasicEditorActionCon } PHPeclipsePlugin.getDefault().setLastEditorFile(file); - + ShowExternalPreviewAction fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance(); fShowExternalPreviewAction.setEditor(textEditor); fShowExternalPreviewAction.update(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index 9cf0602..585993d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -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)) -- 1.7.1