3.x RC1 compatibility show browser preview
authorkhartlage <khartlage>
Sat, 5 Jun 2004 08:24:22 +0000 (08:24 +0000)
committerkhartlage <khartlage>
Sat, 5 Jun 2004 08:24:22 +0000 (08:24 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/CompilationUnitEditorActionContributor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java

index 47829d8..c33d664 100644 (file)
@@ -1,25 +1,34 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials 
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
+ * Copyright (c) 2000, 2003 IBM Corporation and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Common Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/cpl-v10.html
  * 
- * Contributors:
- *     IBM Corporation - initial API and implementation
- *******************************************************************************/
+ * Contributors: IBM Corporation - initial API and implementation
+ ******************************************************************************/
 package net.sourceforge.phpeclipse.phpeditor;
 
+import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.swt.SWT;
 import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorInput;
 import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
 import org.eclipse.ui.texteditor.ITextEditor;
 
-import net.sourceforge.phpdt.ui.actions.PHPdtActionConstants;
-
-public class CompilationUnitEditorActionContributor extends BasicEditorActionContributor {
-       
+public class CompilationUnitEditorActionContributor
+               extends
+                       BasicEditorActionContributor {
+       protected ShowExternalPreviewAction fShowExternalPreviewAction;
        public CompilationUnitEditorActionContributor() {
-               super();                                
+               super();
+               fShowExternalPreviewAction = ShowExternalPreviewAction.getInstance();
        }
 
        /*
@@ -27,19 +36,45 @@ public class CompilationUnitEditorActionContributor extends BasicEditorActionCon
         */
        public void setActiveEditor(IEditorPart part) {
                super.setActiveEditor(part);
-               
-               ITextEditor textEditor= null;
+
+               ITextEditor textEditor = null;
                if (part instanceof ITextEditor)
-                       textEditor= (ITextEditor) part;
-                
+                       textEditor = (ITextEditor) part;
+
                // Source menu.
-               IActionBars bars= getActionBars();              
-               bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(textEditor, "Comment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(textEditor, "Uncomment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.TOGGLE_COMMENT, getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(textEditor, "Format")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT, getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT, getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
-               bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
+               IActionBars bars = getActionBars();
+               bars.setGlobalActionHandler(PHPdtActionConstants.COMMENT, getAction(
+                               textEditor, "Comment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.UNCOMMENT, getAction(
+                               textEditor, "Uncomment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.TOGGLE_COMMENT,
+                               getAction(textEditor, "ToggleComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.FORMAT, getAction(
+                               textEditor, "Format")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.ADD_BLOCK_COMMENT,
+                               getAction(textEditor, "AddBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.REMOVE_BLOCK_COMMENT,
+                               getAction(textEditor, "RemoveBlockComment")); //$NON-NLS-1$
+               bars.setGlobalActionHandler(PHPdtActionConstants.INDENT, getAction(
+                               textEditor, "Indent")); //$NON-NLS-1$ //$NON-NLS-2$
+
+               if (textEditor != null) {
+                       IFile file = null;
+                       IEditorInput editorInput = textEditor.getEditorInput();
+
+                       if (editorInput instanceof IFileEditorInput) {
+                               file = ((IFileEditorInput) editorInput).getFile();
+                       }
+
+                       PHPeclipsePlugin.getDefault().setLastEditorFile(file);
+
+                       fShowExternalPreviewAction.setEditor(textEditor);
+                       fShowExternalPreviewAction.update();
+                       IPreferenceStore store = PHPeclipsePlugin.getDefault()
+                                       .getPreferenceStore();
+                       IAction a = ShowExternalPreviewAction.getInstance();
+                       if (a != null)
+                               a.run();
+               }
        }
-}
+}
\ No newline at end of file
index 4a9d12d..721a6a7 100644 (file)
@@ -104,7 +104,8 @@ import org.eclipse.ui.texteditor.TextOperationAction;
 /**
  * PHP specific text editor.
  */
-public class PHPUnitEditor extends PHPEditor{ //implements IJavaReconcilingListener {
+public class PHPUnitEditor extends PHPEditor { //implements
+                                                                                          // IJavaReconcilingListener {
        interface ITextConverter {
                void customizeDocumentCommand(IDocument document,
                                DocumentCommand command);
@@ -384,15 +385,19 @@ public class PHPUnitEditor extends PHPEditor{ //implements IJavaReconcilingListe
                private List fTextConverters;
                private boolean fIgnoreTextConverters = false;
                //                      private JavaCorrectionAssistant fCorrectionAssistant;
-               public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) {
-                       super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles, store);
-               }
-//             public AdaptedSourceViewer(Composite parent,
-//                             IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
-//                             boolean showAnnotationsOverview, int styles) {
-//                     super(parent, verticalRuler, overviewRuler,
-//                                     showAnnotationsOverview, styles);
-//             }
+               public AdaptedSourceViewer(Composite parent,
+                               IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+                               boolean showAnnotationsOverview, int styles,
+                               IPreferenceStore store) {
+                       super(parent, verticalRuler, overviewRuler,
+                                       showAnnotationsOverview, styles, store);
+               }
+               //              public AdaptedSourceViewer(Composite parent,
+               //                              IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+               //                              boolean showAnnotationsOverview, int styles) {
+               //                      super(parent, verticalRuler, overviewRuler,
+               //                                      showAnnotationsOverview, styles);
+               //              }
                public IContentAssistant getContentAssistant() {
                        return fContentAssistant;
                }
@@ -1650,12 +1655,16 @@ public class PHPUnitEditor extends PHPEditor{ //implements IJavaReconcilingListe
        //      }
        //    }
        //  }
-
        /*
-        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
+        * @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite,
+        *      org.eclipse.jface.text.source.IVerticalRuler,
+        *      org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
         */
-       protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
-               return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles, store);
+       protected ISourceViewer createJavaSourceViewer(Composite parent,
+                       IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
+                       boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
+               return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler,
+                               isOverviewRulerVisible, styles, store);
        }
        //  protected ISourceViewer createJavaSourceViewer(Composite parent,
        // IVerticalRuler ruler, int styles) {
@@ -1790,6 +1799,10 @@ public class PHPUnitEditor extends PHPEditor{ //implements IJavaReconcilingListe
                        } else
                                performSave(false, progressMonitor);
                }
+//             IAction a = ShowExternalPreviewAction.getInstance();
+//             if (a != null) {
+//                     a.run();
+//             }
        }
 
        public boolean isSaveAsAllowed() {
@@ -2130,46 +2143,52 @@ public class PHPUnitEditor extends PHPEditor{ //implements IJavaReconcilingListe
                        fRememberedElementOffset = -1;
                }
        }
-       
-//     /*
-//      * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
-//      * @since 3.0
-//      */
-//     public void aboutToBeReconciled() {
-//
-//             // Notify AST provider
-//             PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement());
-//             
-//             // Notify listeners
-//             Object[] listeners = fReconcilingListeners.getListeners();
-//             for (int i = 0, length= listeners.length; i < length; ++i)
-//                     ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled();
-//     }
-//     
-//     /*
-//      * @see org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit, boolean, IProgressMonitor)
-//      * @since 3.0
-//      */
-//     public void reconciled(net.sourceforge.phpdt.core.dom.CompilationUnit ast, boolean forced, IProgressMonitor progressMonitor) {
-//
-//             // Always notify AST provider
-//             PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast, getInputJavaElement());
-//             
-//             // Notify listeners
-//             Object[] listeners = fReconcilingListeners.getListeners();
-//             for (int i = 0, length= listeners.length; i < length; ++i)
-//                     ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced, progressMonitor);
-//
-//             // Update Java Outline page selection
-//             if (!forced && !progressMonitor.isCanceled()) {
-//                     Shell shell= getSite().getShell();
-//                     if (shell != null && !shell.isDisposed()) {
-//                             shell.getDisplay().asyncExec(new Runnable() {
-//                                     public void run() {
-//                                             selectionChanged();
-//                                     }
-//                             });
-//                     }
-//             }
-//     }
+
+       //      /*
+       //       * @see
+       // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#aboutToBeReconciled()
+       //       * @since 3.0
+       //       */
+       //      public void aboutToBeReconciled() {
+       //
+       //              // Notify AST provider
+       //              PHPeclipsePlugin.getDefault().getASTProvider().aboutToBeReconciled(getInputJavaElement());
+       //              
+       //              // Notify listeners
+       //              Object[] listeners = fReconcilingListeners.getListeners();
+       //              for (int i = 0, length= listeners.length; i < length; ++i)
+       //                      ((IJavaReconcilingListener)listeners[i]).aboutToBeReconciled();
+       //      }
+       //      
+       //      /*
+       //       * @see
+       // org.eclipse.jdt.internal.ui.text.java.IJavaReconcilingListener#reconciled(CompilationUnit,
+       // boolean, IProgressMonitor)
+       //       * @since 3.0
+       //       */
+       //      public void reconciled(net.sourceforge.phpdt.core.dom.CompilationUnit
+       // ast, boolean forced, IProgressMonitor progressMonitor) {
+       //
+       //              // Always notify AST provider
+       //              PHPeclipsePlugin.getDefault().getASTProvider().reconciled(ast,
+       // getInputJavaElement());
+       //              
+       //              // Notify listeners
+       //              Object[] listeners = fReconcilingListeners.getListeners();
+       //              for (int i = 0, length= listeners.length; i < length; ++i)
+       //                      ((IJavaReconcilingListener)listeners[i]).reconciled(ast, forced,
+       // progressMonitor);
+       //
+       //              // Update Java Outline page selection
+       //              if (!forced && !progressMonitor.isCanceled()) {
+       //                      Shell shell= getSite().getShell();
+       //                      if (shell != null && !shell.isDisposed()) {
+       //                              shell.getDisplay().asyncExec(new Runnable() {
+       //                                      public void run() {
+       //                                              selectionChanged();
+       //                                      }
+       //                              });
+       //                      }
+       //              }
+       //      }
 }
\ No newline at end of file